In this assignment, you are to modify an existing class and create several other unrelated classes. You are to add features involving equality to each class. In addition, for each class that you create, you must provide a constructor whose parameters should be all the instance variables of the class, in the same order we use to describe the instance variables in the questions. We shall be autotesting your programs and our autotesting program will expect exactly the information we require, no more and no less. Do not print anything in any of your classes as this will cause the autotester to reject your results. In addition, be certain that the constructors have the correct parameters in the correct order as failure to do so will also cause unhappiness for the autotester and hence for you.
Obtain the class Counter from Assignment 3 and add
an equals method to it. Two Counter
objects are equal if they have the same current value and the
same increment. You should not create a constructor for this
class.
Write a class FoodOrder that has two instance
variables: the name of the food that was ordered and the
number of servings of that food (an int).
Write a constructor and an equals method for this
and all subsequent classes. Two FoodOrder objects
are equal if the name of the food is the same and the number of
servings is the same.
A wicked witch has hired you to write a class to keep track
of children she has in storage. Class Child
should have as instance variables the name of the child, the
mass of the child (in kilograms, as a double),
and the height of the child (in centimetres, as an
int). To the witch, two Child objects
are equal if they have the same mass (to within 0.25 kg)
and the same height.
Write a class WeatherSensor that has two
instance variables, one of type Thermometer (for
temperature in degrees Celsius: an int) and the other
of type Barometer (for air pressure in kiloPascals:
a double). Write all three classes, with constructors
and equals methods for all three.
Two Thermometers are considered equal if the
temperatures are equal.
Two Barometers are considered equal if the air
pressures are within 0.1 kPa of each other.
Here's the tricky bit: WeatherSensors may be
incomplete, missing either the Thermometer or
Barometer, or both. Two
WeatherSensors are equal if their
Thermometers are equal (or both are missing)
and their Barometers are equal (or both are
missing).
Write a class TempWorker that has as instance
variables a name (a String), the number of
words per minute that the worker can type (an
int), and an indication of whether the worker is
experienced with computers (a boolean:
true if the worker is experienced,
false if not).
Two TempWorkers are equal when either of the
following are true:
Electronically submit all seven .java files following
the directions for your campus.