Question: Class definition #2 Write a program which defines a class for appliances. The class should have three properties: the device name, the power consumption, and

Class definition #2

Write a program which defines a class for appliances. The class should have three properties: the device name, the power consumption, and the energy efficiency expressed as a percentage. The device name is a mandatory property, while the other two are optional and, therefore, can have a default value (e.g., 1 for 1 Watt and 50 for an efficiency of 50%).

Create 2 objects using the defined class. Provide the code below.

Reply below (only code here):

Now, make sure that all parameters are hidden and allow their retrieval with a getter method and their modification with a setter method.

Modify and display the properties of the two previously created objects. Provide the code below.

Reply below (only code here):

Create a method that provides the power losses as the product between the power consumption and the complement to 1 of the efficiency: power_losses = power_consuption * (100-efficiency)/100

In the previous code, use the method for calculating power losses for the two previously created objects.

Provide the code below.

Reply below (only code here):

Provide the screenshot of the run output (entire screen, no cuts).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!