示例#1
0
        //Modifiys Tiket values
        public static void ModifiyTiketList(ref List <Tiket> UsersTikets, Tiket Tiket, bool b)
        {
            //Flag if the operation was complete
            bool flag = false;

            //Loops through the useres tiket to find aduplicate tiket
            for (int i = 0; i < UsersTikets.Count; i++)
            {
                //If they are the same tiket type
                if (Tiket.Name == UsersTikets[i].Name)
                {
                    //Sets the flag to true;
                    flag = true;
                    //Modifiys tiket amounts
                    UsersTikets[i].Amount += Tiket.Amount;
                    //If there are less than 1 tiket in the selkection
                    //remove it
                    if (UsersTikets[i].Amount < 1)
                    {
                        UsersTikets.RemoveAt(i);
                    }
                    break;
                }
            }
            //If the operation was not complet complet and the operation was to add a tiket
            if (!flag & b)
            {
                UsersTikets.Add(Tiket);
            }
        }
示例#2
0
        //Alows the user to remove a tiket
        public static void RemoveTiket(ref List <Tiket> UT)
        {
            Console.WriteLine("Select A tiket to remove");
            //Prints the tikets that have already been purchesed
            PrintTiketInfomation(UT, true);
            //Gets the user input
            string tempInput = Console.ReadLine();

            //Loop for the user to remove tikets
            while (true)
            {
                //Test to see if the user can use the input
                int input = canUseNumber(tempInput);
                //if the tiket option is valid
                if (input >= 0 && input < UT.Count)
                {
                    Tiket t = new Tiket(UT[input].Name, UT[input].Amount);
                    Console.WriteLine("You have slected a " + UT[input].Name + " tiket" + "\n" + "You curently have " + UT[input].Amount + ".\n" + "How many would you like to remove?");
                    //Gets the users input
                    tempInput = Console.ReadLine();
                    while (true)
                    {
                        //Test to see if the user can use the input
                        float amount = canUseNumber(tempInput);
                        //If the user has ented a valid amount of tikets
                        if (amount > 0)
                        {
                            //Changes the amount
                            t.Amount  = amount;
                            t.Amount *= -1;
                            //Modifiys the list
                            ModifiyTiketList(ref UT, t, true);
                            Console.WriteLine("\nHere is your curent order.\n");
                            PrintTiketInfomation(UT, true);
                            break;
                        }
                        else
                        {
                            Console.WriteLine("Invalid selection");
                            Console.WriteLine("Enter a valid option ot type exit to retyrn");
                            tempInput = Console.ReadLine();
                            Console.WriteLine(tempInput);
                            if (tempInput == "exit")
                            {
                                break;
                            }
                        }
                    }
                }
                //Invalid option
                else
                {
                    Console.WriteLine("Invalid selection");
                }
                //If there are not tikets in the basket
                if (UT.Count < 1)
                {
                    break;
                }
                Console.WriteLine("\nEnter a another type of tiekt to remove\nor type exit to return\n");
                tempInput = Console.ReadLine();
                if (tempInput == "exit")
                {
                    break;
                }
            }
        }
示例#3
0
        //Alows the user to purches a tiket
        public static void BuyTiket(ref List <Tiket> UT, List <Tiket> LT)
        {
            //Shows tiket prices
            Console.WriteLine("Select A tiket to purchesed");
            PrintTiketInfomation(LT, false);
            //Alows the uset to select a tiket
            Console.WriteLine("Type a number to select a tiket");
            //Gets the user input
            string tempInput = Console.ReadLine();

            //loops until no more tikets are needed
            while (true)
            {
                //Test to see if the user can use the input
                int input = canUseNumber(tempInput);
                //if the tiket option is valid
                if (input >= 0 && input < LT.Count)
                {
                    //Tempery tiket
                    Tiket t = new Tiket(LT[input].Name, LT[input].Price);
                    Console.WriteLine("You have slected a " + t.Name + " tiket" + "\n" + "Select how many are needed");
                    //Gets the users input
                    tempInput = Console.ReadLine();
                    //Loop for the userts input
                    while (true)
                    {
                        //Test to see if the user can use the input
                        float amount = canUseNumber(tempInput);
                        //If the user has ented a valid amount of tikets
                        if (amount >= 0)
                        {
                            //Changes the amount
                            t.Amount = amount;
                            ModifiyTiketList(ref UT, t, true);
                            Console.WriteLine("\nHere is your curent order.\n");
                            PrintTiketInfomation(UT, true);
                            break;
                        }
                        else
                        {
                            Console.WriteLine("Invalid selection");
                            Console.WriteLine("Enter a valid option ot type exit to retyrn");
                            tempInput = Console.ReadLine();
                            Console.WriteLine(tempInput);
                            if (tempInput == "exit")
                            {
                                break;
                            }
                        }
                    }
                }
                //invalid option
                else
                {
                    Console.WriteLine("Invalid selection");
                }
                Console.WriteLine("\nEnter a another type of tiekt\nor type exit to return\n");
                tempInput = Console.ReadLine();
                if (tempInput == "exit")
                {
                    break;
                }
            }
        }