| Author |
Method Access
|
Malk Boy
Greenhorn
Joined: Feb 17, 2005
Posts: 1
|
|
My question is how do I access the methods of the engine class in the control class when I pass an object car to control. Thanks for any help public class Car { Engine e; public car () { e = new Engine(); } public static void main ( String[] args ) { Car c = new Car(); Control ctrl = new Control ( c ); ctrl.runSystem(); } }
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
Just connect the dots: CarRef.EngineRef.method();
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
As an aside, note that this version of Car could be streamlined to...
|
 |
 |
|
|
subject: Method Access
|
|
|