from view.menu_choices import *
from model.boat import BoatTypes
from model.member import EditMember


class Console:
    """
    The view class Console.
    """

    def __init__(self, registry):
        self.__registry = registry

    def display_app_menu(self):
        for choice in Menu:
            print('%d\t%s' % (choice.value, choice.name))

    @staticmethod
    def display_welcome_message():
        print('-----------------------------------')
        print('---- Started the MVC Registry -----')
        print('-----------------------------------')

    def list_members_compact(self):
        print('\nName\t\tPersonal Number\t\tMember ID\t\tNumber of Boats')

        for i in self.__registry.get_member_data():
            print('%s\t\t%s\t\t%s\t\t%d' % (
                i.get_name(), i.get_personal_number(),
                i.get_member_id(), i.get_number_of_boats()
            ))
        print('\n')

    def list_members_verbose(self):
        for x in self.__registry.get_member_data():
            print('\n%s\t\t%s\t\t%s\t\t%d' % (x.get_name(), x.get_personal_number(), x.get_member_id(), x.get_number_of_boats()))
            print('\tBoat ID\t\tName\t\tType\t\tLength')
            for j in x.get_boats():
                print('\t%s\t\t%s\t\t%s\t\t%d' % (j.get_boat_id(), j.get_name(),
                                                  j.get_type().name, j.get_length()))
        print('\n')

    def register_member(self):
        name_input = input('Enter Name: ')
        personal_number_input = input('Enter Personal Number: ')
        self.__registry.register_member(name_input, personal_number_input)

    def register_boat(self):
        input_owner_id = input('Enter Member ID: ')
        name_input = input('Enter Boat Name: ')
        length_input = int(input('Enter New Length: '))

        for c in BoatTypes:
            print('%d\t%s' % (c.value, c.name))

        choice = int(input('\nChoice: '))
        type_input = BoatTypes(choice)

        self.__registry.register_boat(input_owner_id, name_input, type_input, length_input)

    def delete_member(self):
        member_id = input('Enter Member ID: ')

        self.__registry.delete_member(member_id)

    def delete_boat(self):
        input_id = input('Enter Boat ID: ')

        self.__registry.delete_boat(input_id)

    def edit_member(self):
        running = True

        input_member_id = input('Enter Member ID: ')

        member = self.__registry.get_member(input_member_id)

        input_member_name = member.get_name()
        input_member_personal_number = member.get_personal_number()

        while running:
            for c in EditMember:
                print('%d\t%s' % (c.value, c.name))

            choice = int(input('\nChoice: '))

            if choice == EditMember.NAME.value:
                input_member_name = input('Enter New Member Name: ')
            elif choice == EditMember.PERSONAL_NUMBER.value:
                input_member_personal_number = input('Enter New Personal Number: ')
            elif choice == EditMember.MAIN_MENU.value:
                running = False

            self.__registry.edit_member(input_member_id, input_member_name, input_member_personal_number)

    def edit_boat(self):
        running = True

        input_boat_id = input('Enter Boat ID: ')

        boat = self.__registry.get_boat(input_boat_id)

        input_boat_name = boat.get_name()
        input_boat_type = boat.get_type()
        input_boat_length = boat.get_length()

        while running:
            for c in BoatMenu:
                print('%d\t%s' % (c.value, c.name))

            choice = int(input('\nChoice: '))

            if choice == BoatMenu.NAME.value:
                input_boat_name = input('Enter New Boat Name: ')
            elif choice == BoatMenu.TYPE.value:
                for bt in BoatTypes:
                    print('%d\t%s' % (bt.value, bt.name))
                input_boat_type = int(input('Enter Boat Type: '))
            elif choice == BoatMenu.LENGTH.value:
                input_boat_length = int(input('Enter Boat Length: '))
            elif choice == BoatMenu.MAIN_MENU.value:
                running = False

            self.__registry.edit_boat(input_boat_id, input_boat_name, input_boat_type, input_boat_length)

    def view_member(self):
        input_id = input('Enter Member ID: ')

        member = self.__registry.get_member(input_id)

        print('\nName: %s\nPersonal Number: %s\nMember ID: %s\nNumber of Boats: %d' % (
            member.get_name(),
            member.get_personal_number(),
            member.get_member_id(),
            len(member.get_boats())
        ))

