Lion.java - import java.awt import [email protected]@version public class Lion extends Critter cfw private Random rand private int counter private int x

Lion.java - import java.awt import [email protected]@version...

This preview shows page 1 out of 1 page.

import java.awt.*; import java.util.*; /** * @author * @version 4/16/18 */ public class Lion extends Critter { private Random rand; private int counter; private int x; /** * default constructor */ public Lion() { rand = new Random(); counter = 0; x = rand.nextInt(3); } /** * getter method for color of critter * * @return Color a certain color is returned for rand roll */ public Color getColor() { if (counter%3 == 0) { x = rand.nextInt(3); } if (x == 0) { return Color.RED; } else if (x == 1) { return Color.GREEN; } else { return Color.BLUE; } } /** * method for toString * * @return L the value is returned */ public String toString() {
Image of page 1

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture