Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Feb 9th, 2010 | Syntax: Java | Size: 0.64 KB | Hits: 16 | Expires: Never
Copy text to clipboard
  1. public class Shape
  2. {
  3.    private int x, y;    // coordinates of shape
  4.  
  5.    // constructor
  6.    public Shape( int x, int y )
  7.    {
  8.       this.x = x;
  9.       this.y = y;
  10.    }
  11.  
  12.    // set x coordinate
  13.    public void setX( int x )
  14.    {
  15.       this.x = x;
  16.    }
  17.  
  18.    // set y coordinate
  19.    public void setY( int y )
  20.    {
  21.       this.y = y;
  22.    }
  23.  
  24.    // get x coordinate
  25.    public int getX()
  26.    {
  27.       return x;
  28.    }
  29.  
  30.    // get y coordinate
  31.    public int getY()
  32.    {
  33.       return y;
  34.    }
  35.  
  36.    public String getName()
  37.    {
  38.       return "Shape";
  39.    }
  40.  
  41.    public String toString()
  42.    {
  43.       return "Shape";
  44.    }
  45. }  // end class Shape