// class Building.java //:Assignment 4: //:Student Name: Duo Zhou //:Studnet Number: 722452 /**FileName: Building.java * Date: July, 27, 2000 * Purpose: Learn how to use JFrame, JPanel, Synchronized method, creating * multithread, the basic idea of creating GUI * Name of Files: This assignment include Building.java, ConnectedWall.java, * Elevator.java, ElevatorFrame.java, ElevatorPanel.java, * Floor.java, MailDeliveryApp.java, MailPiece.java, * Position.java, Robot.java * Brief Discription: Nothing is changed from the original sample code. */ public class Building{ public static final int MAX_FLOORS = 4; public static final int BASEMENT = 0; private Floor[] floors = new Floor[Building.MAX_FLOORS]; private Elevator elevator; private Robot robot; public Building( Floor[] floors){ this.floors = floors; this.elevator = new Elevator(this); // create elevator for this building } public Robot getRobot(){ return robot; } public void setRobot(Robot robot){ this.robot=robot; } //public void setElevator(Elevator elevator){ // this.elevator=elevator; //} public synchronized Elevator getElevator(){ //Everything is getting access elevator through building, return elevator; // so if we make this method synchonized, then the } // elevator object can be accessed by only one user; public Floor getFloor(int floorNum){ return floors[floorNum]; } }// end of class Building