The goal of this project is to become more familiar with creating and using classes and objects in Java. In order to do so, you will create a Person class. Your class will keep track of how many parts are not shown, display the next item when a method is called, and reset. You will also create a small test application to test your new Person class. The objective here again is to become more familiar with creating and modifying classes as well as manipulating objects. This is a creative assignment. No two pictures will (should) be the same.


  • Create a new Java project named “Project3_netid” (where you replace netid with your NetID)
  • Create a Person class that extends JPanel (see Section 4.6)

Create a Person class that draws a person. The Person class should implement the following methods:

  • getNumLeft – returns the number of turns the player has left (e.g. 6 at the beginning assuming head, body, left/right arm/leg). Hint: this is named like a getter/accessor method for a reason.
  • reset – which resets the number of turns left and erases the person so it is not visible
  • showNext – progressively causes the next body part to be shown: head, body, left arm, right arm, left leg, right leg
  • main – a static method used for testing (see Section 4.6). It should display a person object and when you click on it the next body part should show, if all parts are visible, then it should be reset so it is no longer visible. This will be removed for the final game, but will allow you to test each piece as you go, which is a good programming practice. (See the hint below for help with handling the mouse clicking.)

Be sure to:

  • Use proper indentation
  • Use appropriate variable/field names
  • Group like things together (items that are part of the same objects)
  • Use appropriate comments – including comments for each method
  • Check your curly braces

Hints / tips

  • You may find it useful to organize your person-drawing code into a separate method for each body part (e.g., drawHead, drawBody, dawLeftLeg, etc…).
  • In order to support showing the next body part when the person is clicked, you will need to add the following code (which you need to complete) in the constructor of your Person class:
this.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { // add code so if not all shown, the next body part // is shown, otherwise the person is reset } });
  • To find out more about what shapes you can draw, search on the internet for the Java Graphics class description. Doing this search should return a link to the full description of what can be done with the Graphics class. This is called the application programming interface (API), and is part of an extended library of classes that are available in Java.
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.