1   // joi/5/shapes/ShapeOnScreen.java                         
2   //                                                            
3   //                                                            
4   // Copyright 2003 Bill Campbell and Ethan Bolker                         
5                                                               
6   // This file is used in one of the Chapter 5 exercises on shapes.
7   
8   /**
9    * A ShapeOnScreen models a Shape to be painted at
10   * a given position on a Screen. 
11   *
12   * @see Shape
13   * @see Screen
14   *
15   * @version 5
16   */
17  
18  public class ShapeOnScreen
19  {
20      private Shape shape;
21      private int x;
22      private int y;
23  
24      /** 
25       * Construct a ShapeOncreen.
26       *
27       * @param shape the Shape
28       * @param x its x coordinate
29       * @param y its y coordinate
30       */
31  
32      public ShapeOnScreen( Shape shape, int x, int y )
33      {
34          this.shape = shape;
35          this.x     = x;
36          this.y     = y;
37      }
38  
39      /** 
40       * What Shape does this ShapeOnScreen represent?
41       *
42       * @return the Shape.
43       */
44  
45      public Shape getShape() {
46          return shape; 
47      }
48  
49      /** 
50       * The current x coordinate of this ShapeOnScreen.
51       *
52       * @return the x coordinate.
53       */
54  
55      public int getX() {
56          return x; 
57      }
58  
59      /** 
60       * The current y coordinate of this ShapeOnScreen.
61       *
62       * @return the y coordinate.
63       */
64  
65      public int getY() {
66          return y; 
67      }
68  
69      /**
70       * Unit test.
71       */
72  
73      public static void main( String[] args ) {
74          ShapeOnScreen sos = new ShapeOnScreen( null, 5, 7);
75          System.out.println("Shape: " + sos.getShape()); 
76          System.out.println("x:     " + sos.getX()); 
77          System.out.println("y:     " + sos.getY()); 
78      }
79  }
80