import java.awt.*; abstract class Entertainment { protected int volume; private boolean on; public void switchOn() { on = true; } public void switchOff() { on = false; } public abstract void changeVolume(int amount); public abstract void display(Graphics g); } interface ElectricalDevice { public void setTimeInUse(int time); public int getTimeInUse(); public int getPower(); } class TV extends Entertainment implements ElectricalDevice { private int channel; private int time; public void changeVolume(int amount) { volume = volume + amount; } public void display (Graphics g) { g.fillRect(10, 10, 10, volume); } public void setTimeInUse(int time) { this.time = time; } public int getTimeInUse() { return time; } public int getPower() { return 100; } } class ElectricityManager { private int totalPower; public void calcPower(ElectricalDevice device) { int power = device.getTimeInUse() * device.getPower(); totalPower = totalPower + power; device.setTimeInUse(0); } }