Building Quotation engine program

Answer Posted / testndl002

PresentationLayer --> Program.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TravelInsuranceQuote.DataLayer;
using TravelInsuranceQuote.BusinessLayer;
using System.IO;

namespace TravelInsuranceQuote.PresentationLayer
{
public class Program
{

public static void Main(string[] args)
{
var customer = new Customer();

string[] lines = File.ReadAllLines(@"D:\Test.txt");

foreach (var line in lines)
{
var nameValue = line.Split(new char[] { ':' });
switch (nameValue[0].ToLower())
{
case "triptype":
customer.TripType = ((nameValue[1].ToLower() == "single") ? TripType.Single : TripType.Annual);
break;
case "sex":
customer.Sex = ((nameValue[1].ToLower() == "male") ? Sex.Male : Sex.Female);
break;
case "destination":
customer.Destination = ((nameValue[1].ToLower() == "uk") ? Destination.UK :
((nameValue[1].ToLower() == "europe") ? Destination.Europe : Destination.Worldwide));
break;
case "age":
customer.Age = Convert.ToInt32(nameValue[1]);
break;
case "travelperiod":
customer.TravelPeriod = Convert.ToInt32(nameValue[1]);
break;
}

}

//Console.Write("Type:");
//customer.TripType = ((Console.ReadLine().ToLower() == "single") ? TripType.Single : TripType.Annual);
//Console.Write("Age:");
//customer.Age = int.Parse(Console.ReadLine());
//Console.Write("Sex:");
//customer.Sex = ((Console.ReadLine().ToLower() == "male") ? Sex.Male : Sex.Female); ;
//Console.Write("Destination:");
//switch(Console.ReadLine().ToLower())
//{
// case "uk" :
// customer.Destination = Destination.UK;
// break;
// case "europe" :
// customer.Destination = Destination.Europe;
// break;
// case "worldwide" :
// customer.Destination = Destination.Worldwide;
// break;
//}
//Console.Write("TravelPeriod:");
//customer.TravelPeriod = int.Parse(Console.ReadLine());

string reason;
var customerPremium = new QuoteEngine().GetPremium(customer, out reason);

if (customerPremium != null)
{
Console.WriteLine("BasePremium({0}):{1}", customerPremium.Base, customerPremium.Base);
Console.WriteLine("Age({0}):{1}", customerPremium.Age[1], customerPremium.Age[0]);
Console.WriteLine("Sex({0}):{1}", customerPremium.Sex[1], customerPremium.Sex[0]);
Console.WriteLine("Destination({0}):{1}", customerPremium.Destination[1], customerPremium.Destination[0]);
Console.WriteLine("TravelPeriod({0}):{1}", customerPremium.TravelPeriod[1], customerPremium.TravelPeriod[0]);
Console.WriteLine("Tax({0}):{1}", customerPremium.Tax[1], customerPremium.Tax[0]);
Console.WriteLine("Total:{0}", customerPremium.Total);
}
else
{
Console.Write("Declined:" + reason);
}
Console.ReadKey();
}
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do i find out the number of parameters passed into function?

2417


Write code to read the records from a file and load any array of size 99?make sure that you take care of all the error conditions?

1835


How do you initialize a static member of a class with return value of some function?

863


when will triggars the at new event in abap and web dybn pro?

1709


Q2. A memory location has physical address D5687h. Compute: a. The offset address if the segment number is D445h. b. The segment number if the offset address is B577h.

1873


code for connection from windows forms to sql server

1933


How can we develop a multi-tier application in Java?

1633


Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fit" instead of the number and for the multiples of five print "Bit". For numbers which are multiples of both three and five print "FitBit".

2177


how do you generate source code for the automatic generation for receipt number

4208


What is %Type,%Rowtype?

2020


Explain the difference between an expert and a novice user. How would your strategy for designing user interfaces for an expert user differ from that for designing user interfaces for a novice user.

2826


hii I inntrested abt scjp certification but i dont knw abt scjp plz send details abt scjp exam and syllabus.

1613


why we use abstract in awt?

1747


8.In DSP,Define Signal and System?and various type of signals.

1759


My Qualification is MCA.My interview is on 5th may.They may ask q as------AS u r MCA...Why u r not tring anywhere else? What can be the ans?

1719