Where is the definition for the Car class?
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.
So are you saying i need to create a 3rd .java class and call it Car.java or NewCar.java?
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.
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!!
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.
Please post all of your code and remember to use CODE tags when posting the code.
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.
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?
Re: [RESOLVED] Java help with basic object programming
edit: Didn't see that this was resolved.
It's not obvious it's resolved (apart from the [RESOLVED] in the title ) 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.
@NewToJava1: please do not retrospectively alter your posts - it makes the thread nonsensical and prevents anyone else learning from your problem.
Bookmarks