Question: Need java code for these steps In WhackAShape we implement the methods bottom up. If method A depends on methods B and C, then methods

 Need java code for these steps In WhackAShape we implement themethods bottom up. If method A depends on methods B and C,

Need java code for these steps

In WhackAShape we implement the methods bottom up. If method A depends on methods B and C, then methods B and C will be implemented before method A. buildShape(String input) In the buildShape) method, you will parse the provided input to determine whether to create a CircleShape or SquareShape. Before you create the shape, you need to determine it's size, location and color Use TestableRandom to randomly generate an int size ranging from 100-200. Randomly generate an and y ndex for its location. X will ange over the w do s width, and y over the window's height. Use windows etGraphPanel ?dth and getGraphPanelHeight methods. Be sure to subtract the size you generated, since the object will be drawn from its upper left hand corner. We don't want part of the shape hanging off the edge of the screen. Using the String's contains method and if statements, determine if it says "red" or "blue" If neither of these colors are specified, throw a new IllegalArgumentException This tells whoever gave the string to this method that their input was wrong. Allow the @throws tag to be generated. Also check to see if the string contains "circle' or square. If it doesn't, throw a new IllegalArgumentException If the string does contain circle" or "square, use x, y, size, and color as parameters to build the appropriate CircleShape or SquareShope. See the GraphWindow AP! to look at their methods and constructors. Name your shape current Shape Tie current Shape to the clickedShapeO method by calling its onClick method with the parameters this and "clickedShape. Be sure to specify the method's name. Return currentShape. clickedShape(Shape shape) If the user has clicked the displayed shape, this should call the clickedShape method. Here, we know the user has selected the Shape given as the Shape parameter. We now need to remove this Shape from the window, by calling the window's removeShape(shape) method, and from the bag. by calling the bag's [remove(shape) method. Once the clicked shape is removed, the next shape needs to be displayed Pick a new one from the ba?using bag's pick ) method, and name it nextShape Check to see if nextShape is null. If it is, it means that the bag is empty, and the game is over. Display a new TextShape saying "You Win!" in the center of the screen. To get the x and y location of the center of the screen, use getGraphPane LWidthO and PanelHeightO on your Window etGraph Otherwise, add nextShape to the window using the window's addShape(nextShape) method. clickedQuit(Button button) Same as project 1, call System.exitO with a zero for its parameter. This means there was no errors. getWindow) && getBag0 Implement these yourself. In the default WhackAShape constructor, you will initialize your bag with SimpleArray8ag or SimplelinkedBag. your choice. (Feel free to try both! It won't affect your WhackAShape code.) Initialize your window, and add a Quit Button to your Window's north side, much like in project 1 To put a few things in your bag, start out by calling buildShape for 'red circle."blue circle". "red square', and blue square."Be sure to put each Shape into your bag. Add the first Shape to the Windowby calling pickO In WhackAShape we implement the methods bottom up. If method A depends on methods B and C, then methods B and C will be implemented before method A. buildShape(String input) In the buildShape) method, you will parse the provided input to determine whether to create a CircleShape or SquareShape. Before you create the shape, you need to determine it's size, location and color Use TestableRandom to randomly generate an int size ranging from 100-200. Randomly generate an and y ndex for its location. X will ange over the w do s width, and y over the window's height. Use windows etGraphPanel ?dth and getGraphPanelHeight methods. Be sure to subtract the size you generated, since the object will be drawn from its upper left hand corner. We don't want part of the shape hanging off the edge of the screen. Using the String's contains method and if statements, determine if it says "red" or "blue" If neither of these colors are specified, throw a new IllegalArgumentException This tells whoever gave the string to this method that their input was wrong. Allow the @throws tag to be generated. Also check to see if the string contains "circle' or square. If it doesn't, throw a new IllegalArgumentException If the string does contain circle" or "square, use x, y, size, and color as parameters to build the appropriate CircleShape or SquareShope. See the GraphWindow AP! to look at their methods and constructors. Name your shape current Shape Tie current Shape to the clickedShapeO method by calling its onClick method with the parameters this and "clickedShape. Be sure to specify the method's name. Return currentShape. clickedShape(Shape shape) If the user has clicked the displayed shape, this should call the clickedShape method. Here, we know the user has selected the Shape given as the Shape parameter. We now need to remove this Shape from the window, by calling the window's removeShape(shape) method, and from the bag. by calling the bag's [remove(shape) method. Once the clicked shape is removed, the next shape needs to be displayed Pick a new one from the ba?using bag's pick ) method, and name it nextShape Check to see if nextShape is null. If it is, it means that the bag is empty, and the game is over. Display a new TextShape saying "You Win!" in the center of the screen. To get the x and y location of the center of the screen, use getGraphPane LWidthO and PanelHeightO on your Window etGraph Otherwise, add nextShape to the window using the window's addShape(nextShape) method. clickedQuit(Button button) Same as project 1, call System.exitO with a zero for its parameter. This means there was no errors. getWindow) && getBag0 Implement these yourself. In the default WhackAShape constructor, you will initialize your bag with SimpleArray8ag or SimplelinkedBag. your choice. (Feel free to try both! It won't affect your WhackAShape code.) Initialize your window, and add a Quit Button to your Window's north side, much like in project 1 To put a few things in your bag, start out by calling buildShape for 'red circle."blue circle". "red square', and blue square."Be sure to put each Shape into your bag. Add the first Shape to the Windowby calling pickO

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!