Пример #1
0
        static void Main(string[] args)
        {
            //ToSTring()를 오버라이드 해서 폰 매니저해서 사용해보기
            PhoneBookManager manager  = new PhoneBookManager("오버워치", "감자튀김");
            PhoneBookManager manager2 = new PhoneBookManager("유튜브", "피자");

            manager.ReadSerial();
            Console.WriteLine(manager.ToString());
            Console.WriteLine(manager2.ToString());

            while (true)
            {
                manager.ShowMenu();
                int choice = int.Parse(Console.ReadLine());

                switch (choice)
                {
                case 1: manager.InputData(); break;

                case 2: manager.ListData(); break;

                case 3: manager.SearchData(); break;

                case 4: manager.DeleteData(); break;

                case 5:
                    Console.WriteLine("프로그램을 종료합니다."); manager.SaveSerial();
                    return;
                }
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            PhoneBookManager manager = PhoneBookManager.CreateInstance();

            manager.ReadSerial();

            while (true)
            {
                manager.ShowMenu();
                int choice = int.Parse(Console.ReadLine());

                switch (choice)
                {
                case 1: manager.InputData(); break;

                case 2: manager.ListData(); break;

                case 3: manager.SearchData(); break;

                case 4: manager.DeleteData(); break;

                case 5:
                    Console.WriteLine("프로그램을 종료합니다."); manager.SaveSerial();
                    return;
                }
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            PhoneBookManager manager = PhoneBookManager.CreateInstance();


            while (true)
            {
                try
                {
                    int choice;
                    while (true)
                    {
                        manager.ShowMenu();
                        if (int.TryParse(Console.ReadLine(), out choice))
                        {
                            if (choice < 1 || choice > 6)
                            {
                                throw new MenuChoiceException(choice);
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            throw new Exception("1~6까지의 숫자를 입력하세요");
                        }
                    }

                    switch (choice)
                    {
                    case 1: manager.InputData(); break;

                    case 2: manager.ListData(); break;

                    case 3: manager.SearchData(); break;

                    case 4: manager.SortData(); break;

                    case 5: manager.DeleteData(); break;

                    case 6: Console.WriteLine("프로그램을 종료합니다"); return;

                    default:
                        Console.WriteLine("다시 선택하세요"); break;
                    }
                }
                catch (MenuChoiceException err)
                {
                    err.ShowWrongChoice();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            PhoneBookManager manager = PhoneBookManager.CreateManagerInstance(); //폰북매니저에 생성자를 만들어놓지않아 기본생성자를 호출하는것이였음

            //manager.ReadToFile();
            while (true)
            {
                try
                {
                    int choice;
                    while (true)
                    {
                        manager.ShowMenu();
                        if (int.TryParse(Console.ReadLine(), out choice))
                        {
                            if (choice < 1 || choice > 6)
                            {
                                throw new MenuChoiceException(choice);
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    switch (choice)
                    {
                    case 1: manager.InputData(); break;

                    case 2: manager.ListData(); break;

                    case 3: manager.SearchData(); break;

                    case 4: manager.SortData(); break;

                    case 5: manager.DeleteData(); break;

                    case 6: manager.WriteToFile();
                        Console.WriteLine("프로그램을 종료합니다"); return;
                    }
                }
                catch (MenuChoiceException err)
                {
                    err.ShowWrongChoice();
                }
                catch (Exception err)
                {
                    Console.WriteLine(err.Message);
                }
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            PhoneBookManager manager = PhoneBookManager.SingleTon();

            manager.PrintText();    //파일에 저장된 데이터 호출(파일이 있을 경우)
            int select;

            while (true)
            {
                manager.error[2] = true;
                while (manager.error[2])
                {
                    manager.ShowMenu();
                    try
                    {
                        select = int.Parse(Console.ReadLine());
                        switch (select)
                        {
                        case 1: manager.InputData(); manager.error[2] = false; break;

                        case 2: manager.ListData(); manager.error[2] = false; break;

                        case 3: manager.SearchData(); manager.error[2] = false; break;

                        case 4: manager.DeleteData(); manager.error[2] = false; break;

                        case 5: Console.WriteLine("\n프로그램을 종료합니다."); manager.SaveText(); return;

                        default: manager.ErrorList(); break;
                        }
                    }
                    catch (Exception err)
                    {
                        Console.WriteLine(err.Message);
                    }
                }
            }
        }
Пример #6
0
        static void Main(string[] args)
        {
            PhoneBookManager manager = new PhoneBookManager();

            while (true)
            {
                manager.ShowMenu();
                int choice = Utility.ConvertInt(Console.ReadLine());

                switch (choice)
                {
                case 1: manager.InputData(); break;

                case 2: manager.ListData(); break;

                case 3: manager.SearchData(); break;

                case 4: manager.DeleteData(); break;

                case 5: Console.WriteLine("프로그램을 종료합니다."); return;
                }
            }
        }
Пример #7
0
        static void Main(string[] args)
        {
            PhoneBookManager manager = PhoneBookManager.CreatInstance();

            manager.LoadData();

            while (true)
            {
                try
                {
                    manager.ShowMenu();
                    int choice = int.Parse(Console.ReadLine());

                    switch (choice)
                    {
                    case 1: manager.InputData(); break;

                    case 2: manager.ListData(); break;

                    case 3: manager.SearchData(); break;

                    case 4: manager.DeleteData(); break;

                    case 5: manager.SortDate(); break;

                    case 6: manager.SaveData(); Console.WriteLine("프로그램을 종료합니다"); return;
                    }
                }

                catch (Exception err)
                {
                    Console.WriteLine(err.Message);
                    Console.WriteLine();
                }
            }
        }
Пример #8
0
        static void Main(string[] args)
        {
            PhoneBookManager manager = PhoneBookManager.CreateManagerInstance();

            while (true)
            {
                try
                {
                    manager.ShowMenu();
                    int choice = int.Parse(Console.ReadLine());
                    if (choice < 1 || choice > 6)
                    {
                        throw new MenuChoiceException("1~6번 사이의 메뉴를 선택하세요.");
                        //throw new Exception("1~6번 사이의 메뉴를 선택하세요.");
                    }
                    switch (choice)
                    {
                    case 1: manager.InputData(); break;

                    case 2: manager.ListData(); break;

                    case 3: manager.SearchData(); break;

                    case 4: manager.SortData(); break;

                    case 5: manager.DeleteData(); break;

                    case 6: Console.WriteLine("프로그램을 종료합니다."); return;
                    }
                }
                catch (Exception err)
                {
                    Console.WriteLine("오류발생 - " + err.Message);
                }
            }
        }