• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need some help finishing classes program?

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic