예제 #1
0
        public static void Main(string[] args)
        {
            Program p = new Program();
            //  Insurance i = new Insurance();
            LifeInsurance  li = new LifeInsurance();
            MotorInsurance mi = new MotorInsurance();

            Console.Write("Insurance Number : ");
            li.InsuranceNo = mi.InsuranceNo = Console.ReadLine();
            Console.Write("Insurance Name : ");
            li.InsuranceName = mi.InsuranceName = Console.ReadLine();
            Console.Write("Amount Covered : ");
            li.AmountCovered = mi.AmountCovered = double.Parse(Console.ReadLine());
            Console.WriteLine("Select");
            Console.WriteLine("1.Life Insurance");
            Console.WriteLine("2.Motor Insurance");
            int option = int.Parse(Console.ReadLine());

            if (option == 1)
            {
                Console.Write("Policy Term : ");
                li.PolicyTerm = int.Parse(Console.ReadLine());
                Console.Write("Benefit Percent : ");
                li.BenefitPercent = int.Parse(Console.ReadLine());
                Console.WriteLine("Calculated Premium: " + p.addPolicy(li, option));
                Console.ReadLine();
            }
            if (option == 2)
            {
                Console.WriteLine("Dep Percent");
                mi.DepPercent = float.Parse(Console.ReadLine());
                Console.WriteLine("Calculated Premium: " + p.addPolicy(mi, option));
                Console.ReadLine();
            }
        }
예제 #2
0
 public double addPolicy(Insurance ins, int opt)
 {
     if (opt == 1)
     {
         LifeInsurance l = (LifeInsurance)ins;
         return(l.calculatePremium());
     }
     else
     {
         MotorInsurance m = (MotorInsurance)ins;
         return(m.calculatePremium());
     }
 }