from controller import Controller
from repository import Repository
from ui import UI
import random
from datetime import date,timedelta

last_names=["Smith","Adam","Barbu","Munteanu","Dinu","Popescu","Ionescu","Vasile","Cirlea","Enache"]
first_names=["John","George","Maria","Ana","Ioana","Daniel","Gabriel","Alexandru","Vlad","Arthur"]

def generate_data(n):
    reservations=[]
    current_date= date(2023, 1, 1)
    rooms=[]
    with open("room_types.txt") as f:
        for line in f:
            rooms.append(line.strip().split(","))
    i=1
    while(i<=n):
        departure_date=current_date + timedelta(random.randint(0,1))
        for j in range(1,random.randint(2,3)+1):
            if i>n:
                break
            last_name=random.choice(last_names)
            first_name=random.choice(first_names)
            room=rooms[j-1]
            reservations.append([str(i),last_name,first_name,room[0],room[1],str(current_date),str(departure_date)])
            i+=1
        current_date=departure_date
    
    with open("data.txt","w") as f:
        for reservation in reservations:
            f.write(",".join(reservation)+"\n")



def main():
    repo = Repository("data.txt")
    controller = Controller(repo)
    ui = UI(controller)
    ui.start()

if __name__ == "__main__":
    main()