コード例 #1
0
        //Non-Preferred customer transaction method
        public static void CustomerItemPurchaseNotPreferred(List <NonPreferredCustomer> inputList, int index, string input)
        {
            bool    loop = false;
            decimal purchasePrice;
            NonPreferredCustomer notPreferredTransaction = new NonPreferredCustomer();

            Console.WriteLine(StandardMessages.DisplayNotPreferredCustomerMessage());
            notPreferredTransaction.CustomerStatus = false;

            do
            {
                //Get users purchase price
                Console.Write("Enter purchase price ==> ");
                input = Console.ReadLine();
                //Determine if user inputs a number or character
                if (decimal.TryParse(input, out purchasePrice))
                {
                    notPreferredTransaction.PurchaseAmount    = purchasePrice;
                    notPreferredTransaction.TransactionNumber = notPreferredTransaction.TransactionNumber + index;
                    inputList.Add(notPreferredTransaction);
                    DisplayCustomerTransaction.DisplayNonPreferredTransaction(purchasePrice);
                    Console.WriteLine(StandardMessages.DisplayEnterMessage());
                    Console.ReadLine();
                    loop = true;
                }
                else
                {
                    //If user enters anything other than a number display invalid input.
                    Console.WriteLine(StandardMessages.DisplayInvalidChoice());
                    Console.ReadLine();
                }
            } while (loop == false);
        }
