James Madison University, Fall 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
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](stallone.jpg)
![Frank the Pug](frank_the_pug.jpg)
![Bug Cup](bugcup.jpg)
![Speilberg](speilberg.jpeg)
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
Download a copy of Location.java and Lab22.txt (the worksheet).
Review the code for Location.java, and answer the corresponding questions in the worksheet.
Download a copy of MIB.java (which contains the main method) and Alien.java (which you will implement).
Review the code for Alien.java, and answer the corresponding questions in the worksheet.
Stub out each of the methods by adding return statements. Get everything to compile before moving forward.
Fill in the rest of the code in Alien.java. Use MIB.java to test your code.
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. You may also choose to upload to AutoLab - 5 pts extra lab credit if you get 100% in AutoLab, but your lab grade for today will come exclusively from Canvas.