• 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

Creating the Main program

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Christie Apps
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic