// @topic S-0303-03-01-40 Java MVC Architecture Demo 2 // @brief class Elevator (business object that belongs to the Data Model Tier) package demo; public class Elevator { //------------------------------ // data //------------------------------ public static final int maxFloor = 6; public static final int minFloor = 1; private static final int directionUp = +1; private static final int directionDown = -1; // -1..Down +1..Up private int direction = directionUp; private int floor = 1; private int state = 0; // moving up, moving down, standing //------------------------------ // constructors //------------------------------ public Elevator( int floor ) { this.floor = floor; }//Elevator //------------------------------ // operations //------------------------------ void move() { floor = floor + direction; if ( floor > maxFloor ) { floor = maxFloor; direction = directionDown; } else if ( floor < minFloor ) { floor = minFloor; direction = directionUp; } }//move public int getFloor() { return floor; }//getFloor }//class Elevator