darkagn 315 Veteran Poster Featured Poster

The problem here is that you can't see the fName parameter from the toString() method. This is because fName belongs to the Individual class, not the IndividualArray class. I think that you should remove lines 33-35 since you are outputting your list of Individuals one by one after that anyway.

darkagn 315 Veteran Poster Featured Poster

Take a look at the Java API in the Applet class. You will also need to embed the applet in an HTML page, but it has been so long since I have done that I am not sure I can remember exactly what to do.

darkagn 315 Veteran Poster Featured Poster

Is there any explination to why the command prompt can view the java file but none of my web browser will view the .class file? (Web browsers tested: Internet Explorer, Safari, Google Crome, Firefox, Opera)

Yes, because the code you are trying to run is not an applet, it is just a script that prints to standard output. That's what all those lines that read System.out.println mean.

darkagn 315 Veteran Poster Featured Poster

The error in Step 2 is caused by the fact that the %JAVA_HOME%\bin directory has not been added to your PATH variable. See afzal_01's post about this. Step 3 failed only because Step 2 did also.

darkagn 315 Veteran Poster Featured Poster

Put all of your components that you want to group into a JPanel and set a border around it. Something like TitledBorder should suffice, although if you want to get really fancy try a CompoundBorder. Then you just add the JPanel to your JFrame where you want.

darkagn 315 Veteran Poster Featured Poster

Are you allowed to change the constructor signature in the second GUI? If so, probably the easiest way to achieve what you are after is to pass a reference for the original GUI in the second GUI's constructor and use that reference in the second GUI's addClick() method to callback to the original GUI.

For example, in the "original GUI":

ArrayList<data> info = new ArrayList<data>();

private void getData(){
pd = new GUIProcessData(this);

pd.pack();
pd.setLocationRelativeTo(null);
pd.setVisible(true);
}

public void addData(data someData)
{
 info.add(someData);
}

and in the second GUI:

OriginalGUI parent;

public GUIProcessData(OriginalGUI aParent)
{
 this.parent = aParent;
}

public void addButtonClicked()
{
  data someData = getCurrentData();
  parent.addData(someData);
}

public data getCurrentData()
{
  // method to retrieve the data settings in the second GUI
}

or something like that.

darkagn 315 Veteran Poster Featured Poster

First of all, you need to call your file "filename.java" not filename.class. When you compile the java source file a class file will be created that you can run in a Command prompt or Unix Console (not a browser) by typing

java filename

Otherwise your code should work as expected.

darkagn 315 Veteran Poster Featured Poster

The KeyEvent class has constants for each of the F-keys. You can use a KeyAdapter to listen for a key press, although this is an abstract class so of course you will need to write your own extension. Check out the API on both of these classes for more details.

darkagn 315 Veteran Poster Featured Poster

When you say it's not working, are you getting an error message? Does the string "Came in" print? If the answer is no to both questions then there are no Room objects in your LinkedList. Try a call to roomList.size() to see how many are Room objects exist in your list.

If you are getting the string "Came in" printed, then the problem is that you are just writing r.toString() - you don't actually do anything with that call like print it. Try

System.out.println( r.toString() );

instead.

darkagn 315 Veteran Poster Featured Poster

Hi Shubhang and welcome to DaniWeb :)

I am sorry, but I don't understand what you are asking. Can you please post some code to show us what you mean?

darkagn 315 Veteran Poster Featured Poster

After you have created your eventStudent table can you DESCRIBE it?

DESCRIBE eventStudent;

If not, then the table has not been created. Like I said, you need to run your SQL file before trying to run your php script.

darkagn 315 Veteran Poster Featured Poster

First, make sure that the SQL file has statements that read like this:

CREATE TABLE IF NOT EXISTS Example
-- table definition goes here

Then you actually need to run the mysql query by typing the following into a terminal:

mysql DB_Name < script.sql
buddylee17 commented: You solved this post. +2
darkagn 315 Veteran Poster Featured Poster

postfix = postfix + " " + (Integer.parseInt
(symbol));

This line is attempting to change the entire string to a number, not just the number part of the string. The string "4+4" is not a number, even though the charAt(0) is a digit...

darkagn 315 Veteran Poster Featured Poster

