public static void CallTest() { var lion = new Battery("pesho123", 100, 30, BatteryType.LiIon); var gorilla = new Display(5, 6000000); var samsung = new GSM.GSM("galaxy s2", "samsung", 400, "Stoyan", lion, gorilla); var tempCall = new Call("11.05", "13:45", "0851782516", 240); samsung.AddCall(tempCall); tempCall = new Call("12.05", "11:45", "0851782516", 120); samsung.AddCall(tempCall); tempCall = new Call("14.05", "12:33", "0851782516", 24); samsung.AddCall(tempCall); tempCall = new Call("15.05", "04:45", "0851782516", 1790); samsung.AddCall(tempCall); foreach (var item in samsung.CallHistory) { Console.WriteLine(item); } decimal bill = 0; foreach (var item in samsung.CallHistory) { bill += samsung.CallPrice(item, (decimal)0.37); } Console.WriteLine("Bill is: {0}",bill); int maxIndex=0; int maxDuration=0; for (int i = 0; i < samsung.CallHistory.Count; i++) { if (samsung.CallHistory[i].Duration>maxDuration) { maxDuration = samsung.CallHistory[i].Duration; maxIndex = i; } } samsung.DeleteCall(maxIndex); bill = 0; foreach (var item in samsung.CallHistory) { bill += samsung.CallPrice(item, (decimal)0.37); } Console.WriteLine("Bill is: {0}", bill); foreach (var item in samsung.CallHistory) { Console.WriteLine(item); } samsung.ClearHistory(); }
public static void GsmTest() { Console.WriteLine(); // Create an array of few instances of the GSM class. var lion = new Battery("pesho123", 100, 30, BatteryType.LiIon); var gorilla = new Display(5, 6000000); var samsung = new GSM.GSM("galaxy s2", "samsung", 400, "Stoyan", lion, gorilla); var htc = new GSM.GSM("m8", "HTC", 350, "Dragan", lion, gorilla); var sony = new GSM.GSM("xperia z5", "Sony", 500, "Pesho", lion, gorilla); var onePlusOne = new GSM.GSM("onePlusOne", "onePlusOne", 600, "Ivan", lion, gorilla); var gsmList = new List<GSM.GSM> { samsung, htc, sony, onePlusOne }; // Display the information about the GSMs in the array. Console.WriteLine(string.Join(Environment.NewLine, gsmList)); Console.WriteLine(GSM.GSM.Iphone4S); }
public static void GsmTest() { Console.WriteLine(); // Create an array of few instances of the GSM class. var lion = new Battery("pesho123", 100, 30, BatteryType.LiIon); var gorilla = new Display(5, 6000000); var samsung = new GSM.GSM("galaxy s2", "samsung", 400, "Stoyan", lion, gorilla); var htc = new GSM.GSM("m8", "HTC", 350, "Dragan", lion, gorilla); var sony = new GSM.GSM("xperia z5", "Sony", 500, "Pesho", lion, gorilla); var onePlusOne = new GSM.GSM("onePlusOne", "onePlusOne", 600, "Ivan", lion, gorilla); var gsmList = new List <GSM.GSM> { samsung, htc, sony, onePlusOne }; // Display the information about the GSMs in the array. Console.WriteLine(string.Join(Environment.NewLine, gsmList)); Console.WriteLine(GSM.GSM.Iphone4S); }