java-Design a class named Sandwich with data fields for description and price. Include a constructor that requires arguments for both fields and a method to display the data (example value for description is chicken). Create a subclass named DeliverySandwich that inherits from Sandwich and has a delivery fee and a delivery address as additional fields. The description, price, and delivery address are required as arguments to the subclass constructor. The delivery fee should be set to $3 if the sandwich ordered costs more than $15; otherwise it should be set to $5. Write an application that instantiates at least two objects of each type and displays their state (data).

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

java-Design a class named Sandwich with data fields for description and price. Include a constructor that requires arguments for both fields and a method to display the data (example value for description is chicken). Create a subclass named DeliverySandwich that inherits from Sandwich and has a delivery fee and a delivery address as additional fields. The description, price, and delivery address are required as arguments to the subclass constructor. The delivery fee should be set to $3 if the sandwich ordered costs more than $15; otherwise it should be set to $5. Write an application that instantiates at least two objects of each type and displays their state (data).

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Reference Types in Function
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT