Exemplo n.º 1
0
        /// <summary>
        /// Task 4.1
        /// This method repeatedly displays a small menu to the user so that they
        /// can test that the DistanceConverter can convert
        /// an entered number of miles into feet, or the number of feet
        /// into miles.
        /// </summary>
        private static void TestDistanceConverter()
        {
            T41_DistanceConverter converter = new T41_DistanceConverter();

            string[] choices =
            {
                "1. Convert Miles to Feet",
                "2. Convert Feet to Miles",
                "3. Quit Program"
            };

            int choice = 0;

            do
            {
                SimpleIO.WriteTitle("Distance Converter", "Task 4.1");

                choice = SimpleIO.GetChoice(choices);

                if (choice == 1)
                {
                    double miles = converter.GetNumber("Miles");
                    double feet  = converter.ToFeet(miles);

                    Console.WriteLine("No of Feet = " + feet);
                }
                else if (choice == 2)
                {
                    double feet  = converter.GetNumber("Feet");
                    double miles = converter.ToMiles(feet);

                    Console.WriteLine("No of Miles = " + miles);
                }
            } while (choice != 3);
        }
Exemplo n.º 2
0
        /// <summary>
        /// A simple room booking system
        /// </summary>
        private static void TestMotelBooking()
        {
            T56_BatesMotel motel = new T56_BatesMotel();

            SimpleIO.WriteTitle("The Bates Motel", "Task 5.6");

            string[] choices =
            {
                "1. Book a Room",
                "2. Vacate a Room",
                "3. Display All Rooms",
                "4. Vacate All Rooms",
                "5. Quit"
            };

            int choice = SimpleIO.GetChoice(choices);

            switch (choice)
            {
            case 1: motel.Book(1, 2);
                break;

            default:
                break;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Task 4.2
        /// This method tests the Book class which asks the user
        /// to enter a set of attributes that will be used to create
        /// a horror story or, use default settings for the story
        /// </summary>
        private static void TestBook()
        {
            T42_Book book = new T42_Book();

            string[] choices =
            {
                "1. Get Details",
                "2. Use Defaults"
            };

            int choice = SimpleIO.GetChoice(choices);

            if (choice == 1)
            {
                book.GetDetails();
            }

            book.WriteChapter1();
            book.WriteChapter2();
        }