Q1:

The System.exit() method terminates the Java Virtual Machine, not just a single frame.

Q2:

Not sure what you mean by this Question.

darkagn 315 Veteran Poster Featured Poster

The only time that the getByName method hasn't worked for me was when I was trying to access a computer on a different domain / network to me. I had to use the fully qualified computer name for it to work. What is the name you are inserting and are you on the same domain?

darkagn 315 Veteran Poster Featured Poster

Hmm, the InetAddress.getByName(String) method should work. Are you using the full computer name? That is, including the network?

darkagn 315 Veteran Poster Featured Poster
$new_file_name=vsquarel;

I think that this line is incorrect? Possibly it should be:

$new_file_name="vsquarel";

or even:

$new_file_name="vsquarel.htm";

Unless vsquarel is supposed to be a variable, in which case it should be:

$new_file_name=$vsquarel;

Try these suggestions and see if that fixes your problem... :)

darkagn 315 Veteran Poster Featured Poster

Take a look at the date() function in the PHP Manual ( found at http://au.php.net/manual/en/function.date.php ). There is a special format, t, that returns the number of days in a given month. For example, to find the number of days in July, you could write something like:

$julyDays = date('t', mktime(0, 0, 0, 7, 1, 2008));

since the mktime() function makes a time for the supplied hour, minute, second, month, day and year.

Hope this helps :)

darkagn 315 Veteran Poster Featured Poster

The simple bugs are often the hardest to fix. I personally hate the ones where you have a slight spelling mistake in a variable name and instead of throwing an error it just works but not as you'd expect. They can take ages to find.

I would recommend purchasing a PHP compiler. The good ones are a bit on the expensive side, but are well worth it, particularly for big projects.

darkagn 315 Veteran Poster Featured Poster

The only thing I can see wrong with your sql statement is that you don't need single quotes around your variables. But I wouldn't think that would cause an error. What happens when you call the storedRecord function? (It should just print the sql statement to the screen, but what is being printed?)

darkagn 315 Veteran Poster Featured Poster

Try sending an email with only addresses in the BCC field (ie none in the To or CC fields) and when it is delivered each address will appear in the To field, but only the recipient's will be displayed.

darkagn 315 Veteran Poster Featured Poster

Your DB structure looks ok, except that I would probably just sort by name and remove the sort_name field. Your SQL query will look something like:

SELECT * FROM table_ads
INNER JOIN table_categories
ON table_ads.category_id = table_categories.id
WHERE table_ads.active = true
ORDER BY name

Might need a bit of tweaking to get exactly the result you're after, but should point you in the right direction.

buddylee17 commented: good example Aussie +1
darkagn 315 Veteran Poster Featured Poster

This is a generic function to return a specific field ($field) from a table ($tble) in a MySQL database. The exact record returned is specified by the parameter $whr.

So your call:

$msgcount = getdata("messages", "count(*)", "status=0");

will result in the parameter $msgcount being the result of the following sql query:

SELECT count(*) FROM messages WHERE status=0

In other words, the number of messages where the field status=0.

darkagn 315 Veteran Poster Featured Poster

www.php.net is probably a good place to start. This site has some really good documentation and sample code. Of course, if you get stuck there is also DaniWeb :)

darkagn 315 Veteran Poster Featured Poster

Try replacing your computer name with your IP Address. You will need to create an InetAddress object using your IP and pass that object into the constructor for Socket.

darkagn 315 Veteran Poster Featured Poster

I know that your tutorial probably says to connect to port 7 for an echo, but try connecting to a port > 1024. Chances are your errors are due to trying to connect to a port that is in use.

darkagn 315 Veteran Poster Featured Poster

Davisor Publisher is a Java API that can convert from a DOC, PPT or PDF to PDF, XHTML, PNG, JPEG, TXT or XML formats. I haven't actually used it before but it seems to be a good one.

darkagn 315 Veteran Poster Featured Poster

Use e.getSource() to determine where to copy / paste to / from rather than mPane.field. For example, your PasteActionAdapter.actionPerformed method should be:

public void actionPerformed(ActionEvent e)
{
  e.getSource().paste();
}
darkagn 315 Veteran Poster Featured Poster

