Laptop vs Desktop

You are a system manager in a tech company. You are tasked with developing an inventory system for keeping track of the different computers in the company.
The system should have a base class Computer which should have the following attributes:
  • manufacturer: The company that manufactured the computer.
  • model: The model of the computer.
  • year: The year the computer was manufactured.
This base class should have a method display_info() which displays the above information about the computer in the Manufacturer: <manufacturer>, Model: <model>, Year: <year> format.
Additionally, you are tasked to create two subclasses Laptop and Desktop which inherit from the Computer class.
The Laptop class should have two additional attributes:
  • battery_life: The average battery life of the laptop.
  • weight: The weight of the laptop.
The Desktop class should have one additional attribute:
  • power_consumption: The power consumption of the desktop.
Both the Laptop and Desktop class should override the display_info() method from the Computer class to display the additional attributes relevant to their type.
The Laptop class should display the information in the Manufacturer: <manufacturer>, Model: <model>, Year: <year>, Battery Life: <battery_life>, Weight: <weight> format.
The Desktop class should display the information in the Manufacturer: <manufacturer>, Model: <model>, Year: <year>, Power Consumption: <power_consumption> format.
Input
Output
comp = Computer('Dell', 'Inspiron 3593', 2020); laptop = Laptop('HP', 'Pavilion', 2019, '6 hours', '1.85 kg'); desktop = Desktop('Lenovo', 'ThinkCentre M720', 2022, '90 W'); comp.display_info(); laptop.display_info(); desktop.display_info()
Manufacturer: Dell, Model: Inspiron 3593, Year: 2020 Manufacturer: HP, Model: Pavilion, Year: 2019, Battery Life: 6 hours, Weight: 1.85 kg Manufacturer: Lenovo, Model: ThinkCentre M720, Year: 2022, Power Consumption: 90 W
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue