Hi everyone, this is such a dumb question but I'm doing my best in trying to learn java from a book
I'm having a hard time with abstraction/modularization, more specifically I want to call on a method in another class.
Im just messing around here but I have made three classes: Car, Wheels, Shell.
Car will abstract from Wheels and Shell.
Now I'm having a compiler error with Car as it does not like the method:
public int shellSize() { //return the size of the shell from the object big return big.getSize; }
I have tried everything I know to try and figure out why it won't work - turns out I'm stuck and wondered if you could help?
What I have:
public class Car { private Shell big; private Wheels blackTyre; /** * Constructor for objects of class Car */ public Car(String shellColour, int shellSize, String wheelColour, String wheelShape, int howMany) { big = new Shell(shellColour, shellSize); blackTyre = new Wheels(wheelColour, wheelShape, howMany); } /** * Method - Return the size of the shell */ public int shellSize() { //return the size of the shell from the object big return big.getSize; } }
and then my Shell class:
public class Shell { private String colour; private int size; /** * Constructor */ public Shell(String whatColour, int whatSize) { colour = whatColour; size = whatSize; } public String getColour() { return colour; } public int getSize() { return size; } public void getInfo() { System.out.println(" The colour of the shell is: " +colour+ " and the size is: " +size); } }
Thanks in advance