humphreybc
September 22nd, 2009, 11:13 AM
Hi there,
I'm having difficulty completing this java assignment we've got... basically I'm trying to make a program that reads some numbers from a file using Scanner, and then use the numbers to form an ArrayList, then from that ArrayList these numbers are used to create new Rectangle objects with varying colour, fill, size and position on the screen.
These are the problems i'm having:
1) Trying to get the while loop in FilePanel.java to read 6 int values at each repetition.
2) The first integer from each line, representing fill/draw, needs to be turned into a boolean true/false. (If-else statement).
3) The second colour variable needs to be turned into a Color. So I have to set a variable to Color.red for a 0, Color.blue for 1, Color.green for a 2 etc...
At the moment I have the program printing the numbers just to test whether it's reading from the file correctly. I'm getting a "NoSuchElementException" error each time I run the program though and i'm not sure what for as it compiles correctly.
Any help would be appreciated, files are attached :)
Thanks!
I'm having difficulty completing this java assignment we've got... basically I'm trying to make a program that reads some numbers from a file using Scanner, and then use the numbers to form an ArrayList, then from that ArrayList these numbers are used to create new Rectangle objects with varying colour, fill, size and position on the screen.
These are the problems i'm having:
1) Trying to get the while loop in FilePanel.java to read 6 int values at each repetition.
2) The first integer from each line, representing fill/draw, needs to be turned into a boolean true/false. (If-else statement).
3) The second colour variable needs to be turned into a Color. So I have to set a variable to Color.red for a 0, Color.blue for 1, Color.green for a 2 etc...
At the moment I have the program printing the numbers just to test whether it's reading from the file correctly. I'm getting a "NoSuchElementException" error each time I run the program though and i'm not sure what for as it compiles correctly.
Any help would be appreciated, files are attached :)
Thanks!