def checkout(self, count): try: if type(count) != int: raise InvalidInputError("Room count must be integer", count) elif count < 1: raise InvalidInputError("Room count must be >0 integer", count) else: self.__room_count = self.__room_count + count except InvalidInputError as e: print("CustomValueError Exception!", e)
def reserve(self, count): try: if type(count) != int: raise InvalidInputError("Room count must be integer", count) elif count < 1: raise InvalidInputError("Room count must be >0 integer", count) elif count > self.__room_count: raise InvalidInputError( "Reserve count can't be > than total rooms count", count) else: self.__room_count = self.__room_count - count except InvalidInputError as e: print("CustomValueError Exception!", e)
def rate(self, new_rating): try: if type(new_rating) != int: raise InvalidInputError("Rating must be integer", new_rating) elif 1 > new_rating > 5: raise InvalidInputError("Rating must be >0 integer", new_rating) else: self.__rater_count = self.__rater_count + 1 self.__rating_sum = self.__rating_sum + new_rating self.__rating = self.__rating_sum / self.__rater_count except InvalidInputError as e: print("CustomValueError Exception!", e)
def checkout(room_obj, count): try: if type(count) != int: raise InvalidInputError("Reserve count must be integer", count) elif count < 1: raise InvalidInputError("Room count must be positive integer", count) elif type(room_obj) != Room: raise InvalidInputError("Room Type must be Room", room_obj) else: Room.checkout(room_obj, count) except InvalidInputError as e: print("CustomValueError Exception!", e)
def __init__(self, amount, currency): try: if type(amount) == int and amount <= 0: raise InvalidInputError("Amount must be a positive number:", amount) elif type(amount) != int: raise InvalidInputError("Amount must be number", amount) elif type(currency) != str: raise InvalidInputError('Currency must be a string type:', currency) else: self.__amount = amount self.__currency = currency except InvalidInputError as e: print("CustomValueError Exception!", e)
def __init__(self, room_type, room_price, room_count): try: if type(room_type) != str: raise InvalidInputError("Room type must be string", room_type) elif type(room_count) != int or room_count <= 0: raise InvalidInputError("Room count must me positive integer", room_count) elif type(room_price) != int or room_price <= 0: raise InvalidInputError("Room price must me positive integer", room_count) else: self.__room_type = room_type self.__room_price = room_price self.__room_count = room_count except InvalidInputError as e: print("CustomValueError Exception!", e)
def set_currency(self, val): try: if type(val) == str: self.__currency = val else: raise InvalidInputError("Invalid value for currency", val) except InvalidInputError: print("currency must be string")
def set_amount(self, val): try: if type(val) == int and val > 0: self.__amount = val else: raise InvalidInputError("Invalid value for amount", val) except InvalidInputError: print("Amount must be positive number")
def add_room(self, room_obj): try: if type(room_obj) == Room: self.__rooms.append(room_obj) else: raise InvalidInputError("Room must be Room Type", Room) except InvalidInputError as e: print("CustomValueError Exception!", e)
def set_experience(self, val): try: if type(self.__experience) == int or type(self.__experience) == float: self.__experience = val else: raise InvalidInputError("You can set only String value for Experience", val) except InvalidInputError as e: print("Experience value must be string", e)
def set_salary(self, val): try: if type(self.__salary) == int or type(self.__salary) == float: self.__salary = val else: raise InvalidInputError("You can set only Number for Salary", val) except InvalidInputError as e: print("Salary must be number", e)
def set_discipline(self, val): try: if type(self.__discipline) == str: self.__discipline = val else: raise InvalidInputError("You can set only String value for Discipline", val) except InvalidInputError as e: print("Discipline value must be string", e)
def set_university(self, val): try: if type(self.__university) == str: self.__university = val else: raise InvalidInputError("You can set only String value for University", val) except InvalidInputError as e: print("University value must be string", e)
def set_course(self, val): try: if type(self.__course) == str: self.__course = val else: raise InvalidInputError("You can set only integer value for Course", val) except InvalidInputError as e: print("Course value must be number", e)
def set_score(self, val): try: if type(self.__middle_score) == int: self.__middle_score = val else: raise InvalidInputError("You can set only integer value for Score", val) except InvalidInputError as e: print("Score value must be number", e)
def set_room_count(self, v): try: if type(self.__room_count) == int: self.__room_count = v else: raise InvalidInputError( "You can set only integer value as a Room count", v) except InvalidInputError as e: print("CustomValueError Exception!", e)
def __init__(self, name, surname, age, gender, university, faculty, course, middle_score): super().__init__(name, surname, age, gender) try: if type(university) != str: raise InvalidInputError("University must be string", university) elif type(faculty) != str: raise InvalidInputError("Faculty must be string", faculty) elif type(course) != str: raise InvalidInputError("Course must be integer", course) elif type(middle_score) != int: raise InvalidInputError("Faculty must be integer", middle_score) else: self.__university = university self.__faculty = faculty self.__course = course self.__middle_score = middle_score except InvalidInputError as e: print("CustomValueError Exception!", e)
def __init__(self, name, surname, age, gender): try: if type(age) == str: raise InvalidInputError("Age can't be string", age) elif age < 0: raise InvalidInputError("Negative Value is not acceptable for aga", age) elif type(name) != str: raise InvalidInputError("Name must be string", name) elif type(surname) != str: raise InvalidInputError("Surname must be string", surname) elif type(gender) != str: raise InvalidInputError("Gender must be string", gender) else: self.__name = name self.__surname = surname self.__gender = gender self.__age = age except InvalidInputError as e: print("CustomValueError Exception!", e)
def __init__(self, name, surname, age, gender, university, faculty, discipline, experience, salary): super().__init__(name, surname, age, gender) try: if type(university) != str: raise InvalidInputError("University must be string", university) elif type(faculty) != str: raise InvalidInputError("Faculty must be string", faculty) elif type(discipline) != str: raise InvalidInputError("Course must be integer", discipline) elif type(experience) != int: raise InvalidInputError("Faculty must be integer", experience) elif type(salary) != int: raise InvalidInputError("Faculty must be integer", salary) else: self.__university = university self.__faculty = faculty self.__discipline = discipline self.__experience = experience self.__salary = Money(salary, "USD") except InvalidInputError as e: print("CustomValueError Exception!", e)
def __init__(self, name, rooms): try: if type(name) != str: raise InvalidInputError("Hotel name must be string", name) else: self.__rating = 0 self.__rater_count = 0 self.__rating_sum = 0 self.__name = name self.__rooms = rooms except InvalidInputError as e: print("CustomValueError Exception!", e)