Expected: Product ID: 2, Name: Casual Shirt, Price: $30.00, Quantity Available: 550 Size: M Got: 'Product ID: 2, Name: Casual Shirt, Price: $30.00, Quantity Available: 550\nSize: M' Failed example: plush_toy.get_product_description() Expected: Product ID: 0, Name: Toy Plushie, Price: $25.00, Quantity Available: 50 Got: 'Product ID: 0, Name: Toy Plushie, Price: $25.00, Quantity Available: 50'

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

class Product:

    def __init__(self, product_id, name, price, quantity):
        self.product_id = product_id
        self.name = name
        self.price = round(price, 2) 
        self.quantity = quantity
        
    def get_product_description(self):
        return (f"Product ID: {self.product_id}, "
                f"Name: {self.name}, "
                f"Price: ${self.price:.2f}, "
                f"Quantity Available: {self.quantity}")


class ElectronicProduct(Product):    
    def __init__(self, product_id, name, price, quantity,warranty_period):
        self.warranty_period = warranty_period
        super().__init__(product_id,name,price,quantity)
        
    def get_product_description(self):
        base_description = super().get_product_description()
        return base_description + f"\nWarranty: {self.warranty_period}"


class ClothingProduct(Product):        
    def __init__(self, product_id, name, price, quantity,size):
        self.size = size
        super().__init__(product_id,name,price,quantity)
        
    def get_product_description(self):
        base_description = super().get_product_description()
        return base_description + f"\nSize: {self.size}" 


class ShoppingCart:

    Shopping Cart:
    Product ID: 1, Name: Laptop, Price: $900.00, Quantity Available: 198
    Warranty: 2 years
    Product ID: 2, Name: Casual Shirt, Price: $27.00, Quantity Available: 548
    Size: M
    >>> discounted_cart.calculate_total()
    927.0
    """
    def __init__(self):
        self.cart_items = []

    def add_to_cart(self, product):
        self.cart_items.append(product)
        product.quantity -= 1

    def display_cart(self):
        cart_details = "Shopping Cart:\n"
        for item in self.cart_items:
            cart_details += item.get_product_description() + "\n" 
        print(cart_details.strip()) 

    def calculate_total(self):
        total = 0
        for item in self.cart_items:
            total += item.price
        return round(float(total),2)


class DiscountedShoppingCart(ShoppingCart):
    def __init__(self,discount_percentage):
         super().__init__()
         self.discount_percentage = discount_percentage

    def apply_discount(self):
        for item in self.cart_items:
            discount =  item.price - (item.price * (self.discount_percentage / 100 ))
            item.price = round(discount , 2)

"Implements a method get_product_description that prints basic information about the product"

You're probably returning the string

 
Expected:
Product ID: 2, Name: Casual Shirt, Price: $30.00, Quantity Available: 550
Size: M
Got:
'Product ID: 2, Name: Casual Shirt, Price: $30.00, Quantity Available: 550\nSize: M'
Transcribed Image Text:Expected: Product ID: 2, Name: Casual Shirt, Price: $30.00, Quantity Available: 550 Size: M Got: 'Product ID: 2, Name: Casual Shirt, Price: $30.00, Quantity Available: 550\nSize: M'
Failed example:
plush_toy.get_product_description()
Expected:
Product ID: 0, Name: Toy Plushie, Price: $25.00, Quantity Available: 50
Got:
'Product ID: 0, Name: Toy Plushie, Price: $25.00, Quantity Available: 50'
Transcribed Image Text:Failed example: plush_toy.get_product_description() Expected: Product ID: 0, Name: Toy Plushie, Price: $25.00, Quantity Available: 50 Got: 'Product ID: 0, Name: Toy Plushie, Price: $25.00, Quantity Available: 50'
Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education