Actually, I have just realised the mistake. You want the following code for your connect function in the Connection class:

public function connect()
{
   $dsn = ...
   $username = ...
   $password = ...
   try
   {
     $this->connection = new PDO($dsn, $username, $password);
   }
   catch (PSOException $e)
   {
   echo 'Connection failed: ' . $e->getMessage();
   }
}

Notice the removal of '$this' in the parameters to the constructor of the PDO object. That is because we want to reference the local variables as opposed to the class variables (which this signifies).

darkagn 315 Veteran Poster Featured Poster

Do you have a database on the local server called 'example'? And is there a user called 'root' with a password 'root' that has access to that database? Try testing this by connecting to the example database with that username/password in mysql and see if it works that way. Your connect() method looks correct.

Another thing you can try is to put the connect method in a try/catch block.

public function connect()
{
  $dsn = ...
  $username = ...
  $password = ...
  try
  {
    $this->connection = new PDO($this->dsn, $this->username, $this->password);
  }
  catch (PSOException $e)
  {
    echo 'Connection failed: ' . $e->getMessage();
  }
}
darkagn 315 Veteran Poster Featured Poster

I haven't actually used SQL with Java before, but there are plenty of tutorials / examples out there in the world wide web. This link might be a good place to start since you are using MySQL. Good luck :)

darkagn 315 Veteran Poster Featured Poster

Try adding some println statements to your init() method to see where the initialisation fails. Your html code appears correct to me...

darkagn 315 Veteran Poster Featured Poster

I don't think that's possible. You can check the String against each String in your array (which is what you've said you don't want to do?) but how does it make sense to compare a single string with an array of strings? When do you expect them to be equal?

darkagn 315 Veteran Poster Featured Poster

to determine the length of the boundary of an irregular polygon.
The polygon may have between 3 and 9 sides.
The user should be prompted to enter the number of sides and the coordinates of each vertex point.
The program should then calculate and display the total length of the boundary.
You should write a main function to implement this using your Point and Line classes and test the program thoroughly.

It seems as though you've done everything up until this point. For this section you need to:

  • somehow prompt the user for some coordinates
  • use these coordinates to form some lines
  • sum the length of the lines with the Length method you wrote for Line

All of this needs to be done inside a main method in order for it to be run.

Give that a go and repost if you still have problems. :)

darkagn 315 Veteran Poster Featured Poster

Hi naiad08 and welcome to Daniweb,

We have some pretty strict rules here in that we can't just do the work for you, we need to see some effort and then we can guide you. What have you done so far? Where are you having problems? Do you know the difference between those sorting algorithms?

darkagn 315 Veteran Poster Featured Poster

You can GET the date and time by using

System.currentTimeMillis();

This returns a long type that represents the number of milliseconds since Jan 1, 1970. You can format that long by using the java.util.Calendar and java.text.DateFormat classes.

darkagn 315 Veteran Poster Featured Poster

True, to an extent, but it still works with a url, as it will be given a "file://" url, rather than an "http://" url. It is still valid.

I didn't know that - thanks masijade :)

darkagn 315 Veteran Poster Featured Poster

Instead of

URL url = new URL( path );
BufferedImage image = ImageIO.read( url );

try

File imageFile = new File( path );
BufferedImage image = ImageIO.read( imageFile );

Generally URLs are only used for the internet, use Files for local stuff...

darkagn 315 Veteran Poster Featured Poster

That's not right! char *tensWord[] is an array of pointers to char. As I initiallised it above, it just so happens that the char being pointed to is at the start of a string/array of characters.

Sorry dougy83, you are correct, and thanks for helping my understanding. :)

darkagn 315 Veteran Poster Featured Poster

You write it like this:

int main()
{
  int x, y;
  cin >> x;
  cin >> y;
  if (x==0 && y==0)
  // the && means and, use || for or
  {
    cout << "x/y = 0";
  }
  else
  {
    cout << "neither is 0";
  }
  return 0;
}
darkagn 315 Veteran Poster Featured Poster

const char *tensWord[] = {"", "ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"};

can i ask what is *tensWord[]? i think ur wrong in that part i think it's
const char *tensWord[][10] = {"", "ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"};
and it is right to use char only? why do you use const>?

