1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
masha68 [24]
3 years ago
14

2. Design a class named Sandwich with data fields for description and price. Include a constructor that requires arguments for b

oth fields and a method to display the data (example value for description is chicken). Create a subclass named Delivery Sandwich 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).
Computers and Technology
1 answer:
marta [7]3 years ago
5 0

Answer:

The answer files have been attached below, with the description of the files in the explanation.

Explanation:

The Sandwich class contains two functions

1) Sandwich() : A constructor that takes two arguments, the Description of sandwich and its price.

2) display_Data(): A function that does not take any arguments, and does not return anything. It prints the states (data of the variables Description, Price )

The Delivery Sandwich has three functions:

1) DeliverySandwich(): A constructor that takes in three arguments, Description of sandwich, Its price, and the delivery address.

super key word is used to access the parent class. super() is a method of calling the parent class's constructor. Description and price are passed to parent class's constructor, where as DeliveryAddress is initialized in the DeliverySandwich constructor.

It is then checked whether the price is greater than 15. If it is, the deliveryfee is set to 3, otherwise it is set to 5.

2) display_Data()

This is an overridden function. An overridden function in java is a function that has the same name as another function in its parent's class, but has different functionality.

The function first calls the display_Data() of the parent class using super.display_Data() to display the price and description of sandwich, then prints the address and delivery price of the sandwich

3) main()

Driver code that has objects of both sandwiches. Once an object is created, the display data function is called of each class to see the states of the variables in them.

Download java
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> java </span>
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> java </span>
You might be interested in
What stylistic device does Reverend Jesse Jackson use in the following statement: "We must relate instead of debate; we must ins
vivado [14]

Answer:

Parallelism

Explanation:

Parallelism:- It is a linguistic device.It is basically the use of components that are similar in their meaning ,sound or construction.So in the statement by Reverend Jesse Jackson .The statement uses words that sound similar and the statements have similar construction.

So we conclude that the answer is parallelism.

8 0
3 years ago
Fordham3 Hardware is known for its consensus buying center culture. Recognizing this corporate culture, someone attempting to se
balandron [24]

Answer: (c) focus exclusively on the head of the buying center.

Explanation:

As Fordham3 Hardware is known for its consensus buying center culture, so someone attempting to sell to Fordham3 should focus exclusively on the head of the buying center.

8 0
3 years ago
Implement the function first chars() that takes a list of strings as a parameter and prints to the screen the first character of
Fiesta28 [93]
Def firstChars( word ):
   if( word ): # make sure word has characters
       print( word[ 0 ] ) # print the first character (Python 3 syntax)
3 0
3 years ago
EASY AND I GIVE BRAINLIEST!!! What is a good jeopardy question about operating systems?
madam [21]

 ______ is used in operating system to separate mechanism from policy
<span><span>A. Single level implementation</span><span>B. Two level implementation</span><span>C. Multi level implementation</span><span>D. None</span></span>
3 0
3 years ago
The set of rules for how computers talk to one another
andrezito [222]
That is program ............
4 0
3 years ago
Other questions:
  • We have to calculate the percentage of marks obtained in three subjects (each out of 100) by student A and in four subjects (eac
    11·1 answer
  • The checksum doesn't compute for a packet sent at the Internet Protocol (IP) level. What will happen to the data?
    14·1 answer
  • A network technician has configured a point-to-point interface on a router. Once the fiber optic cables have been run, though, t
    12·1 answer
  • The memory allocated for a float value is ____ bytes.
    9·1 answer
  • You use different office apps to accomplish specific tasks, such a creating a newsletter or producing a sales presentation, yet
    8·1 answer
  • What are the basic tools for coding HTML manually?
    10·2 answers
  • Write a class named Episode. An instance of this episode class will represent a single episode of a TV show, with a title, a sea
    12·1 answer
  • Need answer ASAP!!!!
    14·1 answer
  • When solving a problem in a group situation, which of the following traits should be demonstrated?
    8·1 answer
  • ANSWER QUICKLY!!!
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!