Imagine you are writing a graphics editor. It will have a canvas and a set of tools to work with. Each tool will do a specific job and the editor will register whether the mouse buttons are pressed or released to decide which action must be done with the selected tool. Don't worry, you don't have to write a real graphics editor. In this code challenge, you just have to print the corresponding action to the terminal. Also, a mouseUp event will alsways follow a mouseDown event so you don't need to worry about their order either.
- If the SELECTION tool is selected, print
Started selectionin response to amouseDownevent andFinished selectionin response to amouseUpevent. - If the DRAW tool is selected, print
Drawing a %color% linein response to amouseDownevent andFinished drawing a %color% linein response to amouseUpevent where%color%is the value of thecolorfield in theCanvasclass. - If the ERASER tool is selected, print
Selecting figures to deletein response to amouseDownevent andErased selected figuresin response to amouseUpevent.
Use the provided template and the power of the State pattern to complete this task.