Unit 5 Chapter 14 Assignment | Solution
- AceTutor
- Rating : 33
- Grade : A+
- Questions : 0
- Solutions : 823
- Blog : 1
- Earned : $26606.70
Unit 5 Chapter 14 Assignment
Grading Information: This Program is due on Date Specified.
Comments are REQUIRED; flow charts and pseudocode are NOT REQUIRED.
Directions Points
The files must be called <LiFiUnit5Ch14.java> (driver program)
LiFiPizza.java
LiFiMeat.java (which extends LiFiPizza)
LiFiCheese.java (which extends LiFiPizza)
The files must be called as specified above, (LiFi = Your Last Initial Your First Initial)
Proper coding conventions required the first letter of the class start with a capital
letter and the first letter of each additional word start with a capital letter.
Only submit the .java files needed to make the program run. Do not submit the
.class files or any other files.
5%
Style Components
Include properly formatted prologue, comments, indenting, and other style elements
as shown in Chapter 2 starting page 64 and Appendix 5 page 881-892.
5%
Topics covered in chapter
Topics with * are covered in this assignment. Ensure you use every item listed below in your
completed assignment.
Object class
equals method
*toString method
*Inheritance
*Polymorphism
*Abstract
Interfaces
Protected access modifier
Basic Requirements
Write a super basic Pizza ordering system using Polymorphism.
LiFiUnit5Ch14 (driver)
• Get input for Cheese or Meat pizza.
18%
• Declare a single pizza of LiFiPizza type to be used for both Cheese and Meat
• If a Meat pizza is selected
o instantiate your pizza as a LiFiMeat pizza with zero arguments
o call setCrust() of LiFiMeat
o call setIngredient of LiFiMeat
• If a Cheese pizza is selected,
o Instantiate your pizza as a LiFiCheese pizza with zero arguments.
• Print your order by printing the pizza object (should call the corresponding
toString() method implicitly)
LiFiPizza.java
• abstract class
• private instance data members: type (String), crust(String), and cost (double)
• Default constructor: set cost to initial value $5
• Accessor (getXXX) and mutator (setXXX) methods for each instance data
member
26%
LiFiCheese.java (extends LiFiPizza)
• Default constructor: call appropriate mutator methods of parent class to set
type to “Cheese” and set crust to “Thin”
• Override toString() to return a String representing the state of the Cheese
pizza object. See the sample for the format of the data
16%
LiFiMeat.java (extends LiFiPizza)
• private instance data member: ingredient (String)
• Default constructor: call appropriate mutator method of parent class to set type
to “Meat”
• setCrust(): this method is an overloaded version of the setCrust(String) of
parent class. Allow selection of Thin or Thick crust and call setCrust(String) of
parent class to set instance data member crust (see Sample)
• setIngredient():
o prompt for and input one ingredient (can be any ingredient, but just
one. see Sample)
o add $2 to the initial cost
• Override toString() to return a String representing the state of the calling Meat
pizza object. See the sample for the format of the data
30%
NOTE: Complete your activity and submit it by clicking “Submit Assignment”
Total Percentage 100%
Sample
Your output will vary based on Input.
[Solved] Unit 5 Chapter 14 Assignment | Solution
- This Solution has been Purchased 1 time
- Submitted On 10 Jul, 2016 05:34:47
- AceTutor
- Rating : 33
- Grade : A+
- Questions : 0
- Solutions : 823
- Blog : 1
- Earned : $26606.70