Question

PYTHON PLEASE Implement classes for a coffeeshop. The class customer model a customer with a name...

PYTHON PLEASE Implement classes for a coffeeshop. The class customer model a customer with a name and a calorie limit. The coffeeshop would only serve a drink to the customer if the calorie limit would not be exceeded (all previous purchases from that customer are used to know whether the calorie limit would be exceeded) Also, a class Drink models a drink with a name and calorie value. And a class Caffeinated models a drink with caffeine (and it is a subclass of Drink).

thanks

0 0
Add a comment Improve this question Transcribed image text
Answer #1

# do comment if any problem arises

# Code

class Customer:

    # constructor

    def __init__(self, name, limit):

        self.name = name

        self.calorie_limit = limit

class Drink:

    # constructor

    def __init__(self, name, value):

        self.name = name

        self.calorie_value = value

# drink with caffeine

class Caffeinated(Drink):

    def __init__(self, name, value):

        super().__init__(name, value)

# testing coffeeshop

# create a cafeinated drink

pepsi=Caffeinated("pepsi",250)

# create a cuatomer

Rahul=Customer("Rahul",500)

# check if rahul can have pepsi

if Rahul.calorie_limit>=pepsi.calorie_value:

    print("Rahul can drink pepsi")

else:

    print("Rahul can not drink pepsi")

Screenshot:

Output:

Add a comment
Know the answer?
Add Answer to:
PYTHON PLEASE Implement classes for a coffeeshop. The class customer model a customer with a name...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A) Please implement a Python script to define a student class with the following attributes (instance...

    A) Please implement a Python script to define a student class with the following attributes (instance attributes): cwid: student’s CWID first_name : student’s first name last_name: student’s last name gender: student’s gender gpa: student’s gpa Please make these attributes as private ones so they have to be accessed via getter/setter methods or property. For this purpose, please define a getter/setter method and property for each of the attributes. Another thing you need to do is to define a constructor that...

  • Please use Java Question 3: Person and Customer classes: Design a class named Person with properties...

    Please use Java Question 3: Person and Customer classes: Design a class named Person with properties for holding a person's name, address, and telephone number. Next, design a class named Customer, which is derived from the Person class. The Customer class should have a property for a customer number and a Boolean property indicating whether wishes to be on a mailing list. Demonstrate an object of customer class in a simple GUI application. Write the code include appropriate input validation,...

  • 1. Design and implement classes. Design a class named Account and its two subclasses named Checking and Saving. Make Flexible and NotFlexbile subclasses of Saving. An account has a name, address, phon...

    1. Design and implement classes. Design a class named Account and its two subclasses named Checking and Saving. Make Flexible and NotFlexbile subclasses of Saving. An account has a name, address, phone number, and balance. A checking account has a overdraft limit. A saving account has an interest rate. A flexible saving account has the accumulated interest rate. A none flexible account has the expected accumulated interest rate at the maturity of the account. Override the toString method in each...

  • please use python answering the question thanks Person Implement the Person class. Each person P has...

    please use python answering the question thanks Person Implement the Person class. Each person P has attributes name, age and job. The constructor accepts arguments for the attributes above, in the order above. Each person P has a celebrate_birthday() method, which: increments P's age; sets P's job to "Retired" if their age is now 65 or greater; returns "Happy birthday <name>!", where <name> is P's name.

  • PLEASE DO BOTH OF THESE IN PYTHON 1) Exercise #1: Design and implement class Rectangle to...

    PLEASE DO BOTH OF THESE IN PYTHON 1) Exercise #1: Design and implement class Rectangle to represent a rectangle object. The class defines the following attributes (variables) and methods: Two Class variables of type double named height and width to represent the height and width of the rectangle. Set their default values to 1.0 in the default constructor. A non-argument constructor method to create a default rectangle. Another constructor method to create a rectangle with user-specified height and width. Python...

  • ONLY NEED THE DRIVER CLASS PLEASE!!! Domain & Comparator Classes: 0.) Design a hierarchy of classes,...

    ONLY NEED THE DRIVER CLASS PLEASE!!! Domain & Comparator Classes: 0.) Design a hierarchy of classes, where the Media superclass has the artistName and the mediaName as the common attributes. Create a subclass called CDMedia that has the additional arrayList of String objects containing the songs per album. Create another subclass called DVDMedia that has the additional year the movie came out, and an arrayList of co-stars for the movie. 1.) The superclass Media will implement Comparable, and will define...

  • this is java m. please use netbeans if you can. 7. Person and Customer Classes Design...

    this is java m. please use netbeans if you can. 7. Person and Customer Classes Design a class named Person with fields for holding a person's name, address, and telephone number. Write one or more constructors and the appropriate mutator and accessor methods for the class's fields. Next, design a class named Customer, which extends the Person class. The Customer class should have a field for a customer number and a boolean field indicating whether the cus- tomer wishes to...

  • By Python 3 please 2. (a) Implement a class Student. For the purpose of this exercise,...

    By Python 3 please 2. (a) Implement a class Student. For the purpose of this exercise, a student has a name and a total quiz score. Supply an appropriate constructor and methods get Name, addQuiz(score), getTotalScore(), and getAverageScore(). To compute the latter, you also need to store the number of quizzes that the student took. (b) Modify the Student class to compute grade point averages. Methods are needed to add a grade and get the current GPA. Specify grades as...

  • Please use Umlet. Draw a UML domain model class diagram using the following notes on the...

    Please use Umlet. Draw a UML domain model class diagram using the following notes on the classes, attributes and relationships discovered by the analyst so far: Your head analyst has been interviewing the department faculty about the course scheduler they would like to have developed. So far she has found a few classes. Your job is to create the UML Class diagram. Here is the information we have so far: Classes: • The Room class. All rooms have a building...

  • Java: student directory GUI You need to implement three classes: Person Student StudentDirectory StudentMain Start by...

    Java: student directory GUI You need to implement three classes: Person Student StudentDirectory StudentMain Start by implementing Person and Student classes. Once you are sure you can serialize and deserialize and ArrayList of Students to and from a file, move on to building the GUI application. Person: The Person class should implement serializable interface. It contains the following: Person's first name (String) Person's last name (String) Person's id number Person's date of birth (Date) public String toString(): This method method...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT