Reputation: 3
So I have an assignment for college and there was two tester classes given one called GetMarks and another called Tester, but there seems to be something wrong with the tester. When trying to compile it after making no changes to the source code it fails to compile giving the error message stating; cannot find symbol - method size()
The code that is highlighted is:
if (vw.getCars().size() == 3)
I have no idea how to amend this and no idea what the issue is. If anyone knows what i need to do I would be grateful. If you would like to see the entire source code of the whole project it's here. https://www.dropbox.com/s/yi7talq5yisvqqm/Assignment3.zip
Upvotes: 0
Views: 2723
Reputation: 1079
what you can try doing is this. You can make a method that will return the ArrayList that is in the CarManufacturer.java, Something called getList() would work.
public int getList(){
return this.cars;
}
Then when you do the statement vw.getList().size() it will return an integer value. Best of luck!
Upvotes: 0
Reputation: 3641
Your getCars() method returns a String. You can't do a .size() on a String. I am not sure what you are trying to achieve in the code. So you can start off by investigating what that line in Tester.java does and proceed from there.
EDIT
You have an attribute cars in CarManufacturer.java, which is an ArrayList. The getter for cars is modified to return String. Check that for starters.
Upvotes: 1