Page 317 - Introduction to Programming with Java: A Problem Solving Approach
P. 317

                7.10 Problem Solving with Multiple Driven Classes 283
 public void run(int steps)
{
}
// end run
Scanner stdIn = new Scanner(System.in);
char input;
boolean OK = false;
for (int step=0; step<steps; step++)
{
}
// end for
System.out.print(
}
} // end if
while (!OK);
do
{
"Enter 'b' for button or 'e' for end switch: ");
input = stdIn.nextLine().charAt(0);
if (input == 'b')
button.hit();
switch (state)
{
}
else
{
{
}
case 0: case 2:
System.out.println("Door stopped by button.");
break;
case 1:
System.out.println("Door moving up.");
break;
case 3:
SysAtepm.oautg.porintPlnD("FDoorEmnovihngadnowcn.e")r; // end switch
OK = true;
switch (state)
{
}
case 1:
upSwitch.hit();
System.out.println("Door is up.");
OK = true;
break;
case 3:
downSwitch.hit();
System.out.println("Door is down.");
OK = true;
break;
default:
System.out.print("Already stopped. Enter 'b': ");
OK = false;
// end switch
} // end GarageDoorSystem class
Figure 7.25b
GarageDoorSystem class for the Garage Door program—Part B









































   315   316   317   318   319