5. Writing Classes

Cat Class

Directions: This project can also be found on google classroom. Because this assignment is meant to simulate an AP CSA FRQ, there are no instructions provided that suggest you write test code (such as a main program). SO DO NOT WRITE ANY. On the actual AP exam, writing unnecessary test code (such as main) would likely lead to significant deductions.


Your job is to write an entire Cat class:


  • The class should keep track of two variables or properties of the cat, its name and how many lives it has left. You need to create getters and setters for these two fields.

  • The Cat class should have two constructors. The first should take no arguments and should set the name of the cat to “Unknown”. The second constructor should be passed a string to be used as the name of the cat.

  • The toString() method should return the name of the cat and how many lives it has in a formatted String.

  • Create two additional methods for the Cat class. Create a addLife() method that adds one to the lives variable. Create a subLife() method that subtracts one from the lives variable.

  • When the cat is born, you should initialize the lives to be 9.

This assignment must be done on paper, not on a computer because it’s main goal is to prepare you for the AP exam. Show your finished code to your instructor.



Aquarium Lab

All the starter files for the Aquarium Lab can be found in this folder. You need to download the zip file called "Aquarium Student.zip" and extract all the files.

Then follow this Student Activity Guide to complete the lab.

Vehicle Lab

Go to this folder and download the folder called "Constructors and Comparable Interface Lab - Vehicles" on to your PC. Then follow the instructions in the document, below.

Directions for Vehicles Lab

Call By Value


Go to this document to find the directions for this lab.