Class Square

java.lang.Object
  extended by Square

public class Square
extends java.lang.Object

A square that can be manipulated and that draws itself on a canvas.

Version:
1.0 (15 July 2000)
Author:
Michael Kolling and David J. Barnes

Constructor Summary
Square()
          Create a new square at default position with default color.
Square(int originalX, int originalY)
          Create a new square at specified position (originalX,originalY) with default color.
 
Method Summary
 void changeColor(java.lang.String newColor)
          Change the color.
 void changeSize(int newSize)
          Change the size to the new size (in pixels).
 void makeInvisible()
          Make this square invisible.
 void makeVisible()
          Make this square visible.
 void moveDown()
          Move the square a few pixels down.
 void moveHorizontal(int distance)
          Move the square horizontally by 'distance' pixels.
 void moveLeft()
          Move the square a few pixels to the left.
 void moveRight()
          Move the square a few pixels to the right.
 void moveUp()
          Move the square a few pixels up.
 void moveVertical(int distance)
          Move the square vertically by 'distance' pixels.
 void slowMoveHorizontal(int distance)
          Slowly move the square horizontally by 'distance' pixels.
 void slowMoveVertical(int distance)
          Slowly move the square vertically by 'distance' pixels.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Square

public Square()
Create a new square at default position with default color.


Square

public Square(int originalX,
              int originalY)
Create a new square at specified position (originalX,originalY) with default color.

Method Detail

changeColor

public void changeColor(java.lang.String newColor)
Change the color. Valid colors are "red", "yellow", "blue", "green", "magenta" and "black".


changeSize

public void changeSize(int newSize)
Change the size to the new size (in pixels). Size must be >= 0.


makeInvisible

public void makeInvisible()
Make this square invisible. If it was already invisible, do nothing.


makeVisible

public void makeVisible()
Make this square visible. If it was already visible, do nothing.


moveDown

public void moveDown()
Move the square a few pixels down.


moveHorizontal

public void moveHorizontal(int distance)
Move the square horizontally by 'distance' pixels.


moveLeft

public void moveLeft()
Move the square a few pixels to the left.


moveRight

public void moveRight()
Move the square a few pixels to the right.


moveUp

public void moveUp()
Move the square a few pixels up.


moveVertical

public void moveVertical(int distance)
Move the square vertically by 'distance' pixels.


slowMoveHorizontal

public void slowMoveHorizontal(int distance)
Slowly move the square horizontally by 'distance' pixels.


slowMoveVertical

public void slowMoveVertical(int distance)
Slowly move the square vertically by 'distance' pixels.