have multiple cars print out.
Printable View
have multiple cars print out.
Where is the definition for the Car class?Quote:
HOW to do more than one car
I don't see where you create any cars.
If you had a Car class, you would use the new statement to create new cars.
of the class?
what all should i include inside of the class
What ever needs to be there to define a Car. All the properties of a car that you need.
It's normal to give classes a name that describes what they are modeling (representing). NewCar is not a sensible name unless the class can only represent new cars and not old cars which clearly isn't the case as your second car is 1 year old. Therefore, the class should probably be called Car.Quote:
So are you saying i need to create a 3rd .java class and call it Car.java or NewCar.java?
It's a bit hard to tell you how to do more than one car when you haven't shown us the code you are using at the moment.Quote:
If anyone can help me figure out HOW to do more than one car, because currently no matter what i do it only will add one car, then i would greatly appreciate the help!!
Please post all of your code and remember to use CODE tags when posting the code.
e: 10
Color: Black
Car Price: $18,500
How does your code generate the output you want?
So why is your 'Car' class called 'Cars'. The word 'Cars' implies more than one car but the class is a representation of a single car.Quote:
Car Class
Your code won't even compile, how can you have run it? If your code doesn't compile you should post the compilation error messages so we can fix those points first. For example: Your main method declares a variable 'aUsedCar' but then uses a variable called 'aCar' which hasn't been declared anywhere.
Whilst this won't stop the program compiling, you make lots of getXXX() method calls but you don't assign the returned values to any variables so what is the point in calling the methods?
edit: Didn't see that this was resolved.
It's not obvious it's resolved (apart from the [RESOLVED] in the title :p) because after sorting the problem the OP has gone through the thread and changed all of their posts, so our comments no longer make sense.Quote:
edit: Didn't see that this was resolved.
@NewToJava1: please do not retrospectively alter your posts - it makes the thread nonsensical and prevents anyone else learning from your problem.