Microwave Ovens Microwave Ovens
RU English
The mission is in Reviewing Mode. You can't see the solutions Leader Board, but you can see other user solutions through the Random Review after you solve the mission.

At your work there is a place for the lunch where are 3 microwave ovens (Мicrowave1, Мicrowave2, Мicrowave3) which are the subclasses of the MicrowaveBase class. Every microwave could be controlled by RemoteControl. RemoteControl is use the next commands:

set_time("xx:xx"), where "xx:xx" - time in the minutes and seconds, which shows, how long the eat will be warm up. For example: set_time("05:30")
add_time("Ns"), add_time("Nm"), where N - the amount of the seconds("s") or minutes("m"), which should be added to the current time.
del_time("Ns"), del_time("Nm"), where N - the amount of the seconds("s") or minutes("m"), which should be subtracted from the current time.
show_time(), shows current time for the microwave.

The default time is 00:00. The time is couldn't be less than 00:00 or greater than 90:00, even if add_time or del_time make this happens.

Your task is to create a few classes - one for the MicrowaveBase, three for the three different microwaves and one for the RemoteControl - just as described above. The RemoteControl will have 1 parameter - an instance of the Microwave (for example, RemoteControl(microwave_1), where microwave_1 = Microwave1()) which shows which Microwave should be controlled by the current RemoteControle. Only third oven is works properly and shows the full time. The other two have some problems with their displays - first shows '_' instead of the first digit and second do the same with the last digit. They are show time like this:

microwave_1 = Microwave1()
microwave_2 = Microwave2()
microwave_3 = Microwave3()

RemoteControl(microwave_1).show_time() == "_0:00"
RemoteControl(microwave_2).show_time() == "00:0_"
RemoteControl(microwave_3).show_time() == "00:00"

In this mission you could use Bridge design pattern. Its main task is - to decouple an abstraction from its implementation so that the two can vary independently.


microwave_1 = Microwave1()
microwave_2 = Microwave2()
microwave_3 = Microwave3()

remote_control_1 = RemoteControl(microwave_1)

remote_control_2 = RemoteControl(microwave_2)
remote_control_3 = RemoteControl(microwave_3)
remote_control_1.show_time() == "_1:00"
remote_control_2.show_time() == "01:3_"
remote_control_3.show_time() == "01:40"

Input: methods of the RemoteControl class and time.

Output: time on the display of the microwave.

How it is used: For work with time.

Precondition: 00:00 <= time <= 90:00