def setUp(self): self.yolo = Hotel("YOLO", "Utopia", 13) self.tcu = Hotel("The Crack Up", "Laughter", 55) self.swit = Hotel("Swing It", "Laughter", 69) self.tcu_ = Hotel("The Crack Up", "Laughter", 24) self.yolo.add_hotel() self.tcu.add_hotel()
def test_get_hotels_rate(self): self.result = Controller() self.balajibavan = Hotel("balajibavan", 3) self.balajibavan.add_price_details(200, 100, 90, 90) self.result.add_hotels_details(self.balajibavan) self.parsons = Hotel("parsons", 4) self.parsons.add_price_details(400, 300, 100, 70) self.result.add_hotels_details(self.parsons) self.vivera = Hotel("vivera", 5) self.vivera.add_price_details(400, 300, 90, 90) self.result.add_hotels_details(self.vivera) self.garden = Hotel("garden", "") self.garden.add_price_details(300, 100, 90, 90) self.result.add_hotels_details(self.garden) self.customer = Customer("kala", "Reward") self.result.get_hotels_rate(self.customer, ["Monday"], ["Sunday"]) result, cheepest_hotel = self.result.cheepest_hotel() self.result.get_available_hotel(cheepest_hotel) self.result.get_hotels_rate(self.customer, ["Monday"], ["Sunday"]) result, cheepest_hotel = self.result.cheepest_hotel() result = self.result.get_available_hotel(cheepest_hotel) self.assertTrue(result) self.assertNotEqual(result, False)
def fill_test_data(self): hotel1 = Hotel(1, "Rotana", "Amman", 300, 50) hotel1.add_hotel() hotel12 = Hotel(2, "Royal", "Amman", 250, 35) hotel12.add_hotel() hotel1.list_hotels_in_city() customer1 = Customer("Yahya") customer1.add_customer() reservation1 = Reservation("Rotana", "Yahya", "+962779148786") reservation1.reservation_list_in_hotel()
class Tester(): hotel1 = Hotel(1, "Rotana", "Amman", 300, 50) hotel12 = Hotel(2, "Royal", "Amman", 250, 35) print hotel1.hotels print hotel1.list_hotels_in_city() customer1 = Customer("Yahya") print customer1.customers reservation1 = Reservation("Rotana", "Yahya", "+962779148786") messeag1 = Notification("confirmation", "+962779148786") print messeag1.send_message() print reservation1.reserve_room() print reservation1.reservation_list_in_hotel()
def read_from_file(filename): with open(filename) as file: list = [] for line in file: line = line.split(",") list.append(Hotel(line[0], int(line[1]), int(line[2]))) return list
def test_FailReservation(self): self.list1 = [] self.list2 = [] self.calendar = Calendar() self.room = Room(2, 2, 60.99) self.list1.append(self.room) self.hotel = Hotel("Test Hotel",self.list1, self.list2, self.calendar) self.cust = self.hotel.add_customer("Matti Mallikas","Abc 1 00000 Helsinki","0440000000","*****@*****.**" ) self.reservation1 = self.hotel.make_reservation(self.cust, "Room", "15.5.2019", "2")
def start_app(): rotana_hotel = Hotel(20, "Rotana", "Abu Dhabi", 200, 40) sheraton_hotel = Hotel(21, "Sheraton", "Abu Dhabi", 300, 100) print Hotel.hotels customer = Customer("name", "0000000000") customer.add_customer("name2", "phone2") print "Customer List : {}".format(customer.customers_list) reservation = Reservation(Hotel.hotels[0][1], Customer.customers_list[0][0]) reservation.add_new_reservation(Hotel.hotels[0][1], Customer.customers_list[0][0]) print "Reservation List: {}".format(reservation.reservation_list) reservation.list_resevrations_for_hotel(Hotel.hotels[0][1])
def __init__(self): self.dateManager = DateManager() self.roomManager = RoomManager() self.hotelRegister = HotelRegister() self.hotels = {} self.nlp = NLProcessor() self.skipOwn = False #skip self message to avoid loop for h in hotel_list.keys(): self.hotels[h] = Hotel(h, 10, 5, 2)
def test_parse_hotels(self): parsed_hotels = parse_hotels('test/test.csv') final_hotels = [Hotel(name='Hotel 1', address='Street 1337', stars=4, contact='Mr. Hotel', phone='0000-0000', uri='https://google.com')] self.assertEqual(parsed_hotels, final_hotels)
def start_app(): #اضافة الفنادق rotana_hotel = Hotel(20, "Rotana", "Abu Dhabi", 200, 40) sheraton_hotel = Hotel(21, "Sheraton", "Abu Dhabi", 300, 100) mercur_hotel = Hotel(19, "Mercure", "Nador", 100, 50) royalhotel = Hotel(1, 'The Royal Hotel', 'Toronto', 200, 30) ryadnador = Hotel(2, 'Hotel RYAD', 'Nador', 200, 1) mercure = Hotel(3, 'Mercure', 'Nador', 200, 10) print "*" * 20 print Hotel.hotels print "*" * 20 print "List hotels in Nador city" print mercure.list_hotels_in_city('Nador') #اضافة الزبناء mounir = Customer('Mounir AL OUALITI') asmae = Customer('Asmae SAKSAK') print "*" * 20 #اضافة الحجوزات reservation2 = Reservation("Hotel RYAD", "Mohamed SAKSAK") reservation1 = Reservation("Hotel RYAD", "Mounir AL OUALITI") reservation2 = Reservation("Hotel RYAD", "Asmae SAKSAK") reservation3 = Reservation("Mercure", "Asmae SAKSAK") reservation4 = Reservation("Mercure", "Mounir AL OUALITI") print "*" * 20 print "List reservations for hotel Mercure" print reservation1.list_reservations_for_hotel('Mercure') print "*" * 20 print "List Hotels" print Hotel.hotels print "*" * 20
def create_hotel(): print("Existing Hotel List") print("==========================================================") hotel_names = [] for hotel in hotel_list: hotel_names.append(hotel.get_hotel_name()) print(hotel.get_hotel_name()) print("===========================================================") hotel_name = input("Enter Hotel Name \n") if hotel_name in hotel_names: print("Hotel already exists") else: hotel_list.append(Hotel(hotel_name))
def test_validate(self): h = Hotel(name='Hotel 1', address='Street 1337', stars=4, contact='Mr. Hotel', phone='0000-0000', uri='https://google.com') self.assertIsNone(h.validate()) h2 = Hotel(name='\u0001', address='Street 1337', stars=4, contact='Mr. Hotel', phone='0000-0000', uri='https://google.com') self.assertEqual(h2.validate(), 'Name not printable (\u0001)') h3 = Hotel(name='Hotel 1', address='Street 1337', stars=-4, contact='Mr. Hotel', phone='0000-0000', uri='https://google.com') self.assertEqual(h3.validate(), 'Stars not between 0 and 5') h4 = Hotel(name='Hotel 1', address='Street 1337', stars=4, contact='Mr. Hotel', phone='0000-0000', uri='google.com') self.assertEqual(h4.validate(), 'URI "google.com" is malformed')
def parse_hotels(cvs_path): """ Parses an UTF-8-encoded CSV file and creates a list of hotels out of it. Any parsing errors will be printed to stdout. :param cvs_path: A file path pointing to a CSV file for parsing hotels. :return: A list with successfully parsed rows (hotels), could also be empty if there are no rows or parsing failed at all. """ hotels = [] try: # Open CSV file with UTF-8 encoding (this also means that ONLY UTF-8 encoded files are accepted) with open(cvs_path, encoding='utf-8') as f: header = None # CSV files can contain empty rows non_empty_rows = (row for row in csv.reader(f) if row) for line, row in enumerate(non_empty_rows): # The first row is the header which specifies the order of the columns if not header: header = row continue try: # Zip column names with the current row and pass as dict to Hotel dataclass constructor, # so that even if the csv columns order change, the Hotel will be created correctly hotel = Hotel(**dict(zip(header, row))) except TypeError: print('[Line {}] Unexpected columns found ({})'.format(line, header)) continue reason = hotel.validate() if reason: print('[Line {}] Invalid hotel found ({})'.format(line, reason)) continue hotels.append(hotel) except UnicodeDecodeError: print('CSV file "{}" is not a valid UTF-8 file'.format(cvs_path)) return hotels
def bulck_update_hotel(self, language, start, finish): hotel_infos = self.hotel_ids[start: finish] params2 = { 'language': self.language[language], 'property_id': hotel_infos, } res2 = requests.get( url=self.base_url + 'properties/content', headers=self.headers, params=params2 ) hotel_res = json.loads(res2.text) for hotel_id in hotel_infos: hotel = Hotel( id=hotel_id, name=hotel_res[hotel_id]['chain']['name'].encode('ascii', 'ignore'), ratings=hotel_res[hotel_id]['ratings']['property']['rating'].encode('ascii', 'ignore'), ) self.hotels.append(hotel)
def get_booking_info(type): from database import Database from guest import Guest from reservations import Reservation from worker import Worker from hotel import Hotel try: if type == "Guest": return Guest() elif type == "Worker": return Worker() elif type == "Reservation": return Reservation() elif type == "Database": return Database() elif type == "Hotel": return Hotel() raise AssertionError("Part not found") except AssertionError as _e: print(_e)
def main(): # Create object of Hotel class obj_hotel = Hotel('MARRIOTT', '1 Amiryan Street, Yerevan 0010 Armenia', '+374-10-599000', 'www.marriott.com') # Create objects of Guest class obj_guest1 = Guest('Armen', 'Hakobian', '*****@*****.**', '091-333-402') obj_guest2 = Guest('Ani', 'Hakobian', '*****@*****.**', '077-587-578') # Create objects of Room class obj_room1 = Room(1, 'Yes', 'Yes', 'No') obj_room2 = Room(2, 'No', 'Yes', 'Yes') obj_room3 = Room(3, 'No', 'Yes', 'No') # Add rooms in Hotel obj_hotel.add_room(obj_room1) obj_hotel.add_room(obj_room2) obj_hotel.add_room(obj_room3) # Book rooms obj_hotel.book_room(obj_guest1) obj_hotel.book_room(obj_guest2) # Print hotel info obj_hotel.print_hotel_info() # Print all rooms info obj_hotel.print_all_rooms() # Print room info with a given number (ex. 2) obj_hotel.print_room_info(2) # Print guest info obj_guest1.get_info() # Print all booked rooms info obj_hotel.print_book_info() # or # Print a booked room info by room number obj_hotel.print_book_info(2)
def start_app(): hotels = [ "Best Western", "Hilton", "Hyatt", "InterContinental", "Radisson", "Sheraton", "Westin" ] cities = [ "New York", "Dubai", "Cairo", "Moscow", "Paris", "London", "Tokyo" ] names = [ "Mohamed", "Ahmed", "Mahoud", "Sad", "Ali", "Kaream", "Hussein", "Omar", "Hazem", "Ibrahim" ] i = 0 while i < 25: try: user = Customer( random.choice(names), random.choice(names), "".join(str(random.randint(0, 9)) for _ in range(10))) hotel = Hotel(random.choice(hotels), random.choice(cities), random.randint(50, 100)) user.add_customer() hotel.add_hotel() i += 1 except ValueError: pass for number in Customer.customers: user = Customer.get_customer(number) print("{} {}: {}".format(user.first_name, user.last_name, user.phone_number)) print("=" * 100) for city in Hotel.hotels: print("=" * 100) print("{}:".format(city)) print(list(Hotel.get_hotels_in_city(city).keys()))
def test_accepts_guest_into_unoccupied_room(): hotel = Hotel() hotel.check_in('Bob Barker', 303) assert(hotel.check_in('Roy Orbison', 305) == True)
def run_simulation(run, value, value_DOW, value_month): ###parameters set_price = 71 gamma = 20 average_number_of_potential_customers = 100 min_budget = 30 capacity = 76 max_lead = 200 ###Weights month_prob = [0.75, 0.8, 0.95, 0.9, 1., 0.95, 0.95, 1., 1., 1., 1.1, 1.2] dow_prob = [1, 1, 1, 1, 1, 1, 0.7] gamma_weights = [ 1.1, 0.8, 1.2, 1.1, 0.6, 1.1, 1.2, 0.9, 0.7, 1.0, 0.9, 0.9 ] gamma_weights_dow = [1.05, 1.05, 1.05, 1.05, 0.9, 0.95, 0.8] ###Start/End date start_reserved_night_date = dt.datetime(2018, 1, 1) end_reserved_night_date = dt.datetime(2018, 12, 30) ###Define Hotel. (Doesn't do much now, but in future will have multiple merchants/room types) hotel = Hotel(merchant_id=1, capacities={10: capacity}, available_rooms=[10]) #Initial prices for each DOW prices = { 10: { 0: set_price, 1: set_price, 2: set_price, 3: set_price, 4: set_price, 5: set_price, 6: set_price }, } ###Open and write first line of output files """with open("transformed_data.csv", "w") as data: writer = csv.writer(data, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) writer.writerow(['hotelroom_id','reserved_night_date','booking_datetime','type','price']) person_data=open("person_data.csv", "w") pers_writer = csv.writer(person_data, delimiter=',', quotechar='"',quoting=csv.QUOTE_MINIMAL) pers_writer.writerow(['booking_datetime','price'])""" ###Call revenue manager (currently very simple) lead_rm = RLRevenueManager( prices=prices, hotel=hotel, start_reserved_night_date=start_reserved_night_date, end_reserved_night_date=end_reserved_night_date) start_date = start_reserved_night_date end_date = end_reserved_night_date ### initialise number of customers, budget and interested date market = Market(start_reserved_night_date=start_reserved_night_date, end_reserved_night_date=end_reserved_night_date, average_number_of_potential_customers= average_number_of_potential_customers, min_budget=min_budget, gamma=gamma, gamma_weights_months=gamma_weights, gamma_weights_dow=gamma_weights_dow, month_prob=month_prob, dow_prob=dow_prob, capacity=capacity, state=value, value_DOW=value_DOW, value_month=value_month) #market.initialize_market() ### iterate over days maximum_wtps = {} for delta in range((end_date - start_date).days): reserved_night_date = start_date + dt.timedelta(days=delta) #print("Processing", reserved_night_date) person_np = market._create_persons(reserved_night_date) #,pers_writer) #person_np[:,6]==delta #print(person_np[:,6],delta) lead_rm = market.generate_bookings_for_reserved_night_date( reserved_night_date, lead_rm, person_np, run) print('Total Visits', np.sum(market.state[:, 1])) #More output writing """bookings= np.array([[0,dt.datetime(2018,1,1),0]]*len(lead_rm._current_bookings)) bookings[:,0] = lead_rm._current_bookings[:,2] bookings[:,1] = lead_rm._current_bookings[:,0] bookings[:,2] = lead_rm._current_bookings[:,1] df= pd.DataFrame(data=bookings) df.columns=['hotelroom_id','reserved_night_date','units'] df.to_csv('transformed_room_nights.csv',index=False) person_data.close()""" return lead_rm._revenue, market.state, market.value_DOW, market.value_month
def get_data(self): soup = BeautifulSoup(self.html,'html.parser') # 获取景点 days = soup.find_all('div',class_ = 'daily_itinerary_item') for i in range(len(days)): days[i] = str(days[i]) soup = BeautifulSoup(days[i],'html.parser') tables = soup.find_all('div',class_="daily_itinerary_sub_info") if tables != []: for tag in tables: if tag.find(text = '景点') != None or tag.find(text = '自由活动') != None: pattern = re.compile(r'<a class="itinerary_sce_name">(.*?)</a>') name = pattern.findall(str(tag)) for n in range(len(name)): name[n] = re.sub('\(.*\)','',name[n]) name[n] = re.sub('\(.*\)','',name[n]) if self.flag: print('开始爬取:',name[n],'的酒店') self.jiudian = Hotel(self.city_string,name[n]) path = 'hotel\\'+self.city_string+'.csv' for j in range(len(self.jiudian.hotels)): if os.path.exists(path): hotels = pd.read_csv(path,index_col=0) else: hotels = pd.DataFrame(columns=('house_id','name','price','description','url')) if hotels[(hotels.name==self.jiudian.hotels[j])].empty: index = len(hotels) self.data_list.append(int(self.city_id*1000+index)) hotel = pd.DataFrame({'house_id':[self.city_id*1000+index],'name':[self.jiudian.hotels[j]],'price':[self.jiudian.prices[j]],'description':[self.jiudian.descriptions[j]],'url':[self.jiudian.urls[j]]}) hotels = pd.concat([hotels,hotel],ignore_index=True,axis=0) else: self.data_list.append(int(self.city_id*1000 + hotels[(hotels.name==self.jiudian.hotels[j])].index[0])) hotels.to_csv(path,encoding = 'UTF-8') self.flag = 0 # 查看是否存在 path = 'place\\'+self.city_string+'.csv' if os.path.exists(path): places = pd.read_csv(path,index_col=0) else: places = pd.DataFrame(columns=('spot_id','name','price','description','picurl')) if places[(places.name==name[n])].empty: # 获取价格 print('开始获取:',name[n],'的价格') price = Jingdian(name[n]).price print('开始获取:',name[n],'的介绍和图片') # 获取评论 c = Comment(name[n]) comment = c.comment pic = c.pic_url index = len(places) self.data_list.append([i+1,self.city_id*1000+index]) place = pd.DataFrame({'spot_id':[self.city_id*1000+index],'name':[name[n]],'price':[price],'description':[comment],'picurl':[pic]}) places = pd.concat([places,place],ignore_index=True,axis=0) places.to_csv(path,encoding = 'UTF-8') else: index = places[places.name==name[n]].index[0] index = index self.data_list.append([i+1,self.city_id*1000+index]) places.to_csv(path)
def start_app(): rotana_hotel = Hotel(20, "Rotana", "Abu Dhabi", 200, 40) sheraton_hotel = Hotel(21, "Sheraton", "Abu Dhabi", 300, 100) print Hotel.hotels print rotana_hotel.list_hotels_in_city()
def test_does_not_accept_guest_in_occupied_room(): hotel = Hotel() hotel.check_in('Bob Barker', 303) assert(hotel.check_in('Roy Orbison', 303) == False)
def test_check_in_a_guest(): hotel = Hotel() hotel.check_in('Bob Barker', 302) assert(('Bob Barker' in hotel.guests()) == True)
def test_check_out_a_guest_releases_room(): hotel = Hotel() hotel.check_in('Jim Maui', 301) hotel.check_out('Jim Maui')
def test_check_out_a_guest(): hotel = Hotel() hotel.check_in('Bob Dylan', 306) hotel.check_out('Bob Dylan') assert(('Bob Dylan' in hotel.guests()) == False)
def check_available(self, region, check_in, check_out, language='Chinese', adults='1', childs_age=[], rooms_amount='1'): if self.region != region: self.getHotels(region=region, language=language) if not (self.check_in == check_in and self.check_out == check_out and self.region == region and self.rooms_amount == rooms_amount and self.adults == self.adults): self.adults = self.adults self.childs_age = childs_age self.rooms_amount = rooms_amount self.check_in = check_in self.check_out = check_out if not childs_age: occupancy = [adults] else: occupancy = [adults + '-'] child = ','.join(childs_age) occupancy[0] += child if int(rooms_amount) > 1: occupancy.append(rooms_amount) params = { 'language': self.language[language], 'checkin': self.check_in, 'checkout': self.check_out, 'currency': 'USD', 'country_code': self.country_code, 'sales_channel': 'website', 'sales_environment': 'hotel_only', 'sort_type': 'preferred', 'rate_plan_count': 1, 'occupancy': occupancy } # bulck request for all rooms api limits 250 i = 0 while i + 200 < len(self.hotel_ids): self.bulck_update(params, i, i + 200) self.bulck_update(params, i, len(self.hotel_ids)) self.hotel_ids = self.avail_rooms.keys() # paginations for hotels if self.start <= len(self.hotels): self.end = min(self.start + 10, len(self.hotel_ids)) hotel_infos = self.hotel_ids[self.start:self.end] params2 = { 'language': self.language[language], 'property_id': hotel_infos, } res2 = requests.get(url=self.base_url + 'properties/content', headers=self.headers, params=params2) hotel_res = json.loads(res2.text) for hotel_id in hotel_infos: hotel = Hotel( id=hotel_id, name=hotel_res[hotel_id]['chain']['name'].encode( 'ascii', 'ignore'), ratings=hotel_res[hotel_id]['ratings']['property'] ['rating'].encode('ascii', 'ignore'), ) print hotel.name, hotel.ratings, hotel_id self.hotels.append(hotel) else: self.end = min(self.start + 10, len(self.hotels)) return self.hotels[self.start:self.end]
def main(): rooms = [] services = [] calendar = Calendar() #Resources.csv tiedostosta luetaan hotellin tiedot ja alustetaan hotelli. try: file = open("resources.csv", "r") for row in file: row = row.rstrip() splitted = row.split(",") if splitted[0] == "Resources": pass if splitted[0] == "Name": hotel_name = splitted[1] if splitted[0] == "Room": room_number = splitted[1] number_of_beds = splitted[2] room_price = splitted[3] room = Room(room_number, number_of_beds, room_price) rooms.append(room) if splitted[0] == "Service": service_name = splitted[1] service_duration = splitted[3] service_price = splitted[2] service = Service(service_name, service_price, service_duration) services.append(service) except OSError: print("Resource file is broken") file.close() #Hotelli luodaan keksityn csv-tiedoston pohjalta hotel1 = Hotel(hotel_name, rooms, services, calendar) try: load_info = open("customers.csv", "r") for event in load_info: if event == "": break elif event == "\n" or len(event) < 4: pass else: event.rstrip() list = event.split(",") name = list[0].strip(" ") adress = list[1] number = list[2] email = list[3].rstrip() if len(list) == 4 and "Spa" not in list[0] and "City-tour" not in list[0]: hotel1.import_customer(name, adress, number, email) if len(list) == 4 and ("Spa" in list[0] or "City-tour" in list[0]): cust_name = list[1] date = list[2] persons = list[3] hotel1.import_service(name, cust_name, date, persons) if len(list) == 7: rnumber = list[4].strip(" ").split(" ")[2] date = list[5].strip(" ") duration = list[6].split(" ")[0] hotel1.import_reservation_history(name, adress, rnumber, date, duration) except OSError: print("Customer file is broken") load_info.close() global app app = QApplication(sys.argv) MainWindow = QMainWindow() ui = Ui_MainWindow() ui.setupUi(MainWindow, hotel1) MainWindow.show() sys.exit(app.exec_())
def driversStr(self): out_str = '' for i in self._drivers: out_str += str(i) + '\n' return out_str def bookingsStr(self): out_str = '' for i in self._bookings: out_str += str(i) + '\n' return out_str if __name__ == '__main__': t_service_0 = TransportServices() drivers = {"Alan": "A1111", "Betty": "B2222", "Charlie": "C3333"} for item in drivers: t_service_0.addDriver(Driver(item, drivers[item])) hotels = { 'Zenite': 'One Road P111', 'Young Lodge': '2, Two Road P222' } for item in hotels: t_service_0.addHotel(Hotel(item, hotels[item])) for i in range(2): t_service_0.addBooking( Booking(datetime.datetime(2019, 12, i + 1, 12 - int(3**i), 45), True, t_service_0._hotels[0], 4 - int(3 * i))) print(t_service_0.bookingsStr()) print(t_service_0.hotelsStr()) print(t_service_0.driversStr())
def InitApp(): hotelsInfo = LoadHotelsData() indexer = Indexer() for i, name in enumerate(hotelsInfo.keys()): hotelsEngines[name] = Hotel(indexer, name, hotelsInfo[name], i)
from hotel import Hotel from customer import Customer if __name__ == "__main__": hotel1 = Hotel("Mariotte", "682024", 5, 3, 2000, 3000, 4000, 1000) # Menu print("\t\t\tMENU\n\t1. Book Rooms\n\t2. Vaccate Rooms\n\t3. Exit") while True: choice = int(input("\n\tEnter your choice: ")) if choice == 1: name = input("\n\tEnter your Name: ") print(f'\n\t\tRooms Available') hotel1.rooms_available() single, double, triple = map( int, input( "\tEnter Number of Single/Double/Triple Rooms(Space Seperated): " ).split()) if hotel1.check_available(single, double, triple): ac = input("\tDo you wish to have AC(Y/N): ") if ac == 'y' or 'Y': ac = True else: ac = False days = int(input("\tEnter Number of Days: ")) customer_obj = Customer(name, single, double, triple, ac, days) hotel1.book_room(customer_obj) customer_obj.print_bill() else: