aspose file tools*
The moose likes Java in General and the fly likes Need some help finishing classes program? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Need some help finishing classes program? " Watch "Need some help finishing classes program? " New topic
Author

Need some help finishing classes program?

bob jenkins
Greenhorn

Joined: Nov 14, 2012
Posts: 12
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
erase



if you need more info from me please tell me
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

it wont read the instructions of the input file


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.)
bob jenkins
Greenhorn

Joined: Nov 14, 2012
Posts: 12
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
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11494
    
  16

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
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

bob jenkins wrote: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.


So something between step A and step Z is not behaving as you expected. But unless you actually observe what is happening at steps B through Y like I suggested, you'll just be guessing.

Also, do what Fred said and code and test small pieces independently rather than all at once.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need some help finishing classes program?