294 Methods Chapter 6 To create operations, we (Yahoo free web hosting)
294 Methods Chapter 6 To create operations, we examine the verb phrases listed with each class. The phrase moves to other floor listed with class Elevatorrefers to the activity in which the elevator moves between floors. Should moves be an operation of class Elevator? The elevator decides to move in response to a button press. A button signals the elevator to move, but a button does not actually move the elevator therefore, moves to other floor does not correspond to an operation. (We include the operations for informing the elevator to move to the other floor later in the discussion, when we discuss the verb phrases associated with the buttons.) The arrives at a floor phrase is also not an operation, because the elevator itself decides when to arrive on the floor after five seconds of travel. The resets elevator button phrase associated with class Elevator implies that the elevator informs the elevator button to reset. Therefore, class ElevatorButtonneeds an operation to provide this service to the elevator. We place this operation (resetButton) in the bottom compartment of class ElevatorButtonin our class diagram (Fig. 6.21). We represent the names of the operations as method names (by following the names with a pair of parentheses) and include the return type after the colon: resetButton() : void The parentheses can contain a comma-separated list of the parameters that the operation takes in this case, none. For the moment, most of our operations have no parameters and a voidreturn type; this might change as our design and implementation processes proceed. Floor floorNumber : Integer capacity : Integer = 1