Example #1
0
        static void editPolicy(InsurancePolicy policy)
        {
            List <Rider> policyRiders = policy.getRiderList();
            int          riderNo      = policyRiders.Count;

            Console.Write("Add Rider?[Y/N]: ");
            string option = Console.ReadLine();

            while (option == "Y")
            {
                Console.Write("\nEnter in policy description: ");
                string desc = Console.ReadLine();

                Console.Write("\nEnter policy type: ");
                string policyType = Console.ReadLine();

                Console.Write("\nEnter payout amount: $");
                double payOut = Convert.ToDouble(Console.ReadLine());

                Console.Write("\nEnter total amount: $");
                double totalAmt = Convert.ToDouble(Console.ReadLine());

                Console.Write("\nConfirm Add Rider?[Y/N]: ");
                string addRider = Console.ReadLine();

                if (addRider == "Y")
                {
                    Rider rider = new Rider(riderNo, desc, policyType, payOut, totalAmt, new PercentagePayoutStrategy());
                    policyRiders.Add(rider);
                    riderNo++;
                    Console.WriteLine("Rider Updated!");
                    Console.Write("\nAdd more riders?[Y/N]: ");
                    option = Console.ReadLine();
                }
                else if (addRider == "N")
                {
                    continue;
                }
            }
            if (option == "N")
            {
                Console.Write("Pay Premium by Cheque?[Y/N]: ");
                string ppbc = Console.ReadLine();
                while (ppbc == "Y")
                {
                    if (policyRiders[0].getTotalAmountPayable() == 0)
                    {
                        Console.Write("No outstanding premium");
                        break;
                    }
                    else
                    {
                        Console.WriteLine("Total amount payable = $" + policyRiders[0].getTotalAmountPayable());
                        Console.Write("Enter Cheque No.: ");
                        string cheque = Console.ReadLine();
                        Console.Write("Enter bank acc No.: ");
                        string bank = Console.ReadLine();
                        Console.Write("\nConfirm Payment?[Y/N]: ");
                        string payByCheque = Console.ReadLine();

                        if (payByCheque == "Y")
                        {
                            //Store cheque details
                            //Total amount payable =0
                            Console.WriteLine("Cheque Stored!");
                            break;
                        }
                        else if (payByCheque == "N")
                        {
                            continue;
                        }
                    }
                }
                Console.WriteLine("Policy Updated!");
            }
        }
Example #2
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.");
                    }
                }
            }
        }