Dave Tolls wrote:
That is looking for a static iterator() method on the Cars class.
Presumably it doesn't have one.
I'm guessing you want to actually iterate over the carList, so you want to call the iterate() method on that instead.
Kai Viz wrote:Well. Don't I feel stupid now.
Liutauras Vilda wrote:Welcome to the Ranch.
You still can improve a bit your variables naming.
1. Carlist should read as carList
2. Profit as profit
3. class name Cars should read as singular Car, as one instance refers to a one Car object.
4. All parameter variables in method addCar are also started with an upper case. Should start with lower.
Note: Class names - start with upper case. Variable names, methods with lower case - it is important.
5. Method name cardSoldout. The name does not make sense to me and does not reveal method purpose. Please try to come up with something better. And usually method should be verb, while class a noun.
6. Indentation is not consistent. You use two different styles:
Stick to a one and always follow that, unless you're told by a senior to use different one. In case of that, fully switch to that and forget previous one.
Liutauras Vilda wrote:Also, why profit is int and where the variable Price comes from?
Have no idea what the lot is, most likely someone else won't know too.
Ifwhen you write comments, spend decent amount of time and come up with clear comments so won't be more questions than answers. Actually questions shouldn't come up at all.
Liutauras Vilda wrote:Maybe you need to have a field in Car object which is called sold. So you could check if car is still on the market bugatti.isSold().
That method soldOut I still think is incorrect. Naming at least. Maybe sellCar, which would tell you the actual intense of the method.
I'd think, that your ArrayList is a market. Cars which are in that list are on the market. If you want to sell it, you check if car is sold, if not, then you look it up in ArrayList, find it, sell it (remove from the list, calculate profit), make car as sold out.
Remember, method should be small enough and do one and only one thing. If you need to calculate profit, consider of creating another method which does that.
What I was trying to say you about variables Profit, getModel, getYear - all these are undefined in class LotInventory, so you should be getting compilation error.
Go back to your code and check how you wrote that method call there in your earlier post.
Kai Viz wrote:getModel() is a method in the Car class, and model is defined there.
You are missing () there. Beside that, you should invoke method on particular instance of the Car class - you failed to do that too. When you write code compile it often enough, every 5 or even 3 lines of code, so you'll catch errors earlier.
Kai Viz wrote:
You are writing that code, so you are responsible for its correctness
Kai Viz wrote:If it's wrong, it's my teachers fault
I think you have to fix it before you pass. Currently your code doesn't even compile. Think about the class as about the place to grasp the topic very well, not about just passing it. You'll need that knowledge in your later modules and at work after all.
Kai Viz wrote:I'll have to fix it after this class (need to pass the class, after all!)