Class Circle


public class Circle extends Object
A circle that can be manipulated and that draws itself on a canvas.
Version:
2016.02.29
Author:
Michael Kölling and David J. Barnes
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new circle at default position with default color.
    Circle(int initialSize)
    Here's a constructor that takes a parameter, and uses that value to set up the initial size.
    Circle(int x, int y)
    Here's a constructor that takes initial x and y positions.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    changeColor(String newColor)
    Change the color.
    void
    changeSize(int newDiameter)
    Change the size to the new size (in pixels).
    void
    Make this circle invisible.
    void
    Make this circle visible.
    void
    Move the circle a few pixels down.
    void
    Moves the circle farther to the right than normal.
    void
    moveHorizontal(int distance)
    Move the circle horizontally by 'distance' pixels.
    void
    Move the circle a few pixels to the left.
    void
    Move the circle a few pixels to the right.
    void
    Move the circle a few pixels up.
    void
    moveVertical(int distance)
    Move the circle vertically by 'distance' pixels.
    void
    slowMoveHorizontal(int distance)
    Slowly move the circle horizontally by 'distance' pixels.
    void
    slowMoveVertical(int distance)
    Slowly move the circle vertically by 'distance' pixels.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Circle

      public Circle()
      Create a new circle at default position with default color. This is a constructor. It should give values to every field in the class.
    • Circle

      public Circle(int initialSize)
      Here's a constructor that takes a parameter, and uses that value to set up the initial size.
    • Circle

      public Circle(int x, int y)
      Here's a constructor that takes initial x and y positions.
  • Method Details

    • makeVisible

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

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

      public void moveRight()
      Move the circle a few pixels to the right.
    • moveFartherRight

      public void moveFartherRight()
      Moves the circle farther to the right than normal.
    • moveLeft

      public void moveLeft()
      Move the circle a few pixels to the left.
    • moveUp

      public void moveUp()
      Move the circle a few pixels up.
    • moveDown

      public void moveDown()
      Move the circle a few pixels down.
    • moveHorizontal

      public void moveHorizontal(int distance)
      Move the circle horizontally by 'distance' pixels.
    • moveVertical

      public void moveVertical(int distance)
      Move the circle vertically by 'distance' pixels.
    • slowMoveHorizontal

      public void slowMoveHorizontal(int distance)
      Slowly move the circle horizontally by 'distance' pixels.
    • slowMoveVertical

      public void slowMoveVertical(int distance)
      Slowly move the circle vertically by 'distance' pixels.
    • changeSize

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

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