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 |
|---|---|
| Manufacturer: Dell, Model: Inspiron 3593, Year: 2020 |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB