Esempio n. 1
0
        static void DisplayAddSkis(List <Skis> skis)
        {
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Red;

            bool validResponse = false;

            Skis newSkis = new Skis();

            DisplayScreenHeader("Add Skis");

            do
            {
                validResponse = false;
                Console.Write("\tBrand: ");
                newSkis.Brand = Console.ReadLine();
                if (newSkis.Brand == "")
                {
                    Console.WriteLine("Please enter a Brand");
                }
                else
                {
                    validResponse = true;
                }
            } while (!validResponse);

            do
            {
                Console.Write("\tLength: ");

                if (!int.TryParse(Console.ReadLine(), out int length))
                {
                    Console.WriteLine("Please enter a valid length");
                }
                else
                {
                    if (length <= 0)
                    {
                        Console.WriteLine("Please enter a positive value");
                    }
                    else
                    {
                        validResponse  = true;
                        newSkis.Length = length;
                    }
                }
            } while (!validResponse);

            Console.WriteLine();
            Console.WriteLine("\tNew Ski Properties");
            Console.WriteLine("\t-------------");
            SkiInfo(newSkis);
            Console.WriteLine("\t-------------");


            DisplayContinuePrompt();
            skis.Add(newSkis);
        }
Esempio n. 2
0
        static void DisplayDeleteSkis(List <Skis> skis)
        {
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.DarkGreen;

            DisplayScreenHeader("Delete Skis");


            Console.WriteLine("\tSki Brands");
            Console.WriteLine("\t-------------");
            foreach (Skis ski in skis)
            {
                Console.WriteLine("\t" + ski.Brand);
            }

            Console.WriteLine();
            Console.Write("\tEnter Brand:");
            string skiBrand = Console.ReadLine();

            Skis selectedSki = null;

            foreach (Skis ski in skis)
            {
                if (ski.Brand == skiBrand)
                {
                    selectedSki = ski;
                    break;
                }
            }

            if (selectedSki != null)
            {
                skis.Remove(selectedSki);
                Console.WriteLine();
                Console.WriteLine($"\t{selectedSki.Brand} deleted");
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine($"\t{skiBrand} not found");
            }


            DisplayContinuePrompt();
        }
Esempio n. 3
0
        static void DisplaySkiDetail(List <Skis> skis)
        {
            Console.BackgroundColor = ConsoleColor.Red;
            Console.ForegroundColor = ConsoleColor.White;

            DisplayScreenHeader("Ski Detail");

            Console.WriteLine("\tSki Brands");
            Console.WriteLine("\t-------------");
            foreach (Skis ski in skis)
            {
                Console.WriteLine("\t" + ski.Brand);
            }


            Console.WriteLine();
            Console.Write("\tEnter Brand:");
            string skiBrand = Console.ReadLine().ToLower();

            Skis selectedSkis = null;

            foreach (Skis ski in skis)
            {
                if (ski.Brand == skiBrand)
                {
                    selectedSkis = ski;
                    break;
                }
            }

            Console.WriteLine();
            Console.WriteLine("\t*********************");
            SkiInfo(selectedSkis);
            Console.WriteLine("\t*********************");

            DisplayContinuePrompt();
        }
Esempio n. 4
0
 static void SkiInfo(Skis skis)
 {
     Console.WriteLine($"\tBrand: {skis.Brand}");
     Console.WriteLine($"\tAge: {skis.Length}");
 }
Esempio n. 5
0
        static void DisplayUpdateSkis(List <Skis> skis)
        {
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Blue;

            bool validResponse = false;
            Skis selectedSki   = null;

            do
            {
                DisplayScreenHeader("Update Skis");

                Console.WriteLine("\tSki Brands");
                Console.WriteLine("\t-------------");
                foreach (Skis ski in skis)
                {
                    Console.WriteLine("\t" + ski.Brand);
                }

                Console.WriteLine();
                Console.Write("\tEnter Brand:");
                string skiBrand = Console.ReadLine().ToLower();


                foreach (Skis ski in skis)
                {
                    if (ski.Brand == skiBrand)
                    {
                        selectedSki   = ski;
                        validResponse = true;
                        break;
                    }
                }

                if (!validResponse)
                {
                    Console.WriteLine("\tPlease select a correct Brand.");
                    DisplayContinuePrompt();
                }
            } while (!validResponse);

            string userResponse;

            Console.WriteLine();
            Console.WriteLine("\tReady to Update. [Press Enter to keep the current info]");
            Console.WriteLine();

            do
            {
                validResponse = false;
                Console.Write($"\tCurrent Brand: {selectedSki.Brand} New Brand: ");
                userResponse = Console.ReadLine();

                if (userResponse == "")
                {
                    Console.WriteLine("Please Enter a Valid Brand");
                }
                else
                {
                    validResponse     = true;
                    selectedSki.Brand = userResponse;
                }
            } while (!validResponse);

            do
            {
                validResponse = false;
                Console.Write($"\tCurrent Length: {selectedSki.Length} New Length: ");
                userResponse = Console.ReadLine();

                if (userResponse == "" || !int.TryParse(userResponse, out int length))
                {
                    Console.WriteLine("Please Try Again");
                }
                else
                {
                    if (length <= 0)
                    {
                        Console.WriteLine("Please enter a positive value");
                    }
                    else
                    {
                        validResponse      = true;
                        selectedSki.Length = length;
                    }
                }
            } while (!validResponse);

            Console.WriteLine();
            Console.WriteLine("\tNew Ski Properties");
            Console.WriteLine("\t-------------");
            SkiInfo(selectedSki);
            Console.WriteLine();
            Console.WriteLine("\t-------------");

            DisplayContinuePrompt();
        }