You use const in this situation because the strings aren't going to change, you want them to remain constant.

The char * is an object type in C++ that literally means "pointer to char". The char *tensWord[] is a pointer to a char[].

and how about the 148 or any that has no exact pattern in one tens hundreds.??

The provided code will be close if not spot on for solving your problem here. It should print out "one hundred forty eight" because dougy83 has split the number into hundreds, tens and ones and then printed the result for each.

darkagn 315 Veteran Poster Featured Poster

Ahhhh

Ok, your line at the bottom of your code that reads

String empName = input.nextLine(); // read employee name

remove the word "String" from this line.

The problem here is that you have already defined empName but you want to assign a new value to it. When you say

String empName = input.nextLine();

you are defining the variable but also assigning an initial value to it. After that to reassign a new value, you just write

empName = input.nextLine(); // get another line of input

Then when the loop comes back to the top it will check the same variable with the new value.

darkagn 315 Veteran Poster Featured Poster

Hi jcato77 and welcome to DaniWeb,

jamesbien is completely wrong with his advice. But I am not sure about your question. Do you mean that the code inside the loop that jamesbien referenced never executes, or that it executes even when the user inputs the word "STOP"?

darkagn 315 Veteran Poster Featured Poster

You can return your delimiters from the StringTokenizer by adding a third parameter when you create the tokenizer object.

StringTokenizer st = new StringTokenizer( input, delims, true );

Now your nextToken calls will return the delimiters as tokens as well. This will require changing how many calls you make in the next section of your code.
When you get each delimiter you can parse it to a char very easily:

// since we know the delimiter token has a length of 1
char del = ( st.nextToken() ).charAt( 0 );

P.S. Unless your assignment specifies that you must use a StringTokenizer, you really should listen to Ezzaral's advice...

darkagn 315 Veteran Poster Featured Poster

You are probably better off using a local smtp server if you have access to one...

darkagn 315 Veteran Poster Featured Poster

Hi bmbvm5 and welcome to DaniWeb,

Unfortunately we are not allowed to just do the work for you, we need to see some effort and then we can give pointers. What have you done so far? What problems are you having? Just giving us your assignment specification isn't enough sorry.

darkagn 315 Veteran Poster Featured Poster

http://en.wikipedia.org/wiki/Red_black_tree describes the difference in fairly good detail. The main difference between the two is in the worst case, where a BST can be as bad as O(n) for insertion, search and delete, but a red-black tree is O(log n) in the worst case for these operations. The article is well worth a read as it describes how the red-black tree maintains its balance.

darkagn 315 Veteran Poster Featured Poster

Hello again,

I'm not sure about php (in fact I think you need to work in a server environment to write in php??) but for java the javac compiler is fine for a beginner. Also there are lots of really good tutorials and some great downloads and documentation on the sun website (sun are responsible for the development of the java language) http://java.sun.com/ . If you are planning on developing in the windows environment you might want to consider downloading Cygwin from their website http://www.cygwin.com/ which is a unix-style environment for windows.

Hope this gets you started,
darkagn

darkagn 315 Veteran Poster Featured Poster

Hi there Joe and welcome to Daniweb,

IMHO there is no real right or wrong answer here. But speaking from personal experience I learned Java first then moved on to C and C++. I found this way of learning the three languages effective for me and there are a few reasons for this.

Java is called an object oriented language. Many people (myself included) find it easier to program in such a language because (almost) everything in the language is an object. This makes it easier to design and subsequently code.
Another reason why I found Java an easier first-up language was the compiler gives very descriptive errors when there is a problem with your code.

C++ is also object oriented in theory and is a very popular language. It is hard to see C++ becoming extinct because of this popularity. However I found that debugging C++ was particularly difficult for a beginner.

C is not object oriented at all, it is called a procedural language. I found C much harder to learn than the other two.

I don't really know much about C#.

However all of these languages do have a similar syntax to them. If you learn C++ chances are that you will at least be able to follow a java program and vice versa. In short, Java and/or C++ are both good languages to start with and my opinion stated above is probably a bit biased by the fact that …

darkagn 315 Veteran Poster Featured Poster

No, those are local variables inside the method. They do not have access modifiers like "private".

Oops ... good point. :$