Untitled

 avatar
unknown
plain_text
15 days ago
1.6 kB
1
Indexable
class Laptop:
    def __init__(self, brand, processor, ram_size, storage_type):
        self.brand = brand
        self.processor = processor
        self.ram_size = ram_size
        self.storage_type = storage_type

    def display_specs(self):
        print(f"Laptop Brand: {self.brand}")
        print(f"Processor: {self.processor}")
        print(f"RAM Size: {self.ram_size} GB")
        print(f"Storage Type: {self.storage_type}")
        print("-" * 30)


class Customer:
    def __init__(self, name):
        self.name = name
        self.purchased_laptops = []

    def purchase_laptop(self, laptop):
        self.purchased_laptops.append(laptop)

    def list_purchases(self):
        print(f"{self.name}'s Purchased Laptops:")
        if not self.purchased_laptops:
            print("No laptops purchased yet.")
        else:
            for laptop in self.purchased_laptops:
                laptop.display_specs()


class LaptopFactory:
    total_laptops_produced = 0

    def build_laptop(self, brand, processor, ram_size, storage_type):
        laptop = Laptop(brand, processor, ram_size, storage_type)
        LaptopFactory.total_laptops_produced += 1
        return laptop

    def get_production_count(self):
        return LaptopFactory.total_laptops_produced
    

if __name__ == "__main__": 
 
 laptop = LaptopFactory()

 laptop1 = laptop.build_laptop("Dell", "Ryzen 7", 32, "SSD")

 customer = Customer("Janusek")

 customer.purchase_laptop(laptop1)

 customer.list_purchases()






Leave a Comment