1   // joi/3/shapes/InteractiveShapes.java                         
2   //                                                            
3   //                                                            
4   // Copyright 2003 Bill Campbell and Ethan Bolker                         
5                                                               
6   /**
7    * Interactive program to study shapes.
8    *
9    * @version3
10   */
11  
12  public class InteractiveShapes
13  {
14      public static void main( String[] args )
15      {
16          Terminal t = new Terminal();
17          Screen s = new Screen(
18                                t.readInt("screen width:  "),      
19                                t.readInt("screen height: "));      
20          char c = 'a';
21          int x,y;
22          while ( t.readYesOrNo("more")) {
23              char shape = t.readChar("h(line), b(ox), c(lear): ");
24              switch (shape) {
25              case 'h':
26                  int length = t.readInt("HLine length: ");
27                  x          = t.readInt("x coordinate: ");
28                  y          = t.readInt("y coordinate: ");
29                  (new HLine(length, c++)).paintOn(s,x,y);
30                  break;
31              case 'b':
32                  int w = t.readInt("Box width: ");
33                  int h = t.readInt("Box height: ");
34                  x     = t.readInt("x coordinate: ");
35                  y     = t.readInt("y coordinate: ");
36                  (new Box(w,h,c++)).paintOn(s,x,y);
37                  break;
38              case 'c':
39                  s.clear();
40                  break;
41              default:
42                  t.println("try again");
43                  continue;
44              }
45              s.draw(t);
46          }
47      }
48  }
49