CSC241: Homework 1


This is a light and easy introduction into the project. Remember to read the complete project description in order to understand the general context of the homework.

Create two classes, Room and Animal, that have the following properties: A Room can contain ten Animals; every Animal must know about its Room (i.e., it needs to have a Room reference). Besides, every Room and every Animal must have a name. Finally, add a public String toString() method to every Room that returns the name of the Room and the names of all Animals in the Room. (hint: a Room's toString() method should call Animals' toString() methods).

The Room class should have a public constructor that takes a String (the name of the Room), and a public void addAnimal(Animal a) method that adds an Animal object to the Room's array of Animals. Respectively, the Animal class should have a public constructor that takes a String (the name of the Animal).

I will test your homeworks by providing a driver class that calls the respective public methods of your classes, so make sure your public methods/fields/classes are named exactly as described above.