Beispiel #1
0
        static void customerViewAPolicy(InsurancePolicy policy)
        {
            bool isRunning = false;

            while (isRunning)
            {
                // Display policy details.
                Console.WriteLine("ID: " + policy.getPolicyID());

                Console.WriteLine("Terms & Conditions: ");
                int tAndCNo = 1;
                foreach (string tAndC in policy.getTermsCond())
                {
                    Console.WriteLine("#" + (tAndCNo++) + tAndC);
                }

                Console.WriteLine("Riders: ");
                int riderNo = 1;
                foreach (Rider r in policy.getRiderList())
                {
                    Console.WriteLine("#" + riderNo++);
                    Console.WriteLine("Description: " + r.getDescription());
                    Console.WriteLine("Total Amount payable: $" + r.getTotalAmountPayable());
                    Console.WriteLine("Pay out amount: $" + r.getPayOutAmount());
                    Console.WriteLine();
                }

                // Get outstanding premiums.
                List <Premium> premiums = policy.getPremiums();

                bool hasOutstandingPremiums = premiums.Count > 0;
                if (hasOutstandingPremiums) // Has outstanding premiums.
                {
                    Console.WriteLine("Has outstanding premiums!");

                    Console.WriteLine("\n\n[1] Pay Outstanding Premium(s)\n[0] Return home");
                }
                else // Has no outstanding premiums.
                {
                    Console.WriteLine("Has no outstanding premium!");

                    Console.WriteLine("[0] Return home");
                }

                while (true)
                {
                    Console.Write("Enter option: ");
                    int option = Convert.ToInt32(Console.ReadLine());
                    if (option == 1 && hasOutstandingPremiums) // Customer wants to pay premium using credit card.
                    {
                        customerPayCreditCard(premiums);
                        break;
                    }
                    else if (option == 0) // Return back to the list of policies
                    {
                        isRunning = false;
                        break;
                    }
                    else
                    {
                        Console.WriteLine("Invalid option.");
                    }
                }
            }
        }