diff --git a/2.py b/2.py new file mode 100644 index 0000000..f325d86 --- /dev/null +++ b/2.py @@ -0,0 +1,36 @@ +import tkinter as tk +from tkinter import messagebox +from datetime import datetime + +class Room: + def __init__(self, room_number, room_type, rate, availability=True): + self.room_number = room_number + self.room_type = room_type + self.rate = rate + self.availability = availability + +class Reservation: + def __init__(self, room, start_date, end_date): + self.room = room + self.start_date = start_date + self.end_date = end_date + self.total_cost = self.calculate_total_cost() + + def calculate_total_cost(self): + days = (self.end_date - self.start_date).days + 1 + return days * self.room.rate + +class Hotel: + def __init__(self, name): + self.name = name + self.rooms = [] + self.reservations = [] + + def add_room(self, room): + self.rooms.append(room) + + def check_availability(self, start_date, end_date): + available_rooms = [r for r in self.rooms if r.availability and + not any((start_date <= res.start_date <= end_date or start_date <= res.end_date <= end_date) + for res in self.reservations if res.room == r)] + return available_rooms \ No newline at end of file