コード例 #2
0
        public static void BuildACustomer(List <Customer> inputList, bool loop, string input)
        {
            //Clear current screen
            Console.Clear();
            //Create customer object
            Customer output = new Customer();

            Console.WriteLine(StandardMessages.EnterCustomerInformationTitle());
            //Get customer name
            Console.Write(StandardMessages.EnterCustomerName());
            output.Name = Console.ReadLine();
            //Get customer ID#
            Console.Write(StandardMessages.EnterCustomerIDNumber());
            output.CustomerNumber = Console.ReadLine();
            //Get customer address
            Console.Write(StandardMessages.EnterCustomerAddress());
            output.Address = Console.ReadLine();
            //Get customer phone number
            Console.Write(StandardMessages.EnterCustomerPhoneNumber());
            output.PhoneNumber = Console.ReadLine();

            do
            {
                //Get customers mailing preference
                Console.Write("Do you wish to be on the mailing list yes/no? ==> ");
                input = Console.ReadLine().ToLower();
                //Decision structure for mailing preference
                if (input == "yes" || input == "y")
                {
                    output.MailingListOption = true;
                    loop = true;
                }
                else if (input == "no" || input == "n")
                {
                    output.MailingListOption = false;
                    loop = true;
                }
                else
                {
                    Console.WriteLine(StandardMessages.DisplayInvalidChoice());
                    Console.ReadLine();
                }
            } while (loop == false);

            inputList.Add(output);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: orengoa0459/CSC-153
        static void Main(string[] args)
        {
            //Setinel to control loop
            bool menuLoop = false;
            //Get input from user
            string input;

            //Create objects
            RetailItemLibrary.Items jackets = new RetailItemLibrary.Items("Jackets", 12, 59.05m);
            RetailItemLibrary.Items jeans   = new RetailItemLibrary.Items("Jeans", 40, 34.95m);
            RetailItemLibrary.Items shirts  = new RetailItemLibrary.Items("Shirts", 20, 24.95m);
            do
            {
                //Displays main menu
                Console.Write(StandardMessages.DisplayMainMenu());
                //Controls the process flow of the menu
                input = Console.ReadLine();
                switch (input)
                {
                case "1":
                    //Display retail items list
                    Console.WriteLine("\n\n*Retail Item List*");
                    Console.WriteLine(StandardMessages.DisplayRetailItems(jackets.Description, jackets.UnitsOnHand, jackets.Price));
                    Console.WriteLine(StandardMessages.DisplayRetailItems(jeans.Description, jeans.UnitsOnHand, jeans.Price));
                    Console.WriteLine(StandardMessages.DisplayRetailItems(shirts.Description, shirts.UnitsOnHand, shirts.Price));
                    Console.WriteLine(StandardMessages.ReturnToMainMenu());
                    Console.ReadLine();
                    break;

                case "2":
                    //Exit main program
                    menuLoop = true;
                    break;

                default:
                    //Displays invalid choice
                    Console.WriteLine(StandardMessages.DisplayInvalidChoice());
                    Console.WriteLine(StandardMessages.ReturnToMainMenu());
                    Console.ReadLine();
                    break;
                }
                //Clears current screen
                Console.Clear();
            } while (menuLoop == false);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            //Set loop sentinel
            bool   menuLoop = false;
            string input;
            //Store customer information in list
            List <Customer> customer = new List <Customer>();

            do
            {
                //Main menu
                Console.WriteLine(StandardMessages.DisplayCreateCustomerMenu());
                input = Console.ReadLine();
                switch (input)
                {
                case "1":
                    //Build customer by entering information
                    BuildCustomer.BuildACustomer(customer, menuLoop, input);

                    break;

                case "2":
                    //Displays customer information
                    DisplayCustomerInfo.DisplayCustomerInformation(customer);
                    break;

                case "3":
                    menuLoop = true;;
                    break;

                default:
                    //Displays invalid selection
                    Console.WriteLine(StandardMessages.DisplayInvalidChoice());
                    Console.ReadLine();
                    break;
                }
                //Clears screen
                Console.Clear();
            } while (menuLoop == false);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            //Set loop sentinels
            bool   mainProgramLoop   = false;
            bool   preferredMenuLoop = false;
            string input;
            //Set index to track number of  non-preferred customer transactions.
            int index = 1;

            //Store preferred and non-preferred customer information in lists
            List <PreferredCustomer>    customer             = new List <PreferredCustomer>();
            List <NonPreferredCustomer> nonPreferredCustomer = new List <NonPreferredCustomer>();

            Console.WriteLine(StandardMessages.DisplayProgramInstructions());
            Console.ReadLine();
            Console.Clear();
            do
            {
                //Display main program menu
                Console.WriteLine(StandardMessages.DisplayMainMenu());
                //get input from user
                input = Console.ReadLine();
                switch (input)
                {
                case "1":
                    //Build preferred customer and complete customer transaction
                    BuildCustomer.BuildACustomer(customer, preferredMenuLoop, input);
                    CustomerTransaction.CustomerItemPurchasePreferred(customer, input, preferredMenuLoop);
                    break;

                case "2":
                    //Complete non-preferred customer transaction
                    CustomerTransaction.CustomerItemPurchaseNotPreferred(nonPreferredCustomer, index, input);
                    index++;
                    break;

                case "3":
                    //Display all preferred customers for the day
                    DisplayCustomerInfo.DisplayPreferredCustomerInformation(customer);

                    break;

                case "4":
                    //Display all non-preferred customer **Transactions** for the day
                    DisplayCustomerInfo.DisplayNotPreferredCustomerInformation(nonPreferredCustomer);

                    break;

                case "5":
                    //Exits program
                    mainProgramLoop = true;

                    break;

                default:
                    //Display for invalid selection
                    Console.WriteLine(StandardMessages.DisplayInvalidChoice());
                    break;
                }
                Console.Clear();
            } while (mainProgramLoop == false);
        }
コード例 #6
0
        //Preferred customer transaction method
        public static void CustomerItemPurchasePreferred(List <PreferredCustomer> inputList, string input, bool loop)
        {
            decimal           purchasePrice;
            decimal           discountPrice;
            PreferredCustomer transaction = new PreferredCustomer();

            transaction.PurchaseAmount = 0.0m;
            do
            {
                //Get input from user and validate if user inputs a number or character
                Console.Write("Enter total purchase ==> ");
                input = Console.ReadLine();
                decimal.TryParse(input, out purchasePrice);
                if (decimal.TryParse(input, out purchasePrice) && purchasePrice <= 499.99m && purchasePrice >= 0)
                {
                    transaction.DiscountLevel  = 0m;
                    discountPrice              = purchasePrice * transaction.DiscountLevel;
                    purchasePrice              = purchasePrice - discountPrice;
                    transaction.PurchaseAmount = purchasePrice;
                    Console.WriteLine("\n**Sorry! No discount for this transaction.**");
                    //Display reciept
                    DisplayCustomerTransaction.DisplayPreferredTransaction(transaction.PurchaseAmount, transaction.DiscountLevel, discountPrice);
                    loop = true;
                }
                else if (decimal.TryParse(input, out purchasePrice) && purchasePrice >= 500.00m && purchasePrice <= 999.99m)
                {
                    transaction.DiscountLevel  = .05m;
                    discountPrice              = purchasePrice * transaction.DiscountLevel;
                    purchasePrice              = purchasePrice - discountPrice;
                    transaction.PurchaseAmount = purchasePrice;
                    DisplayCustomerTransaction.DisplayPreferredTransaction(transaction.PurchaseAmount, transaction.DiscountLevel, discountPrice);
                    loop = true;
                }
                else if (decimal.TryParse(input, out purchasePrice) && purchasePrice >= 1000.00m && purchasePrice <= 1499.99m)
                {
                    transaction.DiscountLevel  = .06m;
                    discountPrice              = purchasePrice * transaction.DiscountLevel;
                    purchasePrice              = purchasePrice - discountPrice;
                    transaction.PurchaseAmount = purchasePrice;
                    DisplayCustomerTransaction.DisplayPreferredTransaction(transaction.PurchaseAmount, transaction.DiscountLevel, discountPrice);
                    loop = true;
                }
                else if (decimal.TryParse(input, out purchasePrice) && purchasePrice >= 1500.00m && purchasePrice <= 1999.99m)
                {
                    transaction.DiscountLevel  = .07m;
                    discountPrice              = purchasePrice * transaction.DiscountLevel;
                    purchasePrice              = purchasePrice - discountPrice;
                    transaction.PurchaseAmount = purchasePrice;
                    DisplayCustomerTransaction.DisplayPreferredTransaction(transaction.PurchaseAmount, transaction.DiscountLevel, discountPrice);;
                    loop = true;
                }
                else if (decimal.TryParse(input, out purchasePrice) && purchasePrice >= 2000.00m)
                {
                    transaction.DiscountLevel  = .10m;
                    discountPrice              = purchasePrice * transaction.DiscountLevel;
                    purchasePrice              = purchasePrice - discountPrice;
                    transaction.PurchaseAmount = purchasePrice;
                    DisplayCustomerTransaction.DisplayPreferredTransaction(transaction.PurchaseAmount, transaction.DiscountLevel, discountPrice);
                    loop = true;
                }

                else
                {
                    //If user enters anything other than a number display invalid input.
                    Console.WriteLine(StandardMessages.DisplayInvalidChoice());
                    Console.ReadLine();
                }
            } while (loop == false);
            Console.WriteLine(StandardMessages.DisplayEnterMessage());
            Console.ReadLine();
        }