okay so i have this program that is supposed to read an input file containing a series of commands and act appropriately on those commands. in addition i am supposed to create three additional classes(which i have done already) to support my main java program. the main program is supposed to read a plain text file and follow the instructions contained in the file. it then will create a drawing panel window and the program should follow all the commnds in the input file with a pause of 1000 milliseconds. Each line of the input file contains a seperate command and there are four possible commands:
1. Construct 2. Draw 3. Dance and 4. Erase
Those other three classes are just shapes that draws a shape and has a method to make it dance(move)
i have done these already if you want to see one of them just tell me to post it up.
I have most of the main program done. It opens up the drawing panel and everything, but it wont read the instructions of the input file so it can draw the shape in the drawing panel. If anyone can help in what i'm suppose to add to my program it will be appreciated. I got of ton of help with my last question and i was very glad with the results i got
Heres the main program:
and here's what one of the input files/txtfiles has stored in it:
construct A 0 100 red
draw A 0 200 300 red
dance A 0 10
Meaning what, exactly? Errors? Copy/paste the exact, complete error message and indicate clearly which line is causing it.
Or does it just not do what you want? Exactly what does it do instead? (And before you say, "It does nothing," go to where you read the input and add a bunch of printlns to show the file name, its full path, whether it exists, how big it is, what the result of each read is, etc.)
Joined: Nov 14, 2012
well it doesnt get errors. When i run it it opens up the drawing panel which is what it's supposed to do.
but it won't do what what the text file tells it to do.
for example: here is how i run it java Homework2 hwk2input1.txt
when i run that it's supposed to open up the drawing panel and then show the shape moving on the drawing panel
When you are writing code, it is all about separating tasks and responsibilities. Personally, I wouldn't bother writing any code about reading the command file until I was sure I could do the things the command file was supposed to tell me to do.
Alternatively, I wouldn't bother writing the construct/draw/etc methods until I knew I could parse the file and call the methods.
So right now, it is not clear if the problem is with reading the file and calling the commands, or if the problem is with the commands themselves.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors