Exemple #1
0
        public void DisplayMenu2()
        {
            bool quit = false;

            UserLib.OutputHeading("      Derek's News Daily");

            string[] choices = new string[]
            {
                "Add Message", "Add Photo", "Display All", "Quit"
            };

            do
            {
                int choice = UserLib.SelectChoice(choices);

                switch (choice)
                {
                case 1: AddMessage(); break;

                case 2: AddPhoto(); break;

                case 3: Display(); break;

                case 4: quit = true; break;
                }
            } while (!quit);
        }
Exemple #2
0
        private void RemovePost()
        {
            DisplayTitle("Removing a Post");

            Post post = SelectPost();

            string[] choices  = { "Remove", "Quit" };
            int      choiceNo = UserLib.SelectChoice(choices);

            if (choiceNo == 1)
            {
                news.RemovePost(post);
            }

            news.DisplaySummary();
        }
Exemple #3
0
        /// <summary>
        /// Display a menu of distance units and then prompt the
        /// user to select one and return it.
        /// </summary>
        private DistanceUnit SelectUnit(string prompt)
        {
            string[] choices = { $" {DistanceUnit.Feet}",
                                 $" {DistanceUnit.Metres}",
                                 $" {DistanceUnit.Miles}" };

            Console.WriteLine(prompt);
            int choice = UserLib.SelectChoice(choices);

            DistanceUnit unit;

            if (choice == 1)
            {
                unit = DistanceUnit.Feet;
            }
            else if (choice == 2)
            {
                unit = DistanceUnit.Metres;
            }
            else if (choice == 3)
            {
                unit = DistanceUnit.Miles;
            }
            else
            {
                unit = DistanceUnit.NoUnit;
            }

            Console.WriteLine($" You have selected {unit}");
            Console.WriteLine();

            // Alternative to the if..else

            //switch (choice)
            //{
            //    case "1": unit = DistanceUnit.Feet; break;
            //    case "2": unit = DistanceUnit.Metres; break;
            //    case "3": unit = DistanceUnit.Miles; break;

            //    default: unit = "INVALID CHOICE"; break;
            //}

            return(unit);
        }
Exemple #4
0
        public void DisplayMenu()
        {
            bool quit = false;

            UserLib.OutputHeading("      Derek's News Daily");

            string[] choices = new string[]
            {
                "Add Message", "Add Photo", "Add Comment",
                "Display All", "Display by Author", "Display by Date",
                "Like/Unlike", "Remove Post", "Quit"
            };

            do
            {
                int choice = UserLib.SelectChoice(choices);

                switch (choice)
                {
                case 1: AddMessage(); break;

                case 2: AddPhoto(); break;

                case 3: AddComment(); break;

                case 4: Display(); break;

                case 5: DisplayByAuthor(); break;

                case 6: DisplayByDate(); break;

                case 7: LikePost(); break;

                case 8: RemovePost(); break;

                case 9: quit = true; break;

                default:
                    break;
                }
            } while (!quit);
        }
Exemple #5
0
        private void LikePost()
        {
            DisplayTitle("Liking or Unliking Post");

            Post post = SelectPost();

            string[] choices  = { "Like", "Unlike", "Quit" };
            int      choiceNo = UserLib.SelectChoice(choices);

            if (choiceNo == 1)
            {
                post.Like();
            }
            else if (choiceNo == 2)
            {
                post.Unlike();
            }

            post.Display();
        }
Exemple #6
0
        public static void Main()
        {
            UserLib.OutputHeading(" C# Console Applications 2020");

            string [] choices =
            {
                "App01: Distance Converter", "App02: BMI Calculator",
                "App03: Student Grades",     "App04: Network",
                "App05: RPS Game",           "Quit"
            };

            int choiceNo = UserLib.SelectChoice(choices);

            if (choiceNo == 1)
            {
                DistanceConverter15 converter = new DistanceConverter15();
                converter.ConvertDistance();
            }
            else if (choiceNo == 2)
            {
                BMI bmi = new BMI();
                bmi.CalculateIndex();
            }
            else if (choiceNo == 3)
            {
                StudentGrades app = new StudentGrades();
                app.OutputMenu();
            }
            else if (choiceNo == 4)
            {
                NetworkUI network = new NetworkUI();
                network.DisplayMenu();
            }
            else if (choiceNo == 5)
            {
                GameView view = new GameView();

                view.PlayGame();
            }
        }