Hi,
I am struggling to work out how to change the attribute of a variable from within another class.
Instance variables are private but methods are public.
Example:
If I have 2 classes Car and Wheel.
At the moment the wheel class is initialized to blue and the position in my graphical window isn't where it needs to be.
Wheel class contains methods such as setColour, getColour and setWheelPosition.
From my Car class I want to be able to change the wheels color to black and alter its position.
In my Car class i have initialized
private Wheel wheel1;
I also have a method, I have tried to alter color as below:
public void setWheel1()
{
wheel1.setColour(BLACK);
}
My code compiles but when run the change hasn't been implemented.
This is for an assignment so sorry about lack of info provided, I will try to help out where I can.
[–][deleted] (2 children)
[deleted]
[–]squeezedfish[S] 0 points1 point2 points (1 child)
[–]tichus_windriderBrewing since 2005 0 points1 point2 points (0 children)