Question: . Java Part One There are three person objects, john, mary and jane, sharing a piggy bank of $1000. The Person class contains a double

. Java

Part One 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 Two

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); // 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. 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

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.

DOCD DO0OO DO0O0QO D00OO00O D00O0000OOO

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!