Пример #1
0
        /// <summary>
        /// returns an instance of JanitorDroid based of the prompts
        /// </summary>
        /// <returns></returns>
        public static new Droid CreateDroid()
        {
            bool   toolBoxTmp, computerConnectionTmp, armTmp, vacuumTmp, trashCompactorTmp;
            string material, color;

            Console.WriteLine("Please input the droids material");
            material = Console.ReadLine();

            Console.WriteLine("Please input the droids color");
            color = Console.ReadLine();

            Console.WriteLine("has a toolbox? (y/n)");
            toolBoxTmp = Droid.yesOrNo();

            Console.WriteLine("has a computer connection? (y/n)");
            computerConnectionTmp = Droid.yesOrNo();

            Console.WriteLine("has a arm? (y/n)");
            armTmp = Droid.yesOrNo();

            Console.WriteLine("has a vacuum? (y/n)");
            vacuumTmp = Droid.yesOrNo();

            Console.WriteLine("has a trash compactor? (y/n)");
            trashCompactorTmp = Droid.yesOrNo();

            return(new JanitorDroid(material, color, toolBoxTmp, computerConnectionTmp, armTmp, trashCompactorTmp, vacuumTmp));
        }
Пример #2
0
        /// <summary>
        /// returns an instance of AstromechDroid based of the prompts
        /// </summary>
        /// <returns></returns>
        public static new Droid CreateDroid()
        {
            bool   toolBoxTmp, computerConnectionTmp, armTmp, fireExtinquisherTmp;
            string material, color;
            int    shipsSupportedTmp;

            Console.WriteLine("Please input the droids material");
            material = Console.ReadLine();

            Console.WriteLine("Please input the droids color");
            color = Console.ReadLine();

            Console.WriteLine("has a toolbox? (y/n)");
            toolBoxTmp = Droid.yesOrNo();

            Console.WriteLine("has a computer connection? (y/n)");
            computerConnectionTmp = Droid.yesOrNo();

            Console.WriteLine("has a arm? (y/n)");
            armTmp = Droid.yesOrNo();

            Console.WriteLine("has a fireExtinquisher? (y/n)");
            fireExtinquisherTmp = Droid.yesOrNo();

            Console.WriteLine("number of supported ships");
            //prevents bad input
            while (!int.TryParse(Console.ReadLine(), out shipsSupportedTmp))
            {
                //deletes bad input from the console
                int currentLineInt = Console.CursorTop - 1;
                Console.SetCursorPosition(0, Console.CursorTop - 1);
                Console.Write(new string(' ', Console.WindowWidth));
                Console.SetCursorPosition(0, currentLineInt);
            }

            return(new AstromechDroid(material, color, toolBoxTmp, computerConnectionTmp, armTmp, fireExtinquisherTmp, shipsSupportedTmp));
        }