Answered step by step
Verified Expert Solution
Question
1 Approved Answer
****USE JAVA TO CODE***USE JAVA*** WILL MAKE SURE TO RATE ITIMMEDIATELY! I APPRECIATE GOOD WORK! Part A There are three person objects, john, Mary and
****USE JAVA TO CODE***USE JAVA*** WILL MAKE SURE TO RATE ITIMMEDIATELY! I APPRECIATE GOOD WORK! Part A There are three person objects, john, Mary and Jane, sharing a piggy bank of $1000. The Person class contains a double field for the piggy bank. Implement a Java program to instantiate the three objects as follows: Person john - new Person Person mary - new Person Person Jane new Person ( ); This Person class also has two methods: one is to withdraw money and the other is to check balance of the piggy bank. Balance checking will return a double primitive value. Provide another class MyProg to start the program execution. In the main method, you should model the following behavior by using the methods. First, John took $75 out of the piggy bank and then viewed the balance. Mary later took away $150. John again withdrew another $120. Finally, Jane checked the balance of the piggy bank. Your program should print out the result for each balance checking. Show the UML class diagram for the Person class. Hint: piggy bank should be declared as a local, an instance or a class variable? Part B Develop a BullsEye class that comes with a show (int x, int y, Graphics g) method to display exactly one public class BullsEye public void show (int x, int y, Graphics g) // assign int values to w (width) and h (height) g.drawOval(x, y, w, h), II arguments are similar to the drawOval above g.filloval … ); Create a JFrame Form for developing class TestGUI to start the execution. In the class, declare BullsEyes object b and int row_no to be instance variables. Reference the assignment video of module M3 to provide the void paint (Graphics g) method. Pass message, the object g, to the BullsEye's show method. Here exemplifies the code in the TestGUI class. The number of bullseyes will depend on the row_no value. public void paint(Graphics g) for(int i 0, i row_no, i++) a loop b.show (100, 100 25 * i, g); For this assignment, the result is expected to be a triangular shape. Modify the code in the paint method, so that for row_no 6 the result is as the graph shown below Basically, an increment of one to row_no will introduce two additional BullsEyes. The final result must be displayed at the center of the JFrame Form. (accuracy importanth Give answers to the following questions in the header of the BullsEye class, i.e., putting them in a multiple line comment. For the three arguments x, y and g, what objects are call-by-value and what are call-by- reference? (important) Since object b and int row_no are instance variables, can they be used in other methods in class TestGUI? (important) DOCD D0OO D0O0QO D0OO0Q D0O0000OOC
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