CS 149: Introduction to Programming
James Madison University, Spring 2018 Semester

Lab22: Class variables vs attributes

Background

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

IMPORTANT: The final exam will be similar in scope to this lab. It's important that you not only get the lab done, but that you thoroughly understand the underlying concepts. Be sure to ask questions.

Objectives

The Story

     

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.

Instructions

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

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

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

  4. Review the code for Alien.java, 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 Alien.java. Use MIB.java 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 Alien.java and Lab22.txt via Canvas by the end of the day.