Hi Guys I am writing a small program of a car race and have done the first step which was my own classes one called die and one called car that has in it the attributes for the car - odometer, speed - and getters and setter for each, now it is time to write the main program and I feel as though I am hitting my head against a brick wall I just cannot think straight, probably due to lack of sleep anyway in this part I need to create an instance (??have no idea what this is) of the Car and Die class, have a variable called trackLength (I am setting this as a length of 40) and use a while loop so the car races around for 10 laps. So could someone just give me a big push in the right direction PLEASE what should I do first?? Second? Thankyou in Advance and I really hope this all makes sense.
Sounds like you just need to glue your little objects together. I often make a main driver program that does nothing but set things up and make them go. This is pure guesswork since I know so little about your program:
The line "Car racer = new Car()" creates an object instance of the class Car and sets the variable racer to point to that instance. The line for Track does much the same thing. Does that make sense?
Are you working on Java in a class or on your own? Maybe the gang here can recommend some good books that start from the beginning.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
posted 13 years ago
Thankyou very much Stan Sorry it was hard to grasp without my code, didn't feel confident enough to put it up in case it was all wrong - I would feel so stupid lol I am enrolled in a course for next year so am trying to become comfortable with it (when my boys give me a chance) before then. I have a Java book by Walter Savitch. Thankyou again for your help! Christie
Seriously Rick? Seriously? You might as well just read this tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java