Question: You will need to create the following class files in the Questions package based on the instructions below or in the associated API documentation: Dog
You will need to create the following class files in the Questions package based on the instructions below or in the associated API documentation:
Dog
Cat
>
>
BaseballPlayer
Conversion
Write unit tests for the LiopleurodonTest.java class file in the Questions package in the Test Packages folder based on the instructions contained below.
Instructions for Dog class:
This class is modeled after a Dog. You should have instance variables as follows:
The Dogs name
The number of tricks known by the Dog.
The color* of the Dogs coat (fur).
*: For the Dogs fur color you should use the Color class from the java.awt package.
You should choose proper types and meaningful identifiers for each of these instance variables.
Your class should contain two constructor methods. A default constructor and a constructor that allows you to instantiate an object of the Dog class and choose initial values for each of the three instance variables.
Your class should also contain accessor methods for all three instance variables. However, you should only have a mutator method to change the number of tricks known by the Dog (it would be mean to change its name or the color of its fur).
You will also need to override the toString method to work properly for the class. It should return a String containing the dogs name, the number of tricks it can perform, and its coat color.
Instructions for Cat class:
This class is modeled after a Cat. You should have instance variables as follows:
The Cats name
The number of mice caught by the Cat.
Whether or not the Cat is secretly plotting to kill you
Note that you will need to choose both good types and meaningful identifiers for each of these instance variables. You may also assume that the Cat is not automatically always secretly plotting to kill you. Sometimes the plot is out in the open.
Your class should contain two constructor methods. A default constructor and a constructor that allows you to instantiate an object of the Cat class and choose initial values for each of the three instance variables.
Your class should also contain accessor and mutator methods for all three instance variables (Cats really dont care what you call them, they wont listen regardless, and it is potentially possible that it will stop plotting to kill you, although this is both unlikely and only temporary).
You will also need to override the toString method to work properly for the class. It should return a String containing the Cats name, the number of mice caught by the Cat, and whether or not the Cat is secretly plotting to kill you.
Instructions for > and > classes:
Create two java classes of your own (use names descriptive of what the class represents, don't call them MyClass1 and MyClass2) to model some objects in the real world or your own imagination. Each of your classes should have at least three instances variables, accessor and mutator methods for each of those instance variables, one constructor method of any type, as well as an overridden toString method that will display every field value as part of a String.
Demonstrate that your classes work appropriately by creating instances of each in the MainClass class which contains a main method.
Instructions for Conversion class:
The Conversion class will contain methods designed to perform simple conversions. Specifically, you will be writing methods to convert temperature between Fahrenheit and Celsius and length between meters and inches and practicing overloading methods.
See the API document for the Conversion class for a list of the methods you will write.
Also, because all of the methods of the Conversion class will be static, you should ensure that it is not possible to create any instances of the class. You can do this by declaring a default constructor method using the private access modifier.
Instructions for BaseballPlayer class:
The BaseballPlayer class is modeled after a BaseballPlayer and will contain methods to calculate various statistics based on the stats of a player.
For this class, you will want to use a static variable for storing a DecimalFormat object.
See the API document for the BaseballPlayer class for a list of methods you will write.
Instructions for LiopleurodonTest Unit Test class:
For this portion of the assignment you will need to write unit tests that will allow you to test three different methods of the Liopleurodon class to determine if they are functioning correctly. An example unit test for the setIsMagical method is already supplied and may be used as a reference for creating any additional unit test methods.
You will want to create three additional unit tests that are used to test the functionality of the setName, setOccupation, and setLocation methods of the Liopleurodon class. Each of these methods takes a single argument of type String and modifies the instance variable based on the name of the method.
Once you have completed the unit tests, you should run them to determine if the methods that they are testing work correctly, and if not, fix any errors in the Liopleurodon class.



BaseballPlayer Class API Constructors: + \begin{tabular}{|l|l|} \hline Identifier: & BaseballPlayer(Stringname,intnumber,intsingles,intdoubles,inttriples,inthomeRuns,intatBats,intwalks,intsacrificeFlies) \\ \hline Parameters: & name-AStringrepresentingtheplayersnamenumber-Anintrepresentingtheplayersnumbersingles-Anintrepresentingthenumberofsinglestheplayerhashitdoubles-Anintrepresentingthenumberofdoublestheplayerhashittriples-AnintrepresentingthenumberoftriplestheplayerhashithomeRuns-AnintrepresentingthenumberofhomeRunstheplayerhashitatBats-Anintrepresentingthenumberoftimestheplayerhasbeenatbatwalks-AnintrepresentingthenumberoftimestheplayerhaswalkedsacrificeFlies-Anintrepresentingthenumberofsacrificeflyoutsmade \\ \hline Return Value: & \\ \hline Other: & \\ \hline \end{tabular} Methods: \begin{tabular}{|l|l|} \hline Identifier: & getBattingAverage \\ \hline Parameters: & \\ \hline Return Value: & double - the batting average of a player. \\ \hline Other: & ReturnthebattingaverageforaBaseballPlayerwhichiscalculatedasthenumberofhitsdividedbythenumberofatbats. \\ \hline \end{tabular} \begin{tabular}{|l|l|} \hline Identifier: & getSluggingPercentage \\ \hline Parameters: & \\ \hline Return Value: & double - the slugging percentage of a player. \\ \hline Other: & ReturnthesluggingpercentageforaBaseballPlayerwhichiscalculatedwiththefollowingformula:((1#ofsingles)+(2#ofdoubles)+(3#oftriples)+(4#ofhomeruns))/#ofatbats \\ \hline \end{tabular} \begin{tabular}{|l|l|} \hline Identifier: & getOnBasePercentage \\ \hline Parameters: & \\ \hline Return Value: & double the on base percentage of a player. \\ \hline Other: & Returntheon-basepercentageforaBaseballPlayerwhichiscalculatedwiththefollowingformula:(#ofhits+#ofwalks)/#ofatbats+#ofwalks+#ofsacrificeflies) \\ \hline \end{tabular} BaseballPlayer Class API Conversion Class API
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
