Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Creating the Main program  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!