示例#1
0
        //Menu Option Desk
        public static void Desk()
        {
            Clear();
            WriteLine("\n There are some things on the desk...a book, a box and some papers.. ");
            WriteLine(" What do you wanna do?\n");
            WriteLine(" 1) Look closer at the book");
            WriteLine(" 2) Look closer at the box");
            WriteLine(" 3) Look closer at the papers");
            WriteLine(" 4) Open the drawer");
            WriteLine(" 5) Go back");
            WriteLine(" 6) Open BackPack\n");

            bool input = true;

            do
            {
                string menuChoice = ReadLine();
                switch (menuChoice)
                {
                case "1":
                    Book();
                    break;

                case "2":
                    SafetyLocker();
                    break;

                case "3":
                    Papers();
                    break;

                case "4":
                    Clear();
                    //Checking for object in both the backpack and the usedObject-file
                    string type = "Light-bulb";
                    if (foundObjects.CheckForObject(type) || foundObjects.CheckForUsedObject(type))
                    {
                        WriteLine("\n The drawer is empty");
                        ReadLine();
                        Desk();
                    }
                    else
                    {
                        //If not found the new object is saved to JSON-file
                        WriteLine("\n There's a light-bulb, could be useful! Let's put it in the backpack.");
                        ReadLine();
                        if (foundObjects.AddObject("Light-bulb", "Gives light when paired together with a lamp", "BathroomLamp"))
                        {
                            Desk();
                        }
                        else
                        {
                            //Handeling error
                            WriteLine(" Couldn't save item to backpack");
                            ReadLine();
                            Desk();
                        }
                    }
                    break;

                case "5":
                    basement.BasementView();
                    break;

                case "6":
                    //Opening Backpack and handeling response
                    string backpackResponse = foundObjects.OpenBackpack();
                    if (backpackResponse == "back")
                    {
                        basement.BasementView();
                    }
                    else
                    {
                        WriteLine("\n Naahh...that didn't work");
                        ReadLine();
                        basement.BasementView();
                    }
                    break;

                default:
                    WriteLine("\n What are you trying to do? That's not a correct input Try again..");
                    input = false;
                    break;
                }
            } while (input == false);
        }