// how do objects, classes, references work? // Scaled back Worker class: class Worker { // FIELDS of class consist of variables and methods // Instance variables: int id; String name; // Constructor (special kind of method that // returns address of newly // created object automatically!): Worker() { } // Methods: // $toString$ is "built-in" and prints // whatever String you wish // when you print the reference to an object // String toString() { // return "Worker: "+name+", ID: "+id; // } } // class Worker public class Simulation { public static void main(String[] args) { // Create a new Worker object and // store the addres of that object in $worker1$. // Also called INSTANTIATING AN OBJECT/CLASS ____________ ____________ ; ___________ = ___________ ___________ ; // Print value of reference: _________________________________________ ; // Set $worker1$ instance variables. // Why INSTANCE VARIABLE? // Each object is an instance of a class! // (To make variables and methods shared by // all objects instantiated from same class // use $static$ -- discussed later) _________________________________________ ; _________________________________________ ; // Print description of $worker1$. Go back and // remove comments on $toString$ method: _________________________________________ ; } } // class Simulation