Lab21: Class variables vs attributes


In the previous lab, you created a class of immutable objects named Color149. Today you will explore another immutable class, but also work with a class intending to be changed. That class contains some instance variables (attributes) as well as some class variables (static).


  • Explain the difference between immutable and mutable objects.

  • Create methods that manipulate class as well as instance variables.

  • Trace the execution of a program that uses many different objects.

The Story

stallone picture

The premise behind the Men in Black (MIB) series of movies is that there are aliens on this earth who have sought a neutral planet for refuge from conflict elsewhere in the universe. Most are benign and in fact are helpful to society. But some go out of control. The MIB keep track of the aliens, and if warranted, "isolate" or "remove" them from the earth.

A little known fact is that the recent Bridgeforth Stadium addition was partially funded through the MIB, who built a secret detention center underneath the stadium turf. Aliens detained at the JMU location will be found at location 38.435427 latitude, -78.872942 longitude.

Your application will enable MID to "check in" new alien arrivals and track their whereabouts. Also, it is important that we know how many aliens we are currently tracking in order to determine workforce requirements. Aliens that are eliminated or deported will be removed from these counts.


  1. Download a copy of and Lab22.txt (the worksheet).

  2. Review the code for, and answer the corresponding questions in the worksheet.

  3. Download a copy of (which contains the main method) and (which you will implement).

  4. Review the code for, and answer the corresponding questions in the worksheet.

  5. Stub out each of the methods by adding return statements. Get everything to compile before moving forward.

  6. Fill in the rest of the code in Use to test your code.

  7. Compare your output with the solution's output (using diff and/or meld).

Read carefully the description of each of the blank methods. In some cases you will alter class variables and instance variables; in others you will alter one or the other; and in some cases you will simply access data.

Submit  via Autolab by the end of the day or tomorrow by 11pm.

Back to Top