Hi There!

I'm Dan Schlegel, an Assistant Professor in the Computer Science Department at SUNY Oswego

Assignment 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 and for further details. You can download a jar file (and required sample input file) for a project which meets the requirements of the project description but will not follow the same implementation as we will use in this course.

In this first assignment you will create two classes, Room and Adult, that have the following properties:

  • A Room can contain five Adults, stored in an array (NOT an ArrayList);
  • Every Adult must know about its Room (i.e., it needs to have a Room reference);
  • Every Room and every Adult must have a name and description;
  • Room has a public String toString() method that returns the name of the Room, its description and the names and descriptions of all Adults in the Room. (hint: Room’s toString() method should call Adults’ toString() methods);
  • The Room class should have a public constructor that takes two Strings (the name of the Room, and the description of the Room), and a public void addAdult(Adult a) method that adds an Adult to the Room. Be sure to think about what needs to change about the Adult being assigned Room, and the Room it is being assigned to;
  • The Adult class should have a public constructor that takes two Strings (the name of the Adult, and the description of the Adult).

Be sure to think about cases of failure – what should you do when an operation cannot be performed? See the project description for details.

In this assignment you may not use any static methods or fields – we will need the ability to have more than one Room and Adult as the project moves forward! Remember to use good practices. For example, don’t access fields directly from other classes, use getter/setter methods.

Create a third class (call it Main) which contains a main method implementing test cases for the above criteria. Be sure it contains tests for the “hard” cases, e.g., testing Room’s toString where a Room contains more than one Adult.

You will submit your assignment via Blackboard. I will be using my own driver class which tests various aspects of this assignment, so make sure your public methods/fields/classes are named exactly as described above.