static void Main() { GSM[] gsm = new GSM[3]; Battery bat = new Battery("1sd34", 500, 100, BatteryType.NiCd); Display disp = new Display(); Battery anotherBat = new Battery(800, 200); Display anotherDisp = new Display(4.5, 20000000); gsm[0] = new GSM("IPhone 6S", "Apple", 1000.00, bat.ToString(), disp.ToString()); gsm[1] = new GSM("Galaxy S5", "Samsung", 620.00, "Ivan", anotherBat.ToString(), disp.ToString()); gsm[2] = new GSM("Nexus 5X", "LG", anotherBat.ToString(), anotherDisp.ToString()); foreach (var phone in gsm) { Console.WriteLine(phone.ToString()); Console.WriteLine(); } Console.WriteLine("========================="); Console.WriteLine(GSM.IPhone4S); Console.WriteLine("========================="); GSMCallHistoryTest test = new GSMCallHistoryTest(); test.Test(); }
public override string ToString() { StringBuilder finalResult = new StringBuilder(); finalResult.Append("Model: ").Append(string.IsNullOrEmpty(model) ? "" : this.model).Append("\n"); finalResult.Append("Manufacturer: ").Append(string.IsNullOrEmpty(manufacturer) ? "" : this.manufacturer).Append("\n"); finalResult.Append("Price: ").Append(this.Price == null ? "" : this.price.ToString()).Append("\n"); finalResult.Append("Owner: ").Append(string.IsNullOrEmpty(owner) ? "" : this.owner).Append("\n"); finalResult.Append("Battery: \n").Append(this.Battery == null ? "" : battery.ToString()).Append("\n"); finalResult.Append("Display: \n").Append(this.Display == null ? "" : display.ToString()).Append("\n"); return(finalResult.ToString()); }
public void Test() { Battery bat = new Battery("1sd34", 500, 100, BatteryType.NiCd); Display disp = new Display(); GSM phone = new GSM("6", "IPhone", bat.ToString(), disp.ToString()); phone.AddCall("12.12.2012", "15:00", "+359 885 635338", 500); phone.AddCall("04.04.2004", "12:00", "+359 885 643453", 200); phone.AddCall("01.03.2014", "09:00", "+359 884 654634", 100); foreach (var item in GSM.CallList) { Console.WriteLine(item); } Console.WriteLine("Total price of all calls in history: " + phone.CalculateCallPrice(0.37) + "BGN"); Console.WriteLine("========================="); phone.DeleteCall(); foreach (var item in GSM.CallList) { Console.WriteLine(item); } Console.WriteLine("Total price of all calls in history: " + phone.CalculateCallPrice(0.37) + "BGN"); Console.WriteLine("========================="); phone.ClearHistory(); foreach (var item in GSM.CallList) { Console.WriteLine(item); } }