示例#1
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(99, 36);
            RiceCookerInfo RCInfo = new RiceCookerInfo(10000, 5000);
            SoundPlayer    Sound  = new SoundPlayer();

            string[] MenuItem = { "  power  ", "  Lid  ", "  Cooking  ", "  Warming  ", "  Cancel  ", "  Quatity  ",
                                  "  Rice  ",  "  Water  " };

            while (true)
            {
                OutFrame();
                RiceBox(16, 11);
                Cover(RCInfo.CoverOpenClose);
                RiceInfo(RCInfo);
                PowerLine(RCInfo.Power);
                RiceHeight(50, 2, RCInfo.Rice);
                WaterHeight(72, 2, RCInfo.Water);

                Menu(65, 25, MenuItem);
                if (MainMenuIndex == 9)
                {
                    break;
                }

                switch (MainMenuIndex)
                {
                case 0:     //power
                    RCInfo.Power = !RCInfo.Power;
                    if (RCInfo.Power)
                    {
                        Sound.SoundLocation = "Power_on.wav";
                    }
                    else
                    {
                        Sound.SoundLocation = "power_off.wav";
                    }
                    Sound.Load();
                    Sound.Play();
                    break;

                case 1:     //뚜껑, 취사 중에 뚜겅이 열리면 안된다.
                    if (RCInfo.State == CookerProcess.Cooking)
                    {
                        MessageBox(51, 27, "Lid can't be open while cooking");
                        Console.ReadKey(true);
                    }
                    else
                    {
                        RCInfo.CoverOpenClose = !RCInfo.CoverOpenClose;
                        if (RCInfo.CoverOpenClose)
                        {
                            Sound.SoundLocation = "cover_open.wav";
                        }
                        else
                        {
                            Sound.SoundLocation = "cover_close.wav";
                        }
                        Sound.Load();
                        Sound.Play();
                    }
                    break;

                case 2:     //취사
                    if (!RCInfo.Power)
                    {
                        MessageBox(51, 27, "Power is Off");
                        Console.ReadKey(true);
                        break;
                    }
                    if (RCInfo.CoverOpenClose)
                    {
                        MessageBox(51, 27, "Lid is Open");
                        Console.ReadKey(true);
                        break;
                    }
                    if (RCInfo.Number == 0)
                    {
                        MessageBox(51, 27, "Enter the Quantity");
                        Console.ReadKey(true);
                        break;
                    }

                    int Rice = RCInfo.Rice - (RCInfo.Number * 160);
                    if (Rice < 0)
                    {
                        MessageBox(51, 27, " ???Rice not enough");
                        Sound.SoundLocation = "Put more rice.wav";
                        Sound.Load();
                        Sound.Play();
                        Console.ReadKey(true);
                        break;
                    }

                    int Water;
                    Water = RCInfo.Water - (RCInfo.Number * 170) * 5;
                    if (Water < 0)
                    {
                        MessageBox(51, 27, " ???Water is not enough");
                        Sound.SoundLocation = "Put more water.wav";
                        Sound.Load();
                        Sound.Play();
                        Console.ReadKey(true);
                        break;
                    }

                    RCInfo.State = CookerProcess.Riceing;
                    RiceInfo(RCInfo);

                    Sound.SoundLocation = "Putting Rice.wav";
                    Sound.Load();
                    Sound.Play();

                    Console.SetCursorPosition(24, 12);
                    Console.Write("Adding Rice");
                    Console.SetCursorPosition(18, 13);
                    Console.Write("Θ Θ Θ Θ Θ Θ Θ");
                    Console.SetCursorPosition(18, 14);
                    Console.Write("Θ Θ Θ Θ Θ Θ Θ");
                    Console.SetCursorPosition(18, 15);
                    Console.Write("Θ Θ Θ Θ Θ Θ Θ");
                    Console.SetCursorPosition(18, 16);
                    Console.Write("Θ Θ Θ Θ Θ Θ Θ");
                    Console.SetCursorPosition(18, 17);
                    Console.Write("Θ Θ Θ Θ Θ Θ Θ");
                    RCInfo.Rice = RCInfo.Rice - (RCInfo.Number * 160);
                    RiceHeight(50, 2, RCInfo.Rice);
                    Thread.Sleep(3000);

                    for (int i = 0; i < 2; i++)
                    {
                        RCInfo.State = CookerProcess.Watering;
                        RCInfo.Water = RCInfo.Water - (RCInfo.Number * 170 * 2);
                        RiceInfo(RCInfo);


                        Sound.SoundLocation = "Water_in.wav";
                        Sound.Load();
                        Sound.Play();

                        Console.BackgroundColor = ConsoleColor.Black;
                        Console.SetCursorPosition(24, 12);
                        Console.Write("Adding Rice");
                        Console.BackgroundColor = ConsoleColor.Blue;
                        Console.SetCursorPosition(18, 13);
                        Console.Write("Θ Θ Θ Θ Θ Θ Θ");
                        Console.SetCursorPosition(18, 14);
                        Console.Write("Θ Θ Θ Θ Θ Θ Θ");
                        Console.SetCursorPosition(18, 15);
                        Console.Write("Θ Θ Θ Θ Θ Θ Θ");
                        Console.SetCursorPosition(18, 16);
                        Console.Write("Θ Θ Θ Θ Θ Θ Θ");
                        Console.SetCursorPosition(18, 17);
                        Console.Write("Θ Θ Θ Θ Θ Θ Θ");
                        WaterHeight(74, 2, RCInfo.Water);
                        Thread.Sleep(3000);

                        Sound.SoundLocation = "Washing Rice.wav";
                        Sound.Load();
                        Sound.Play();
                        RCInfo.State = CookerProcess.Washing;
                        RiceInfo(RCInfo);

                        Console.BackgroundColor = ConsoleColor.Black;
                        Console.SetCursorPosition(24, 12);
                        Console.Write("Adding Rice");
                        Console.BackgroundColor = ConsoleColor.Blue;
                        Console.SetCursorPosition(18, 13);
                        Console.Write("~ ~ ~ ~ ~ ~ ~");
                        Console.SetCursorPosition(18, 14);
                        Console.Write("Θ Θ Θ Θ Θ Θ Θ");
                        Console.SetCursorPosition(18, 15);
                        Console.Write("~ ~ ~ ~ ~ ~ ~");
                        Console.SetCursorPosition(18, 16);
                        Console.Write("Θ Θ Θ Θ Θ Θ Θ");
                        Console.SetCursorPosition(18, 17);
                        Console.Write("~ ~ ~ ~ ~ ~ ~");
                        Thread.Sleep(3000);

                        RCInfo.State = CookerProcess.Droping;
                        RiceInfo(RCInfo);

                        Sound.SoundLocation = "water_out.wav";
                        Sound.Load();
                        Sound.Play();

                        Console.BackgroundColor = ConsoleColor.Black;
                        Console.SetCursorPosition(24, 12);
                        Console.Write(" Droping water");
                        for (int j = 0; j < 5; j++)
                        {
                            Console.BackgroundColor = ConsoleColor.Black;
                            for (int k = 0; k < j; k++)
                            {
                                Console.SetCursorPosition(18, 13 + k);
                                Console.Write("Θ Θ Θ Θ Θ Θ Θ");
                            }

                            Console.BackgroundColor = ConsoleColor.Blue;
                            for (int k = j; k < 5; k++)
                            {
                                Console.SetCursorPosition(18, 13 + k);
                                Console.Write("Θ Θ Θ Θ Θ Θ Θ");
                            }
                            Thread.Sleep(700);
                        }
                    }

                    // Note: 취사용 물 공급
                    RCInfo.Water = RCInfo.Water - (RCInfo.Number * 170);
                    WaterHeight(74, 2, RCInfo.Water);
                    RiceInfo(RCInfo);

                    // Note: 취사 시작
                    RCInfo.State = CookerProcess.Cooking;
                    RiceInfo(RCInfo);

                    Sound.SoundLocation = "rice.wav";
                    Sound.Load();
                    Sound.Play();

                    Console.BackgroundColor = ConsoleColor.Black;
                    Console.SetCursorPosition(24, 12);
                    Console.Write("취사 중");
                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.SetCursorPosition(18, 13);
                    Console.Write("⊙ ⊙ ⊙ ⊙ ⊙ ⊙ ⊙");
                    Console.SetCursorPosition(18, 14);
                    Console.Write("⊙ ⊙ ⊙ ⊙ ⊙ ⊙ ⊙");
                    Console.SetCursorPosition(18, 15);
                    Console.Write("⊙ ⊙ ⊙ ⊙ ⊙ ⊙ ⊙");
                    Console.SetCursorPosition(18, 16);
                    Console.Write("⊙ ⊙ ⊙ ⊙ ⊙ ⊙ ⊙");
                    Console.SetCursorPosition(18, 17);
                    Console.Write("⊙ ⊙ ⊙ ⊙ ⊙ ⊙ ⊙");
                    Thread.Sleep(7000);     // 7초 정도

                    // Note: 완료 , 사운드 삐리릭...
                    RCInfo.State = CookerProcess.Completion;
                    RiceInfo(RCInfo);
                    Sound.SoundLocation = "Ring10.wav";
                    Sound.Load();
                    Sound.Play();
                    Thread.Sleep(7000);     // 3초 정도

                    Sound.SoundLocation = "밥완료.wav";
                    Sound.Load();
                    Sound.Play();

                    Console.SetCursorPosition(24, 12);
                    Console.Write("취사 완료");
                    Thread.Sleep(3000);     // 3초 정도

                    // Note: 보온
                    RCInfo.State = CookerProcess.Keeping;
                    RiceInfo(RCInfo);

                    Sound.SoundLocation = "맛있게드세요.wav";
                    Sound.Load();
                    Sound.Play();

                    Console.BackgroundColor = ConsoleColor.Black;
                    Console.SetCursorPosition(24, 12);
                    Console.Write("보온 중  ");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.SetCursorPosition(18, 13);
                    Console.Write("⊙ ⊙ ⊙ ⊙ ⊙ ⊙ ⊙");
                    Console.SetCursorPosition(18, 14);
                    Console.Write("⊙ ⊙ ⊙ ⊙ ⊙ ⊙ ⊙");
                    Console.SetCursorPosition(18, 15);
                    Console.Write("⊙ ⊙ ⊙ ⊙ ⊙ ⊙ ⊙");
                    Console.SetCursorPosition(18, 16);
                    Console.Write("⊙ ⊙ ⊙ ⊙ ⊙ ⊙ ⊙");
                    Console.SetCursorPosition(18, 17);
                    Console.Write("⊙ ⊙ ⊙ ⊙ ⊙ ⊙ ⊙");
                    Thread.Sleep(3000);     // 3초 정도
                    Console.ForegroundColor = ConsoleColor.White;

                    RCInfo.Number = 0;     // Note: 인원수 초기화
                    break;

                case 3:     // Note:보온
                    if (!RCInfo.Power)
                    {
                        // 밧데리로 일부 메시지 전달
                        MessageBox(51, 27, "전원이 꺼져 있습니다");
                        Console.ReadKey(true);
                        break;
                    }

                    RCInfo.State = CookerProcess.Keeping;
                    RiceInfo(RCInfo);
                    break;

                case 4:     // 취소
                    RCInfo.State = CookerProcess.None;
                    RiceInfo(RCInfo);
                    break;

                case 5:     // 인원수
                    if (!RCInfo.Power)
                    {
                        // 밧데리로 일부 메시지 전달
                        MessageBox(51, 27, "전원이 꺼져 있습니다");
                        Console.ReadKey(true);
                        break;
                    }

                    MessageBox(51, 27, " 식사할 인원 수 : ");
                    try
                    {
                        RCInfo.Number = int.Parse(Console.ReadLine());
                    }
                    catch (Exception e)
                    {
                        RCInfo.Number = 0;
                    }
                    break;

                case 6:     // 쌀통 설정
                {
                    string Message = "현재 쌀의 양(kg) : " + (RCInfo.Rice / 1000);
                    MessageBox(51, 27, Message);
                    Console.SetCursorPosition(63, 29);
                    Console.Write("추가할 쌀 양(kg) : ");
                    string Amount = Console.ReadLine();
                    try
                    {
                        RCInfo.Rice += int.Parse(Amount) * 1000; // kg 단위
                        if (RCInfo.Rice > 18000)                 // 18kg 최대
                        {
                            RCInfo.Rice -= int.Parse(Amount) * 1000;
                            MessageBox(51, 27, "양이 너무 많습니다");
                            Console.ReadKey(true);
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        break;
                    }
                }
                break;

                case 7:     // 뭍통 설정
                {
                    string Message = "현재 물의 양(리터) : " + (RCInfo.Water / 1000);
                    MessageBox(51, 27, Message);
                    string Amount = string.Empty;
                    Console.SetCursorPosition(63, 29);
                    Console.Write("추가할 물의 양(리터) : ");
                    Amount = Console.ReadLine();
                    try
                    {
                        RCInfo.Water += int.Parse(Amount) * 1000;         // 리터를 밀리리터로
                        if (RCInfo.Water > 18000)
                        {
                            RCInfo.Water -= int.Parse(Amount) * 1000;
                            MessageBox(51, 27, "양이 너무 많습니다");
                            Console.ReadKey(true);
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        break;
                    }
                }
                break;


                    //RCInfo.Water = RCInfo.Water - (RCInfo.Number * 170);
                    //WaterHeight(74, 2, RCInfo.Water);
                    //RiceInfo(RCInfo);
                }
            }
        }
示例#2
0
        static void RiceInfo(RiceCookerInfo Info)
        {
            Console.BackgroundColor = ConsoleColor.Black;
            Console.SetCursorPosition(3, 25);
            if (Info.Power)
            {
                Console.Write("Power Status : On");
            }
            else
            {
                Console.Write("Power Status : Off");
            }

            Console.SetCursorPosition(3, 26);
            if (Info.CoverOpenClose)
            {
                Console.Write("Lid is Open");
            }
            else
            {
                Console.Write("Lie is closed");
            }

            Console.SetCursorPosition(3, 27);
            switch (Info.State)
            {
            case CookerProcess.None:
                Console.Write("Rice Cooker Status : Standby");
                break;

            case CookerProcess.Riceing:
                Console.Write("Rice Cooker Status : Rice is putting");
                break;

            case CookerProcess.Watering:
                Console.Write("Rice Cooker Status : Water is putting on");
                break;

            case CookerProcess.Washing:
                Console.Write("Rice Cooker Status : Rice is being washed");
                break;

            case CookerProcess.Droping:
                Console.Write("Rice Cooker Status : Water is being off");
                break;

            case CookerProcess.Cooking:
                Console.Write("Rice Cooker Status : Rice is being cooked");
                break;

            case CookerProcess.Completion:
                Console.Write("Rice Cooker Status : Rice Completed");
                break;

            case CookerProcess.Keeping:
                Console.Write("Rice Cooker Status : Rice is kept warming");
                break;
            }

            Console.SetCursorPosition(3, 28);
            Console.Write("Quantity : {0}", Info.Number);
            Console.SetCursorPosition(3, 29);
            Console.Write("Rice Status : {0:f1} Kg", Info.Rice / 1000.0f);
            Console.SetCursorPosition(3, 30);
            Console.Write("Water Status : {0:f1} Litre", Info.Water / 1000.0f);
        }