JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

off course you can do without, but you'll still need to test whether or not the element is within range.

... which you don't need to do if you are going to access the array???
Seriously, I would be interested to see your code where this array is better than just (i+1).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

int[] arrNumbers = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};

ie arrNumbers == i+1

really?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Did you do what I said?
You have a very simple bug in your user input code. You need to add one very short method call and it will work.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

1. Print out both those values after they are input so you can see exactly what values you are trying to use.
2. In your catch blocks don't just print "there was a problem", use ex.printStackTrace(); to see all the info related to the problem.

ps: The server name may surprise you when you print it ;-)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

According to http://compilers.iecc.com/comparch/article/01-03-037 it's LL(1), recursive descent

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

To clarify:
You have a JFrame with a JPanel subclass that displays a menu. When one of the menu items is selected you want to display another JPanel subclass that contains your board (and this replaces the menu panel?).
If so, I don't see the need for anything more than just adding the new panel (and removing or hiding the menu panel). The constructor for the board JPanel should contain or call evethung needed to populate the board. Depending on what layout manager you are using you may need to pack() or revalidate() your JFrame afterwards. I don't understand what the Invoker code is for, or why its needed.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Please mark this "solved" so people know not to worry.
J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It would go a lot better if you started your Timer!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

TCP.
UDP messages are sent, but there is no check or guarantee whether they arrive or not. Also if you send multiple UDP packets there's no guarantee that they will arrive in the same order as they were sent.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

... and hope to have a great time at www.daniweb.com :)

I'm sure you will. You contributions are very welcome.. Thanks for helping.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Probably there was something wrong with the file path/name that you typed in.
You could print out the user's input so you have a record of what the path/file name were.
Rather than using
System.err.println("Error: " + e.getMessage());
in your catch block, use
e.printStackTrace();
which will give you much more info on exactly what and where the problem was.

JavaPrograms commented: Great solution! +3
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Abruptly terminates the program, sending a return code of 0 to the operating system. Often used to end a program, but does have dangers in that it doesn't allow other parts of the program to close or free any resources they may have open.
In this particular case it's not needed, because the program will terminate normally at the end of the main method anyway.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hi David, welcome to DaniWeb.
I know your intentions were good, but we're here to help beginners build their own Java expertise. By posting complete pieces of code you run the risk that people will copy/paste without fully understanding, thus learning nothing (except maybe that it's easier to cheat than to work). It's much better to steer/prompt/guide them to write their own code.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sorry, I don't know how to explain that any more clearly. Please re-read the whole of my previous post.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You are using Windows, yes?
The delimiter in Windows is \
But in Java that character is used to start escape sequences, so to create String containing a \ you have to code \\, exactly as in stephen84s post.
In your first version you were using ' characters, coded in Java as \'
Because ' is a valid character in a Windows file name you were creating a file called 'Users'gourav'Document'NetBeansProjects'WebApplication2'web'league1.txt in your current working directory.
When you replace the \' with \\ the string is parsed as a full path with directory names etc, and you probably have a mistake in there somewhere (incorrect directory name, access rights problems...?).
In Windows you can also use / as a delimiter and it (usually) works, but \ is the "correct" delimiter.

Next time please try to describe your problems properly. "stops working" and "is not working" tells us nothing useful. Always post exactly what you did in your code, the full text of any Exception or other error message, and describe exactly how the output was different from what you expected. I'm not going to try to answer any more problems that are not fully described.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

See stephen84s repky. You seem to be trying to use ' as a path delimiter!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Is writing what one thing many times? Please try to explain exactly and precisely what is happening.
You create your FilWriter in append mode (second parameter is true), so every time you run the application you get another copy of the data added to your file.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sorry, this is nothing to do with copy constructors.
You create an array and give it a size (30), and initially all those elements are null. You have a method to populate the array with data, but unless you call that 30 times, there will still be null elements in the array.
Your loops then process every element in the array, even the null ones, and when you do that you get an NPE.
Rather than loop through all the array elements, use your arraycounter variable to limit the loop to just the elements that have been populated.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Every time you read a line you call displayText, in which you create and add a new TextArea.
You should create the frame etc with a single text area when the application starts, and just add the String to that existing text area in displayText.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

what exactly were the "last modifications"? because that's where we need to concentrate.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

return printer(s); calls printer(s) again, which executes down to the last line where it executes return printer(s); etc infinitely

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Just one variable for each kind of boat, and re-use it for multiple new boats.

"Again I get the error" I guess you know what you mean, but I don't. The boats will be stored in the list in the order that you add them.

ps: I'm finishing now. See you next week. Good luck
J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

And why I cant get the order right?

Fix the first problem first, then look at the order again.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If I got this right
public static PowerBoat powerboat1 = new PowerBoat();
public static PowerBoat powerboat2 = new PowerBoat();

and so on?

