Absolute Java (6th Edition)
Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 4, Problem 12PP

This programming project extends Programming Project 4.11. Create a PizzaOrder class that allows up to three pizzas to be saved in an order. Each pizza saved should be a Pizza object as described in Programming Project 4.11. In addition to appropriate instance variables and constructors, add the following methods:

public void setNumPizzas  int numPizzas —sets the number of pizzas in the order. numPizzas must be between 1 and 3.

public void setPizza1 (Pizza pizza1) —sets the number of pizzas in the order.

public void setPizza2 (Pizza pizza2) —sets the second pizza in the order.

public void setPizza3 (Pizza pizza3) —sets the third pizza in the order.

public double calcTotal() —returns the total cost of the order.

Write a main method to test the class. The setPizza2 and setPizza3 methods will be used only if there are two or three pizzas in the order, respectively. Sample code illustrating the methods is shown below. Note that first three lines are incomplete. You must complete them as part of the Programming Project.

Pizza pizza1 = / /  Code to create a large pizza, 1 cheese, 1 ham Pizza pizza2 = / /  Code to create a medium pizza, 2 cheese, 2 pepperoni PizzaOrder order = / /  Code to create an order order .setNumPizzas(2);  / / 2  pizzas in the order order .setPizzal(pizza1);  / /  Set first pizza order .setPizza2(pizza2);  / /  Set second pizza double total = order .calcTotal(); // Should be  18 + 20 = 38

Blurred answer
Students have asked these similar questions
IN C++ Implement a class Car with the following properties. A car has a certain fuel efficiency (measured in miles/gallon or liters/km—pick one) and a certain amount of fuel in the gas tank. The efficiency is specified in the constructor, and the initial fuel level is 0. Provide another parameterized constructor which takes both efficiency and fuel as parameters. Also supply methods getGasInTank, returning the current amount of gasoline in the fuel tank. getEfficiency()  return the efficiency of car. setGasInTank(double fuel), to add gasoline to the fuel tank. setEfficiency(double efficiency) Supply a method Drive () that simulates driving the car for a certain distance, reducing the amount of gasoline in the fuel tank according to its efficiency. Sample usage: Car myHybrid (50); // 50 miles per gallon myHybrid.addGas(20); // Tank 20 gallons myHybrid.Drive(100); // Drive 100 miles double gasLeft = myHybrid.getGasInTank(); // Get gas remaining in tank Supply a main method that tests…
Write a class Point with instance variables as: xCoordinate(int) and yCoordinate(int). Write public instance methods (getters & setters) for each instance variable. Now, write a class Circle with private instance variables as radius and Pi (value is 3.14). Write public setter, getter for radius, Area method for calculating Area, Draw method for radius.  Formula for calculating area=pi*r^2  Formula for calculating radius= Math.sqrt (xCordinate^2+yCordinate^2) a. Extend a Circle class from Point class such as Class Circle extends Pointb. Write a Default constructor in Circle class that sets radius, xCoordinate & yCoordinate to some default value e.g. -1;c. Write a Parameterized constructor in Circle class which takes xCoordinate, yCoordinate and radius as a parameter.Now write a ColoredCirlce class with private instance variable as color (String) and public setter & getters. Extend the ColoredCircle from Circle and do the following operations.d. Write a default constructor…
Write a class Point with instance variables as: xCoordinate(int) and yCoordinate(int). Write public instance methods (getters & setters) for each instance variable. Now, write a class Circle with private instance variables as radius and Pi (value is 3.14). Write public setter, getter for radius, Area method for calculating Area, Draw method for radius. Formula for calculating area=pi*r^2 Formula for calculating radius= sqrt (xCordinate^2+yCordinate^2)   Extend a Circle class from Point class such as Class Circle extends Point Write a Default constructor in Circle class that sets radius, xCoordinate & yCoordinate to some default value e.g. -1; Write a Parameterized constructor in Circle class which takes xCoordinate, yCoordinate and radius as a parameter. E.g.                              Circle (int xCoordinate, int yCoordinate, double radius) {                              this.xCoordinate= xCoordinate;                              this.yCoordinate= yCoordinate;…

Chapter 4 Solutions

Absolute Java (6th Edition)

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
6 Stages of UI Design; Author: DesignerUp;https://www.youtube.com/watch?v=_6Tl2_eM0DE;License: Standard Youtube License