public static void Test() { MobilePhoneDevice telephone = new MobilePhoneDevice("Alcatel", "Lucent"); telephone.AddCall(new Call(new DateTime(2014, 02, 01, 13, 12, 51), "+359879310320", 354)); telephone.AddCall(new Call(new DateTime(2014, 02, 02, 17, 21, 50), "0876520320", 211)); telephone.AddCall(new Call(new DateTime(2014, 02, 03, 10, 45, 13), "0887675685", 108)); foreach (var call in telephone.CallsHistoryList) { Console.WriteLine(call); } var totalCallsPrice = telephone.CalculateTotalPrice(Call.CallPrice); Console.WriteLine("The total price of all calls is: {0} BGN.", totalCallsPrice); var sortedCallList = telephone.CallsHistoryList.OrderBy(c => c.Duration); var longestCall = sortedCallList.Last(); Console.WriteLine(longestCall); telephone.DeleteCall(longestCall); var newTotalCallsPrice = telephone.CalculateTotalPrice(Call.CallPrice); // the newly calculated price Console.WriteLine("The total price of all calls is after the deletion of the longest call: {0} BGN.", newTotalCallsPrice); telephone.ClearCallHistory(); Console.WriteLine("Here is the call history after the clearing."); foreach (var call in telephone.CallsHistoryList) { Console.WriteLine(call); } }
static void Main() { Battery batteryOne = new Battery(BatteryType.NiMH, 120.00m, 6.00m); Display displayOne = new Display(5, 512); MobilePhoneDevice mobilePhoneOne = new MobilePhoneDevice("HTC", "HONG ME"); // Task 4 // Task 12 mobilePhoneOne.battProperty = batteryOne; mobilePhoneOne.displProperty = displayOne; //Console.Write("Please insert a model: "); //mobilePhoneOne.model = Console.ReadLine(); //Console.Write("Please inser a manufacturer: "); //mobilePhoneOne.manufacturer = Console.ReadLine(); //Console.Write("Please insert a price: "); //mobilePhoneOne.price = decimal.Parse(Console.ReadLine()); //Console.Write("Please insert an owner's name: "); //mobilePhoneOne.ownersName = Console.ReadLine(); Battery batteryTwo = new Battery(BatteryType.LiIon, 96.00m, 5.00m); Display displayTwo = new Display(4, 512); MobilePhoneDevice mobilePhoneTwo = new MobilePhoneDevice("S Duos", "Samsung", 420.00m, "Georgi Minkov"); // Task 4 // Task 12 mobilePhoneTwo.battProperty = batteryTwo; mobilePhoneTwo.displProperty = displayTwo; Battery batteryThree = new Battery(BatteryType.NiCd, 120.00m, 6.00m); Display displayThree = new Display(5, 1024); MobilePhoneDevice mobilePhoneThree = new MobilePhoneDevice("Lumia", "Nokia", 650.00m, "Dimitar Petrov"); // Task 4 // Task 12 mobilePhoneThree.battProperty = batteryThree; mobilePhoneThree.displProperty = displayThree; //Console.WriteLine(mobilePhoneOne); // Task 4 //Console.WriteLine(mobilePhoneTwo); // Task 4 //Console.WriteLine(mobilePhoneThree); // Task 4 MobilePhoneDevice[] mPDArray = { mobilePhoneOne, mobilePhoneTwo, mobilePhoneThree }; // Task 7 foreach (object item in mPDArray) { Console.WriteLine(item); Console.WriteLine(); } Console.WriteLine(MobilePhoneDevice.IPhone4S); Console.WriteLine(); CallHistoryTest.Test(); }