class Customer: def __init__(self, roomBooking, name): self.__roomBooking = roomBooking self.__name = name self.__feedback = 0 #1 Mark for creating mutators to change the value of feedback from outside the Customer class def positiveExperience(self): self.__feedback += 1 def negativeExperience(self): self.__feedback -= 1 #1 Mark for creating accessors to pass the values of the Customer class' private attributes outside of the Customer class def getFeedback(self): return self.__feedback def getRoom(self): return self.__roomBooking def getName(self): return self.__name class Room: def __init__(self, number, size, clean): self.__number = number self.__size = size self.__occupants = [] self.__clean = clean #1 Mark for implementing addOccupant in the Room class #1 Mark for appropriately changing how class attributes are accessed in addOccupant def addOccupant(self, occupantIn): if len(self.__occupants) < self.__size: self.__occupants.append(occupantIn) occupantIn.positiveExperience() else: occupantIn.negativeExperience() return if self.__clean == True: occupantIn.positiveExperience() else: occupantIn.negativeExperience() self.__clean = False #1 Mark for implementing removeOccupant in the Room class #1 Mark for appropriately changing how class attributes are accessed in removeOccupant def removeOccupant(self, occupantOut): index = -1 for pos, occupant in enumerate(self.__occupants): if occupantOut.getName() == occupant.getName(): index = pos if index != -1: del self.__occupants[index] #1 Mark for creating accessors (or equivalent methods) to pass the values of the Room class' private attributes outside of the Room class def isEmpty(self): if self.__occupants == []: return True else: return False def clean(self): self.__clean = True class Hotel: def __init__(self, rooms): self.__rooms = rooms def checkRooms(self): return self.__rooms class Manager: def __init__(self, name): self.__name = name #1 Mark for implementing takeFeedback in the Manager class #1 Mark for appropriately changing how class attributes are accessed in takeFeedback def takeFeedback(self, customer): if customer.getFeedback() > 0: print(self.__name + " says:\n" + customer.getName() + " was happy with their stay!") elif customer.getFeedback() < 0: print(self.__name + " says:\n" + customer.getName() + " was unhappy with their stay!") else: print(self.__name + " says:\n" + customer.getName() + " found their stay ok.") class Cleaner: def __init__(self, name): self.__name = name #1 Mark for implementing cleanRooms in the Cleaner class #1 Mark for appropriately changing how class attributes are accessed in cleanRooms def cleanRooms(self, hotel): for roomNumber, room in enumerate(hotel.checkRooms()): if room.isEmpty(): room.clean() print(self.__name + " cleaned Room " + str(roomNumber + 1)) class Receptionist: def __init__(self, name): self.__name = name #1 Mark for implementing checkIn in the Receptionist class #1 Mark for appropriately changing how class attributes are accessed in checkIn def checkIn(self, hotel, customer): room = hotel.checkRooms()[customer.getRoom() - 1] room.addOccupant(customer) print(self.__name + " checked in " + customer.getName()) #1 Mark for implementing checkOut in the Receptionist class #1 Mark for appropriately changing how class attributes are accessed in checkOut def checkOut(self, hotel, customer, manager): room = hotel.checkRooms()[customer.getRoom() - 1] room.removeOccupant(customer) print(self.__name + " checked out " + customer.getName()) manager.takeFeedback(customer) def main(): room1 = Room(1, 1, False) room2 = Room(2, 2, True) room3 = Room(3, 1, False) hotel = Hotel([room1,room2,room3]) customer1 = Customer(1, "Mrs. White") customer2 = Customer(2, "Mr. Green") customer3 = Customer(2, "Miss. Scarlett") customer4 = Customer(3, "Mrs. Peacock") customer5 = Customer(2, "Prof. Plum") customer6 = Customer(3, "Col. Mustard") receptionist = Receptionist("Jane") cleaner = Cleaner("Michael") manager = Manager("Janhavi") receptionist.checkIn(hotel, customer1) receptionist.checkIn(hotel, customer2) receptionist.checkIn(hotel, customer3) receptionist.checkOut(hotel, customer1, manager) cleaner.cleanRooms(hotel) receptionist.checkIn(hotel, customer4) receptionist.checkOut(hotel, customer4, manager) receptionist.checkIn(hotel, customer5) receptionist.checkOut(hotel, customer5, manager) receptionist.checkOut(hotel, customer2, manager) receptionist.checkOut(hotel, customer3, manager) cleaner.cleanRooms(hotel) receptionist.checkIn(hotel, customer6) receptionist.checkOut(hotel, customer6, manager) input() if __name__ == '__main__': main()