1) Calculator that handles exceptions (10 marks) Create a GUI similar to the following:
The user is expected to fill in the input 1 and 2 fields. By pushing one of the calculator buttons it will perform the correct calculation and put the output in the output box. There are a few ways users can cause exceptions using this GUI, (for example, divide by 0, fields not being set, inputs being strings not numbers). Implement Y vfY exceptions that are handled by your code. When these exceptions are triggered you should handle them gracefully, and the gui should change in some way, (for example if a field is not filled in and they try to perform a calculation the field can change colour to highlight which field wasn’t filled in, or have a status message label change and update to tell the user which exception they)
2) Home Automation with exception handling (20 marks) Home automation is becoming popular with homeowners these days. The short explanation of it is that you control several electronic devices from a central hub, usually an app on your phone or computer. You will be creating a GUI that will control at least 2 different types of devices. See the following example:
In this app you will need to control at least two different classes of devices, so for my example, I have used lights and TV, however you may pick any electronic device that you may want to control. For each device I would like you to have at least two controls, however feel free to add more to make it make sense where applicable. Each device should update an element of the GUI via the action listeners for the buttons. So for example on the lighting control, and example of modifying the GUI might be changing the light bulb image from and “off” light bulb to an “on” light bulb, and for the TV example, pushing channel up increases the number in the current channel field. Each device should also have 2 exception cases which should be handled and should prompt the user in some way. So for example, the light bulb case turning on the lights when the lights are already on should throw an exception which prompts the user to let them know that the lights are already on, and a similar situation if they try to turn off the lights that are already off.