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
  • 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...

  • 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...

  • ----------------------------------- public class Customer { String firstName,lastName; //constructor public Customer(String firstName,String lastName) { this.firstName=firstName; this.lastName=lastName; }...

    ----------------------------------- public class Customer { String firstName,lastName; //constructor public Customer(String firstName,String lastName) { this.firstName=firstName; this.lastName=lastName; } //override toString() method public String toString() { return this.lastName+", "+this.firstName; } boolean equals(Customer obj) { if(this.firstName.equals(obj.firstName) && this.lastName.equals(obj.lastName)) return true; else return false; } } ----------------------------------- public class Ingredient { String ingredientName; int amount; double price; public Ingredient(String ingredientName,int amount,double price) { this.ingredientName=ingredientName; this.amount=amount; this.price=price; } double getCost() { return amount/1000.0*price; } public String toString() { return this.ingredientName+", "+this.amount+" mls, $"+this.price+"/L"; } } -----------------------------------...

  • You are going to model a Book in a library. The Book class should contain a...

    You are going to model a Book in a library. The Book class should contain a title and an author (exactly 1 author is OK). Also, a book can be checked out and returned by a student. A Book object should be able to identify the student who currently holds the book. 1.Design the public interface (public constructor and public methods) for a class Book. You can use String to represent title, author, and student. 2. Implement the class Book...

  • Python only please, thanks in advance. Type up the GeometricObject class (code given on the back...

    Python only please, thanks in advance. Type up the GeometricObject class (code given on the back of the paper). Name this file GeometricObjectClass and store it in the folder you made (xxlab14) 1. Design a class named Rectangle as a subclass of the GeometricObject class. Name the file RectangleClass and place it in the folder. 2. The Rectangle class contains Two float data fields named length and width A constructor that creates a rectangle with the specified fields with default...

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
ADVERTISEMENT