/** Room class for spring '07 schedule problem. * The name attribute is simply a location like RLY-100 * I need to store 6 course section strings per room. */ public class Room { private String name; private String [] section; public Room(String s) { name = s; section = new String [6]; // don't forget to allocate indiv strings! for (int i = 0; i < 6; ++i) section[i] = ""; } public String toString() { // Allow up to 10 characters for the name of the room String build = name; for (int i = 0; i < 10 - name.length(); ++i) build += " "; // For each class section, allow up to 11 characters for its info for (int i = 0; i < 6; ++i) { build += section[i]; for (int j = 0; j < 11 - section[i].length(); ++j) build += " "; } return build; } // Warning - hour parameter is a number 8-13 not 0-5. // Use a star (*) to signify that we have additional class // at same time (in same room). public void addClass(String courseSection, int hour) { hour = hour - 8; if (section[hour].length() == 0) section[hour] = courseSection; else section[hour] += "*"; } public String getName() { return name; } }