Question
Create a new file called doodlelab.java. 2. Make sure you download the doodlepad.jar file from http://doodlepad.org and place it in the same directory as your
Create a new file called doodlelab.java. 2. Make sure you download the doodlepad.jar file from http://doodlepad.org and place it in the same directory as your program. 3. Add an import statement to the top of the file to import doodlepad.* 4. Define a new class named doodlelab and give it a public static void main(String[] args) method. 5. Declare static variables and methods, as appropriate, to implement your program. Hints: Youll need at least three int variables to keep track of the tally of each colored M&M Youll need a StringBuilder object to accumulate the R, G or B letters that log the color and order of M&Ms produced
6. Define three static methods to be invoked when each of the three Ovals are clicked. Assign these methods as event handlers for the appropriate Ovals mouse pressed event. Remember, the signature (parameter types and order) must match mouse event handler methods Make sure that the body of each of the three methods increments the correct color variable and updates the StringBuilder object, as necessary.
7. Define a fourth static method named showSummary(...). Assign it as the mouse pressed event handler for the Rectangle object. Make sure to define the method with the proper signature for a mouse event handler. The body of this method should print all totals for the three M&M colors, and the String value of the StringBuilder object.
8. Define a public static void main(String[] args) method that sets up your program, including: Instantiation of three Oval objects that are colored appropriately. Instantiation of a Rectangle object. If necessary, instantiation a new StringBuilder object to accumulate R, G or B letters. Assignment of all event handler methods to the events of each shape using their setMousePressedHandler(...) method by passing the proper method reference.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started