Question

In: Computer Science

Inheritance - What is inheritance - Answer your own description in Readme.txt Based on Hamburger project,...

Inheritance - What is inheritance - Answer your own description in Readme.txt

Based on Hamburger project, you will create a package about Pizza.

In your Readme.txt, write how you make your Pizza package differently from the Hamburger package and also explain how inheritance work with your Pizza package.

package Hamburger;

/**
* Inheritance challenge – Hamburger place (Main, Hamburger, two other Burger type class)
* Hamburger class should have name, bread roll type, meat, and up to 4 additional
* additions(e.g. lettuce, tomato, carrot, etc)
* to select to be added to the burger. Each item will be charged an additional
*/
public class Hamburger {
private String name;
//meat, price, breadRollType
private String meat;
private double price;
private String breadRollType;

private String additionName1;
private double additionPrice1;

private String additionName2;
private double additionPrice2;

private String additionName3;
private double additionPrice3;

private String additionName4;
private double additionPrice4;

public Hamburger(String name, String meat, double price, String breadRollType) {
this.name = name;
this.meat = meat;
this.price = price;
this.breadRollType = breadRollType;
}

public void addHamburgerAddition1(String name, double price){
this.additionName1 = name;
this.additionPrice1 = price;
}

public void addHamburgerAddition2(String name, double price){
this.additionName2 = name;
this.additionPrice2 = price;
}

public void addHamburgerAddition3(String name, double price){
this.additionName3 = name;
this.additionPrice3 = price;
}

public void addHamburgerAddition4(String name, double price){
this.additionName4 = name;
this.additionPrice4 = price;
}


public double hamberPriceTotal(){

double hamburgerPrice = this.price;

System.out.println(this.name + " hambuger on a " + this.breadRollType + " roll with " + this.meat + "'s price is " + this.price);

if(this.additionName1 != null){
hamburgerPrice += this.additionPrice1;
System.out.println("Added " + this.additionName1 + " for an extra " + this.additionPrice1);
}

if(this.additionName2 != null){
hamburgerPrice += this.additionPrice2;
System.out.println("Added " + this.additionName2 + " for an extra " + this.additionPrice2);
}

if(this.additionName3 != null){
hamburgerPrice += this.additionPrice1;
System.out.println("Added " + this.additionName3 + " for an extra " + this.additionPrice3);
}

if(this.additionName4 != null){
hamburgerPrice += this.additionPrice4;
System.out.println("Added " + this.additionName4 + " for an extra " + this.additionPrice4);
}

return hamburgerPrice;

}

}

Solutions

Expert Solution

class Person(object):

def __init__(self, first_name, last_name, age, gender):

self.first_name = first_name

self.last_name = last_name

self.age = age

self.gender = gender

def print_full_name(self):

msg = '{first_name} {last_name}'.format( first_name=self.first_name, last_name=self.last_name)

print(msg)

class Teacher(Person):

def __init__(self, first_name, last_name, age, gender, subject):

super().__init__(first_name, last_name, age, gender)

self.subject = subject

def print_subject(self):

msg = "Subject: {subject}".format(subject=self.subject) print(msg)

class Student(Person):

def __init__(self, first_name, last_name, age, gender, std_class):

super().__init__(first_name, last_name, age, gender)

self.std_class = std_class

def print_class_name(self):

msg = 'Class name: {name}'.format(name=self.std_class)

print(msg) p = Person('Shera', 'Md', 20, 'Male')

p.print_full_name() t = Teacher('Gilchrist', 'Adam', 20, 'Male', 'Maths')

t.print_full_name() t.print_subject() s = Student('Priya', 'Ch', 20, 'Female', '3rd Class')

s.print_full_name()

s.print_class_name()


Related Solutions

Inheritance - What is inheritance - Answer your own description in Readme.txt Based on Hamburger project,...
Inheritance - What is inheritance - Answer your own description in Readme.txt Based on Hamburger project, you will create a package about Pizza. In your Readme.txt, write how you make your Pizza package differently from the Hamburger package and also explain how inheritance work with your Pizza package. package Hamburger; /** * Inheritance challenge – Hamburger place (Main, Hamburger, two other Burger type class) * Hamburger class should have name, bread roll type, meat, and up to 4 additional *...
Inheritance - What is inheritance - Answer your own description in Readme.txt Based on Hamburger project,...
Inheritance - What is inheritance - Answer your own description in Readme.txt Based on Hamburger project, you will create a package about Pizza. In your Readme.txt, write how you make your Pizza package differently from the Hamburger package and also explain how inheritance work with your Pizza package. package Hamburger; /** * Inheritance challenge – Hamburger place (Main, Hamburger, two other Burger type class) * Hamburger class should have name, bread roll type, meat, and up to 4 additional *...
You own and operate a hamburger. Each year, you receive revenue of $400,000 from your hamburger...
You own and operate a hamburger. Each year, you receive revenue of $400,000 from your hamburger and associated food sales, and it costs you $200,000 for the food. In addition, you pay $80,000 for electricity, taxes, and other expenses per year. Instead of running the hamburger, you could become a management consultant and receive a yearly salary of $100,000. A large clothing retail chain wants to expand and offers to rent the store from you for $40,000 per year. How...
Assignment One: Description of Your Individual Entrepreneurial Project Please describe your own individual project which may...
Assignment One: Description of Your Individual Entrepreneurial Project Please describe your own individual project which may be unique or you had been thinking about since it has invented or innovative ideas. Need to include description of the product, service, or idea you intend to do. The competitive advantage of your output and what make you think it is sustainable? The estimated cost of your project and some financial expectations. You may include any other details that you think it is...
Based on your approved project proposal develop the following sections: Organizational Description - this section will...
Based on your approved project proposal develop the following sections: Organizational Description - this section will provide an overview of the organization. This overview will include a summary of: 1- Potential population characteristics (i.e., majority aboriginal populations, etc.). 2- Potential challenges that you can identify for this organization (i.e., access to services due to geographic location, etc.) in which technology can play a significant role. 3- Description of the technological need(s) that this organization is required to address. 4- Proposal...
1. Read each question. 2. Answer based upon your knowledge of the chapter and your own...
1. Read each question. 2. Answer based upon your knowledge of the chapter and your own experience. 3. Indicate by number (1 or 2) which question you are answering first. 4. Proofread your answer--demonstrate your best writing ability. CHAPTER 12 Effective Business Presentations 1. What role do visuals play in business presentations? 2. The four Ps: Planning, preparing, practicing, and presenting, are very important to presentations. Explain how you understand each of them. Is one more important than the others?
Based on the five case studies, answer the questions in your own words for each case...
Based on the five case studies, answer the questions in your own words for each case study, using complete sentences, and providing examples, if applicable. Case Study 1 During an appendectomy, the patient, a 16-year-old male, exhibits decreased oxygen saturation, hypotension, decreased breath sounds, and increased airway pressures during ventilation. What is most likely happening with this patient? What should you do as a surgical tech in the scrubbed role? What will the anesthesia provider most likely do? Case Study...
What is the definition of Project Management? Using your own example, discuss project scheduling with the...
What is the definition of Project Management? Using your own example, discuss project scheduling with the critical path method (CPM).
do mendelian principles of inheritance apply to humans? Explain your answer
do mendelian principles of inheritance apply to humans? Explain your answer
Which is the BEST description of project scope? All of the features and deliverables your project...
Which is the BEST description of project scope? All of the features and deliverables your project will deliver All of the products your project will make All of the people involved in your project All of the work you will do to build the product
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT