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 and Brad Richards
    • Constructor Detail

      • Circle

        public Circle​(Circle otherCircle)
        This is a copy constructor. It takes a reference to another circle, and sets "us" up to have the same state that they do. We can peek at their fields even though they're private because they're instances of the same class that we are.
      • Circle

        public Circle()
        Create a new circle at default position with default color.
    • Method Detail

      • getXPosition

        public int getXPosition()
        A "getter" method that returns the circle's xPosition.
      • getYPosition

        public int getYPosition()
        A "getter" method that returns the circle's xPosition.
      • 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.
      • 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".