Next: The class ApartmentOwner: representation
Up: Unit 07
Previous: Parameters passed to a
Specification:
Realize a Java class whose objects maintain some information on the owners of
apartments. Each object of the class should contain a string that indicates
the name of the owner, and an array of 10 slots of type string, indexed by the
numbers from 0 to 9, that can contain each the address of an apartment owned by
that owner (or null, if the slot is empty). The class should export
the following functionalities:
- a constructor that takes as parameter the name of the owner, and creates
an object with the specified owner and in which all slots of the array are
initially empty;
- a method that returns the owner of an apartment;
- a method that returns the address contained in a slot (or null,
if the slot is empty);
- a method to assign the address of an apartment to a slot;
- a method that returns the number of apartments (i.e., of non-empty
slots);
- a method that reorganizes the addresses in such a way that they are
contained in the first consecutive slots of the array;
- a method toString(), that overrides the toString()
method inherited from Object, and returns a string containing the
information about the object.
Next: The class ApartmentOwner: representation
Up: Unit 07
Previous: Parameters passed to a