Use the following Java programs as an example of a Java class and client code that uses it: MimicOct.java and UnderTheSea.java.
All of you have been working with classes in Java. One of the most important things to know about classes is that they are actually blueprints for objects. They basically contain all of the information as to how objects are built.
One of the most important features of objects is the fact that they have state and behavior. The way that they hold state is through instance variables. Instance variables are simply variables that "describe" the object and its state. There are several ways to handle the accessibility of an instance variable within an object, but in this lab we are going to work only with public instance variables. Public means that any class within the project that you're working in has permission to access and modify the instance variables. To access or modify an instance variable that is public, such as populationNumber, in an object called species, simply type species.populationNumber = someInteger.
Create a Species constructor that takes in a String for its name, an int for its population, and an int for its growth rate. Don't let someone initialize a species with a population above 1500 or below 1, or a growth rate outside of the range of 1 to 20 percent. If the population is initialized below 1, set it to 1, and if above 1500, set it to 1500. Similarly for the growth rate.
Return an appropriate String in the toString method that describes the state of a Species object.
Example String to return in the toString() method:
System.out.println(s);
which is a shortcut for
System.out.println(s.toString());
Create two species objects of whatever animal that you wish (do this in CircleOfLife.java).
Completion within lab time: 3 points or
Completion within 1 week: 2 points