コード例 #1
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);
        }