master
parent
7b173d9bc1
commit
b336a3973d
@ -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
|
Loading…
Reference in new issue