Question: Create a class called Creature. (Java) Your Creature class should have the following instance variables: Number of Teeth Color (such as red, green, etc) Texture
Create a class called Creature. (Java) Your Creature class should have the following instance variables: Number of Teeth Color (such as "red", "green", etc) Texture ("scaly", "spiky", "slimy", etc) hasWings (This can be TRUE or FALSE) isCarnivorous (This can be TRUE or FALSE) Height (in inches) Specimen Name Your Creature class should have appropriate getters and setters for each of the above instance variables. All instance variables should be private. Your Creature class should have three constructors: A default constructor, which takes no parameters and which sets default values of your choosing for each instance variable. A constructor with parameters for name, color, and texture. This constructor should set these values appropriately and initializes the rest to the default values you chose prior. A constructor which takes in all of the properties as parameters and sets the instance variables appropriately for each. In addition to including all getters and setters, your class should have the following methods: A toString method which appropriately overrides to display relevant information about the calling Creature instance. All instance variable values should be displayed in the toString return as a coherent sentence. Hint: For the variables which are TRUE and FALSE : how might we be able to make a conditional decision to print relevant information that reflects the value in the toString, rather than JUST printing the value true or false. Building the method below may help you think about this, and see the examples at the bottom for a toString that does not print, but does utilize these values in the human readable printout. An "eat" method which takes no parameters and does not return anything, but checks the relevant instance variable to see if the creature is carnivorous. If it is carnivorous, the method should print "NAME chews on some meat", with NAME being the appropriate instance variable. If it is not, the method should print "NAME nibbles on some leaves". A "smile" method which takes no parameters and does not return anything, but prints "NAME smiles with all NUMBER of its teeth", with NAME and NUMBER being the relevant instance variables. A CUSTOM method of your choosing that any of your creatures can do. Your method does not need to be long, but should do something distinct, demonstrate an understanding with the design of the method that you are defining an action each creature will be able to do, and use relevant parameters and return types. Be sure to comment all methods appropriately, and to use only non-static methods!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
