Lab 19: Class variables vs attributes

Background

Today you will explore an immutable class(Python does not implement fully immutable objects, but Java and other Object Oriented languages do), but also work with a class intending to be changed. That class contains some instance variables (attributes) as well as some class variables (static).

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 picture
Pug
bug
speilberg

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

  2. Review the code for location.py.

  3. Download a copy of mib.py (which contains a main section) and alien.py (which you will implement).

  4. Review the code for alien.py.

  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.py. Use mib.py 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.py  via Gradescope by the end of the day or tomorrow by 11pm.

Back to Top