Question
Need pseudocode for the following public class MasterRoomList { ArrayList masterRoomList; public MasterRoomList() { masterRoomList = new ArrayList (); createMasterList(); } public ArrayList getMasterRoomList() {
Need pseudocode for the following
public class MasterRoomList {
ArrayList
public MasterRoomList() { masterRoomList = new ArrayList
public ArrayList
public void addRoom(Room room) { masterRoomList.add(room); }
public void removeRoom(Room room) { for (Room r : masterRoomList) { if (r.getRoomNumber().equals(room.getRoomNumber())) { masterRoomList.remove(r); } } }
public void setDirty(Room room) { for (Room r : masterRoomList) { if (r.getRoomNumber().equals(room.getRoomNumber())) { r.setIsDirty(true); } } }
public void setClean(Room room) { for (Room r : masterRoomList) { if (r.getRoomNumber().equals(room.getRoomNumber())) { r.setIsDirty(false); } } }
public boolean checkDirty(Room room) { boolean isDirty = false; for (Room r : masterRoomList) { if (r.getRoomNumber().equals(room.getRoomNumber())) { isDirty = r.isIsDirty(); } } return isDirty; }
public void checkCapacity(Room room, int numOfGuests) { for (Room r : masterRoomList) { if (r.getRoomNumber().equals(room.getRoomNumber())) { if (r.getMaxGuest() > numOfGuests) { JOptionPane.showMessageDialog(null, "Room is at capacity. An additional room" + " is required."); } } } }
private void createMasterList() { File file = new File("rooms.txt"); FileReader fr; try { fr = new FileReader(file); BufferedReader br = new BufferedReader(fr); String line; RoomType type; Smoking smoke; PetFriendly pets; while ((line = br.readLine()) != null) { String[] split = line.split("\\s*,\\s*"); String tempNum = split[0]; String tempType = split[1]; if (tempType.contains("RoomType.KINGSINGLE")) { type = RoomType.KINGSINGLE; } else { type = RoomType.QUEENDOUBLE; } String tempSmoke = split[2]; if (tempSmoke.contains("Smoking.SMOKING")) { smoke = Smoking.SMOKING; } else { smoke = Smoking.NONSMOKING; } String tempPets = split[3]; if(tempPets.contains("YES")) pets = PetFriendly.YES; else pets = PetFriendly.NO; Room tempRoom = new Room(tempNum, type, smoke, pets); addRoom(tempRoom); } } catch (FileNotFoundException ex) { Logger.getLogger(MasterRoomList.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(MasterRoomList.class.getName()).log(Level.SEVERE, null, ex); } System.out.println(masterRoomList); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started