yes, that's one way that will work

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The problem is in the way you set up your test data.
You create one PowerBoat, set its values, add it to the list. The first element of the list is now a reference to that PowerBoat
You then change the values of that same PowerBoat, and add it to the list again. Now both the elements of the list refer to the same one PowerBoat, which has the latest values.
You can re-use your powerBoat variable, but you have to create a new PowerBoat for each one you want to add to boat.
ditto Sailboat, of course.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Can you please post the complete current code? It's impossible to diagnose any further without it.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, so now you have no "static"s anywhere in Boat, SailBoat or PowerBoat, yes?
So what's still wrong?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sorry. I don't understand that last post. Where's "here"?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Looks like you have made exactly the same mistake with the variables in your subclasses.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Depends on what kind of programming work you want to do. C/C++ for really technical stuff, C# or Java for more commercial stuff (less exciting but more jobs available).

<personal opinion>Personally I think that learning C++ first really harms people's understanding of object-oriented design, so I would recommend C# or Java first.</personal opinion>

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Short answer: Java is very widely used in commercial and corporate applications. It runs at least as fast as any other serious programming language except hand-tuned C code.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, no, that's exactly the wrong thing to do, and that's why "in the output I get same values".
static means there is just value for that variable, and all the instances share that one value. You don't want that, you want each instance to have its own colour and length

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The problem may be in the Boat class - did you declare colour and length as static by any chance?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You test for 'e' as a consonant. Did you mean 'w'?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Do you mean I need to use a unique array called Employee to and save each type of employees into that array?

That's how I would do it - define an Employee class that holds info for ONE employee, with similar subclasses, then put all the instances of any of those classes into a single array of Employee objects.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

R32@
This is just a question, because I don't know what you have or have not been taught yet, but did you consider an array of Employees, into which you can store instances of a SalariedEmployee or the other two subclasses?

Employee[] allEmployess = new Employee[100];
allEmployess[0] = new SalariedEmployee...

I'm asking because the way you have it now, with one big Employee class containing arrays for fName, lName etc isn't going to work well with polymorphism and subclasses.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Default access for class members is within the same package ("package-private")
http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html

and yes, void getXXX() is a confusing violation of standard naming conventions, although maybe not the biggest problem priority for this O/P.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's nextLine(), not Line().

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

use .equals() when comparing strings rather than ==
try to read this link for more info
Java: ==,.equals()

Good advice, yes, but in this case the code is comparing chars, not Strings

char oo = xx.next().charAt(0);
if (oo == 'y')...{

so .equals cannot be used in this situation.


Maybe the problem here is that the y/n is read with a next(), which will leave a newline character unprocessed in the scanner's buffer, so the student name's nextLine() returns the remainder of the current line, ie "".
At line 49 try a nextLine() rather then a next() to read the y/n so that the newline character is processed normally.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Anything(eg arrays) you create in your Java app is lost when the app terminates. To save data for later use you need to write it to a file or a database. Probably the easiest is to write in in text form (same as printing) to a text file. Google will give you lots of examples and explanations.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

So where and how exactly does the map come into it, and what exactly is the question about the map?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Maybe I haven't understood the question?
You already posted a method that gets the SomeObject corresponding to a String that's passed as a parameter.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Can you create the map as Map<String, SomeObject > ?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That depends on the bank, but in general:
A savings account pays interest, and can never have a negative balance
A current account may or may not pay some interest, and may allow negative balances.
A current account is used for day-to-day transactions using cheques or debit cards or on-line systems, and allows cash withdrawas through cash machines.
Savings accounts are less likely to have cheque books or debit cards or allow cash withdrawals, they may just allow transfers of funds into/out of the owner's current account.

Having said that, banks offer accounts with every possible mixture of those characteristics, so in practice there isn't a clear distinction between them.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

In your valueChanged method ev.getSource() will just be the list box itself, which you probably knew anyway. You can use list.getSelectedValue() to find out which object in the list is currently selected inside your valueChanged method.

ps @stultuske: in this particular case both getSource and getSelectedValue return the actual object in question, so an == test is appropriate.

stultuske commented: learning every day :) +12
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Java is case sensitive. Jlabel != JLabel

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I guess you could create a on-line .bat file containing that command, but that hardly seems worth the bother, and doesn't lead on to anything useful. As you build your java skills you will start using some kind of IDE to compile and test code, and you will start packaging your applications into .jar files which can be double-clicked to run them by default.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Did you mean
javac javaclassname.java
or
java javaclassname

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

This is a common symptom, and the usual cause is that Java is looking for the icon files in the wrong place.
new ImageIcon(iconName) will not throw an exception if there is a problem, it just returns null. If you pass null to a JLabel or JButton for the image icon that also does not throw an exception, it just doesn't display an image. So the net effect is that if there is a problem reading the file you get no error messages, you just don't see the image.

You can use this little fragment to see where Java is looking for your files:

java.io.File f= new java.io.File(iconName);
System.out.println(f.getAbsolutePath());