class UI:
    def __init__(self,services) -> None:
        self.services=services
    
    def __call__(self):
        while True:
            print("""
            1.Add address
            2.Display all addresses
            3.Determine where to put taxi stations
            4.Determine coordinates
            5.Exit
            """)
            command=input(">")
            match command:
                case "1":
                    try:
                        id=input("Input an id:")
                        name=input("Input a name:")
                        number=input("Input a number:")
                        x=input("Input an x coordinate:")
                        y=input("Input an y coordinate:")
                        self.services.add_address(id,name,number,x,y)
                    except Exception as e:
                        print(e)
                case "2":
                    print(self.services.get_addresses())
                case "3":
                    try:
                        x=input("Input an x coordinate:")
                        y=input("Input an y coordinate:")
                        distance=input("Input a distance:")
                        addresses=self.services.get_distance(x,y,distance)
                        for address, distance in addresses:
                            print(str(address)+" "+str(distance)+"\n")
                    except Exception as e:
                        print(e)               
                case "4":
                    try:
                        coordinates=self.services.get_coordinates()
                        print("Coordinates: "+str(coordinates[0])+" "+str(coordinates[1]))
                    except Exception as e:
                        print(e)
                case "5":
                    return
                case _:
                    print("Invalid command")