from view.menu_choices import *
from model.boat import BoatTypes
from model.member import EditMember


class Console:
    """
    The view class Console.
    """

    def __init__(self, registry):
        self.__registry = registry

    def display_app_menu(self):
        for choice in Menu:
            print('%d\t%s' % (choice.value, choice.name))

    @staticmethod
    def display_welcome_message():
        print('-----------------------------------')
        print('---- Started the MVC Registry -----')
        print('-----------------------------------')

    def list_members_compact(self):
        print('\nName\t\tPersonal Number\t\tMember ID\t\tNumber of Boats')

        for i in self.__registry.get_member_data():
            print('%s\t\t%s\t\t%s\t\t%d' % (
                i.get_name(), i.get_personal_number(),
                i.get_member_id(), i.get_number_of_boats()
            ))
        print('\n')

    def list_members_verbose(self):
        for x in self.__registry.get_member_data():
            print('\n%s\t\t%s\t\t%s\t\t%d' % (x.get_name(), x.get_personal_number(), x.get_member_id(), x.get_number_of_boats()))
            print('\tBoat ID\t\tName\t\tType\t\tLength')
            for j in x.get_boats():
                print('\t%s\t\t%s\t\t%s\t\t%d' % (j.get_boat_id(), j.get_name(),
                                                  j.get_type().name, j.get_length()))
        print('\n')

    def register_member(self):
        name_input = input('Enter Name: ')
        personal_number_input = input('Enter Personal Number: ')
        self.__registry.register_member(name_input, personal_number_input)

    def register_boat(self):
        input_owner_id = input('Enter Member ID: ')
        name_input = input('Enter Boat Name: ')
        length_input = int(input('Enter New Length: '))

        for c in BoatTypes:
            print('%d\t%s' % (c.value, c.name))

        choice = int(input('\nChoice: '))
        type_input = BoatTypes(choice)

        self.__registry.register_boat(input_owner_id, name_input, type_input, length_input)

    def delete_member(self):
        member_id = input('Enter Member ID: ')

        self.__registry.delete_member(member_id)

    def delete_boat(self):
        input_id = input('Enter Boat ID: ')

        self.__registry.delete_boat(input_id)

    def edit_member(self):
        running = True

        input_member_id = input('Enter Member ID: ')

        member = self.__registry.get_member(input_member_id)

        input_member_name = member.get_name()
        input_member_personal_number = member.get_personal_number()

        while running:
            for c in EditMember:
                print('%d\t%s' % (c.value, c.name))

            choice = int(input('\nChoice: '))

            if choice == EditMember.NAME.value:
                input_member_name = input('Enter New Member Name: ')
            elif choice == EditMember.PERSONAL_NUMBER.value:
                input_member_personal_number = input('Enter New Personal Number: ')
            elif choice == EditMember.MAIN_MENU.value:
                running = False

            self.__registry.edit_member(input_member_id, input_member_name, input_member_personal_number)

    def edit_boat(self):
        running = True

        input_boat_id = input('Enter Boat ID: ')

        boat = self.__registry.get_boat(input_boat_id)

        input_boat_name = boat.get_name()
        input_boat_type = boat.get_type()
        input_boat_length = boat.get_length()

        while running:
            for c in BoatMenu:
                print('%d\t%s' % (c.value, c.name))

            choice = int(input('\nChoice: '))

            if choice == BoatMenu.NAME.value:
                input_boat_name = input('Enter New Boat Name: ')
            elif choice == BoatMenu.TYPE.value:
                for bt in BoatTypes:
                    print('%d\t%s' % (bt.value, bt.name))
                input_boat_type = int(input('Enter Boat Type: '))
            elif choice == BoatMenu.LENGTH.value:
                input_boat_length = int(input('Enter Boat Length: '))
            elif choice == BoatMenu.MAIN_MENU.value:
                running = False

            self.__registry.edit_boat(input_boat_id, input_boat_name, input_boat_type, input_boat_length)

    def view_member(self):
        input_id = input('Enter Member ID: ')

        member = self.__registry.get_member(input_id)

        print('\nName: %s\nPersonal Number: %s\nMember ID: %s\nNumber of Boats: %d' % (
            member.get_name(),
            member.get_personal_number(),
            member.get_member_id(),
            len(member.get_boats())
        ))

The view class Console.