Question
Chapter 10 Exercise 7 Pizza.java, DeliveryPizza.java and DemoPizzas.java Make a class named Pizza with the following data fields: description - of type String price -
Chapter 10 Exercise 7 Pizza.java, DeliveryPizza.java and DemoPizzas.java
Make a class named Pizza with the following data fields:
description - of type String
price - of type double
The description stores the type of pizza (such as sausage and onion). Include a constructor that requires arguments for both fields and a method named display to display the data. For example, if the description is 'sausage and onion' and the price is '14.99', the display method should output:
sausage and onion pizza Price: $14.99
make a subclass named DeliveryPizza that inherits from Pizza but adds the following data fields:
deliveryFee - of type double
address - of type String
The description, price, and delivery address are required as arguments to the constructor. The delivery fee is $3 if the pizza ordered costs more than $15; otherwise it is $5.
public class DeliveryPizza
{
// Define DeliveryPizza class here
}
public class DemoPizzas
{
public static void main(String args[])
{
// Write demo program here
}
}
public class Pizza
{
// Define the Pizza class here
}
Question 2
Chapter 11 Complete Exercise 4 Division.java, InternationalDivision.java, DomesticDivision.java and UseDivision.java
make an abstract Division class with fields for a company's division name and account number, and an abstract display() method. Use a constructor in the superclass that requires values for both fields. Create two subclasses named InternationalDivision and DomesticDivision. The InternationalDivision includes a field for the country in which the division is located and a field for the language spoken; its constructor requires both. The DomesticDivision includes a field for the state in which the division is located; a value for this field is required by the constructor.
public abstract class Division
{
protected String divisionTitle;
protected int acctNum;
public Division(String title, int acct)
{
//put code here
}
public abstract void display();
}
public class DomesticDivision extends Division
{
protected String state;
public DomesticDivision(String title, int acct, String st)
{
// put code here
}
public void display()
{
// put code here
}
}
public class InternationalDivision extends Division
{
protected String country;
protected String language;
public InternationalDivision(String title, int acct, String cty, String lang)
{
// put code here
}
public void display()
{
// put code here
}
}
public abstract class UseDivision
{
public static void main(String[] args)
{
DomesticDivision abcDomDiv = new
DomesticDivision("Sales", 123, "California");
DomesticDivision xyzDomDiv = new
DomesticDivision("Technology", 234, "Kansas");
InternationalDivision abcIntDiv = new
InternationalDivision("Technology", 345, "Germany", "German");
InternationalDivision xyzIntDiv = new
InternationalDivision("Marketing", 456, "Japan",
"Japanese");
abcDomDiv.display();
xyzDomDiv.display();
abcIntDiv.display();
xyzIntDiv.display();
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started