Exemplo n.º 1
0
        static void Main()
        {
            //GSM[] arr = new GSM[3];
            //arr[0] = new GSM("Google Nexus 3", "Samsung", 400, "-", new Battery("Removable", BatteryType.LiIon, 270, 8), new Display(4.65f, 16000000));
            //arr[1] = new GSM("Galaxy S5", "Samsung", 800, "-", new Battery("Removable", BatteryType.LiIon, 390, 21), new Display(5.1f, 16000000));
            //arr[2] = new GSM("Ascend P7", "Huawei", 650, "-", new Battery("Non-removable", BatteryType.LiPol, 422, 14), new Display(5f, 16000000));

            //for (int i = 0; i < arr.Length; i++)
            //{
            //    Console.WriteLine(arr[i]);
            //    Console.WriteLine();
            //}

            Console.WriteLine(GSM.IPhone4S);
            Console.WriteLine();

            var myPhone = new GSM("Google Nexus 3", "Samsung", 400, "-", new Battery("Removable", BatteryType.LiIon, 270, 8), new Display(4.65f, 16000000));

            myPhone.AddCall(new Call(new DateTime(2015, 3, 5, 10, 15, 7), "+359880123456", 10));
            myPhone.AddCall(new Call(new DateTime(2015, 3, 6, 8, 13, 7), "+359888888888", 65));
            myPhone.AddCall(new Call(new DateTime(2015, 3, 7, 13, 17, 7), "+359880123456", 100));
            myPhone.AddCall(new Call(new DateTime(2015, 3, 8, 22, 37, 7), "0880123456", 50));


            PrintTotal(myPhone);

            myPhone.DeleteCall(2); // longest call is with index 2

            PrintTotal(myPhone);

            myPhone.ClearCalls();

            PrintTotal(myPhone);
        }
        public void CallHistoryTest()
        {
            GSM myPhone = new GSM("Lumia", "Nokia");
            //public Call(string date, string time, string dialed, long duration)
            List <Call> someCalls = new List <Call> {
                new Call("02.02.2015", "15:45", "0896232333", 56),
                new Call("03.18.2015", "11:45", "0852454555", 13),
                new Call("01.02.2015", "00:05", "0899656598", 118),
                new Call("03.15.2015", "18:32", "0896232333", 65)
            };

            foreach (Call a in someCalls)
            {
                myPhone.AddCall(a);
            }
            myPhone.DisplayCalls();
            double price = 0.37;

            Console.WriteLine("With price of 0.37 per minute, the total cost of the calls:" + myPhone.CalcPrice(price / 60));
            Console.WriteLine("Removing the longest call ...");
            myPhone.DeleteCall(someCalls[2]);
            Console.WriteLine("With price of 0.37 per minute, the total cost of the calls:" + myPhone.CalcPrice(price / 60));
            myPhone.ClearHistory();
            Console.WriteLine("History Cleared");
            Console.WriteLine("Current History:");
            myPhone.DisplayCalls();
        }
Exemplo n.º 3
0
Arquivo: GSMTest.cs Projeto: GAlex7/TA
        static void Main()
        {
            //GSM[] arr = new GSM[3];
            //arr[0] = new GSM("Google Nexus 3", "Samsung", 400, "-", new Battery("Removable", BatteryType.LiIon, 270, 8), new Display(4.65f, 16000000));
            //arr[1] = new GSM("Galaxy S5", "Samsung", 800, "-", new Battery("Removable", BatteryType.LiIon, 390, 21), new Display(5.1f, 16000000));
            //arr[2] = new GSM("Ascend P7", "Huawei", 650, "-", new Battery("Non-removable", BatteryType.LiPol, 422, 14), new Display(5f, 16000000));

            //for (int i = 0; i < arr.Length; i++)
            //{
            //    Console.WriteLine(arr[i]);
            //    Console.WriteLine();
            //}

            Console.WriteLine(GSM.IPhone4S);
            Console.WriteLine();

            var myPhone = new GSM("Google Nexus 3", "Samsung", 400, "-", new Battery("Removable", BatteryType.LiIon, 270, 8), new Display(4.65f, 16000000));

            myPhone.AddCall(new Call(new DateTime(2015, 3, 5, 10, 15, 7), "+359880123456", 10));
            myPhone.AddCall(new Call(new DateTime(2015, 3, 6, 8, 13, 7), "+359888888888", 65));
            myPhone.AddCall(new Call(new DateTime(2015, 3, 7, 13, 17, 7), "+359880123456", 100));
            myPhone.AddCall(new Call(new DateTime(2015, 3, 8, 22, 37, 7), "0880123456", 50));

            PrintTotal(myPhone);

            myPhone.DeleteCall(2); // longest call is with index 2

            PrintTotal(myPhone);

            myPhone.ClearCalls();

            PrintTotal(myPhone);
        }
Exemplo n.º 4
0
        static void Main()
        {
            GSM Nokia = new GSM("Lumia", "Nokia");

            Nokia.Price = 456.32m;
            Nokia.Owner = "Pesho";
            Console.WriteLine(Nokia);
        }
Exemplo n.º 5
0
        public static void Main()
        {
            GSM[] arr = new GSM[5]
            {
                new GSM("Lumia", "Nokia", 500, "Ivan"),
                new GSM("S6", "Samsung", 1000, "Maria"),
                new GSM("6S", "iPhone", 1500, "Pesho"),
                new GSM("P6", "Huawei", 690.50, "John"),
                new GSM("6", "iPhone", 1300, "Ginka")
            };

            foreach (var phone in arr)
            {
                Console.WriteLine(phone);
            }
            Console.WriteLine();

            GSM myGSM = new GSM("Lumia", "Nokia", 500, "Ivan");

            myGSM.AddCalls(new Call(60));
            myGSM.AddCalls(new Call(120));
            myGSM.AddCalls(new Call(20));
            myGSM.AddCalls(new Call(10));

            for (int i = 0; i < myGSM.CallHistory.Count; i++)
            {
                Console.WriteLine("Call {0} duration: {1}sec", i + 1, myGSM.CallHistory[i].DurationInSeconds);
            }
            Console.WriteLine();
            Console.WriteLine("Total price of all calls: {0}", myGSM.CalculateTotalPriceOfCalls());

            int longestCall = int.MinValue;

            for (int i = 1; i < myGSM.CallHistory.Count; i++)
            {
                int currentMax = Math.Max(myGSM.CallHistory[i - 1].DurationInSeconds, myGSM.CallHistory[i].DurationInSeconds);
                if (longestCall < currentMax)
                {
                    longestCall = currentMax;
                }
            }
            for (int i = 0; i < myGSM.CallHistory.Count; i++)
            {
                if (myGSM.CallHistory[i].DurationInSeconds == 120)
                {
                    myGSM.CallHistory.RemoveAt(i);
                }
            }
            Console.WriteLine("Total price of all calls after removing longest call : {0}", myGSM.CalculateTotalPriceOfCalls());
            myGSM.ClearCallHistory();

            for (int i = 0; i < myGSM.CallHistory.Count; i++)
            {
                Console.WriteLine("After clear {0}", myGSM.CallHistory[i].DurationInSeconds);
            }
        }
Exemplo n.º 6
0
        private static void Main()
        {
            // Inserting data:
            GSM myPhone = new GSM("Nokia", "Nokia OOD");

            myPhone.Price                  = 500;
            myPhone.Owner                  = "Ivancho";
            myPhone.battery                = new Battery(BatteryType.NiMH);
            myPhone.battery.HourIdle       = 12;
            myPhone.battery.HoursTalk      = 520;
            myPhone.display                = new Display(12);
            myPhone.display.NumberOfColors = 326;

            // Transfering data and printing
            Console.WriteLine(myPhone.PrintMobileInfo(myPhone.battery, myPhone.display));

            // Iphone4S data:
            string theIPhoneInfo = GSM.IPhone4S;

            Console.WriteLine(theIPhoneInfo);

            // and ETC
            GSM phone = new GSM("Alcatel", "Alacatelov");

            GSMTest.CreateAFewGSMs(5);

            // Adding calls
            myPhone.resentCall = new Call("0898123231");
            Console.WriteLine(myPhone.resentCall.LastNumber);
            myPhone.CallHistory.Add(myPhone.resentCall);

            // Adding a second call
            myPhone.resentCall = new Call("08788765426");

            // Adding the call to the list
            myPhone.CallHistory.Add(myPhone.resentCall);
            foreach (Call talk in myPhone.CallHistory)
            {
                Console.WriteLine(talk.LastNumber);
            }

            // From here on, the adding to the callHistory is automatic
            myPhone.AddAndRemove("add", myPhone);
            myPhone.AddAndRemove("remove", myPhone);
            double totalPrice = myPhone.TotalPriceOfCalls(myPhone);

            // Not working because I don't have thread.sleep or something to make timespan
            Console.WriteLine("Total price: {0}", totalPrice);

            // Clearing the history
            myPhone.ClearHistory();
            GSMCallHistoryTest.GSMTest();
        }
Exemplo n.º 7
0
        public double TotalPriceOfCalls(GSM currentGSM)
        {
            double totalPrice = 0;

            foreach (Call talk in currentGSM.CallHistory)
            {
                double totalMinutes = double.Parse(talk.Duration.Minutes.ToString());
                totalPrice += totalMinutes * 0.37;
            }

            return(totalPrice);
        }
Exemplo n.º 8
0
 public static List<Calls> RemoveLongestCall(GSM phone, List<Calls> CallHistory)
 {
     Calls longestCall = CallHistory[0];
     foreach (Calls call in CallHistory)
     {
         if (call.Duration > longestCall.Duration)
         {
             longestCall = call;
         }
     }
     phone.DeleteCall(longestCall);
     return CallHistory;
 }
Exemplo n.º 9
0
        public static List <Calls> RemoveLongestCall(GSM phone, List <Calls> CallHistory)
        {
            Calls longestCall = CallHistory[0];

            foreach (Calls call in CallHistory)
            {
                if (call.Duration > longestCall.Duration)
                {
                    longestCall = call;
                }
            }
            phone.DeleteCall(longestCall);
            return(CallHistory);
        }
Exemplo n.º 10
0
        public static void Test()
        {
            GSM[] phone = new GSM[]
            {
                new GSM("Samsung", "Galaxy S5"),
                new GSM("Samsung", "Galaxy S4"),
                new GSM("Samsung", "Galaxy S3"),
                new GSM("Apple", "IPhone 6S")
            };
            GSMTest test = new GSMTest(phone);

            Console.WriteLine(GSMTest.PrintInfo());
            Console.WriteLine(GSM.IPhone4S);
        }
Exemplo n.º 11
0
        public void Create4GSMs()
        {
            GSM samsungMini = new GSM("Samsung S3 Mini", "Samsung");
            GSM samsung = new GSM("Samsung S3", "Samsung");
            GSM iPhone6 = new GSM("IPhone 6", "Apple");
            GSM[] arrayGSM = { samsungMini, samsung, iPhone6 };

            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine(arrayGSM[i].ToString());
            }

            Console.WriteLine(GSM.IPhone4S);
        }
Exemplo n.º 12
0
        public static void Test()
        {
            GSM[] phone = new GSM[]
            {
                new GSM ("Samsung", "Galaxy S5"),
                new GSM ("Samsung", "Galaxy S4"),
                new GSM ("Samsung", "Galaxy S3"),
                new GSM ("Apple", "IPhone 6S")
            };
            GSMTest test = new GSMTest(phone);

            Console.WriteLine(GSMTest.PrintInfo());
            Console.WriteLine(GSM.IPhone4S);
        }
Exemplo n.º 13
0
        public static void GSMTest()
        {
            GSM testGSM = new GSM("Alcatel", "Volvo");

            testGSM.AddAndRemove("add", testGSM);
            Console.WriteLine(testGSM.ResentCall.Duration.ToString());
            Console.WriteLine(testGSM.ResentCall.LastNumber);

            testGSM.AddAndRemove("add", testGSM);
            Console.WriteLine(testGSM.ResentCall.Duration.ToString());
            Console.WriteLine(testGSM.ResentCall.LastNumber);

            testGSM.AddAndRemove("add", testGSM);
            Console.WriteLine(testGSM.ResentCall.Duration.ToString());
            Console.WriteLine(testGSM.ResentCall.LastNumber);

            double totalPrice = testGSM.TotalPriceOfCalls(testGSM);

            Console.WriteLine(totalPrice);

            int longestTalkIndex = 0;

            for (int i = 1; i < testGSM.CallHistory.Count; i++)
            {
                if (testGSM.CallHistory[i - 1].Duration > testGSM.CallHistory[i].Duration)
                {
                    {
                        longestTalkIndex = i - 1;
                    }
                }

                if (i == testGSM.CallHistory.Count - 1 && testGSM.CallHistory[i - 1].Duration < testGSM.CallHistory[i].Duration)
                {
                    longestTalkIndex = i;
                }
            }

            testGSM.CallHistory.RemoveAt(longestTalkIndex);
            double newTotalPrice = testGSM.TotalPriceOfCalls(testGSM);

            Console.WriteLine(newTotalPrice);
            for (int i = 0; i < testGSM.CallHistory.Count; i++)
            {
                Console.WriteLine(testGSM.CallHistory[i].LastNumber);
                testGSM.CallHistory.RemoveAt(i);
            }
        }
        static void Main(string[] args)
        {
            GSM gsm = new GSM("testModel", "testManufacturer");

            gsm.AddCall(new Call("11.02.2013", "18:32", "00000000", 432));
            gsm.AddCall(new Call("11.02.2013", "19:02", "00000001", 23));
            gsm.AddCall(new Call("12.02.2013", "11:28", "00000010", 5243));

            foreach (Call call in gsm.CallHistory)
            {
                Console.WriteLine("Call date: " + call.Date);
                Console.WriteLine("Call time: " + call.Time);
                Console.WriteLine("Call phone number: " + call.PhoneNumber);
                Console.WriteLine("Call duration: " + call.Duration);
                Console.Write("\n");
            }

            Console.WriteLine("Total price: " + gsm.TotalPrice(0.37m));

            gsm.DeleteCall(2);

            Console.WriteLine("Total price without the longest call: " + gsm.TotalPrice(0.37m));
            Console.Write("\n");

            foreach (Call call in gsm.CallHistory)
            {
                Console.WriteLine("Call date: " + call.Date);
                Console.WriteLine("Call time: " + call.Time);
                Console.WriteLine("Call phone number: " + call.PhoneNumber);
                Console.WriteLine("Call duration: " + call.Duration);
                Console.Write("\n");
            }

            gsm.ClearCallHistory();

            foreach (Call call in gsm.CallHistory)
            {
                Console.WriteLine("Call date: " + call.Date);
                Console.WriteLine("Call time: " + call.Time);
                Console.WriteLine("Call phone number: " + call.PhoneNumber);
                Console.WriteLine("Call duration: " + call.Duration);
                Console.Write("\n");
            }
        }
        public static void GSMTest()
        {
            GSM testGSM = new GSM("Alcatel", "Volvo");

            testGSM.AddAndRemove("add", testGSM);
            Console.WriteLine(testGSM.ResentCall.Duration.ToString());
            Console.WriteLine(testGSM.ResentCall.LastNumber);

            testGSM.AddAndRemove("add", testGSM);
            Console.WriteLine(testGSM.ResentCall.Duration.ToString());
            Console.WriteLine(testGSM.ResentCall.LastNumber);

            testGSM.AddAndRemove("add", testGSM);
            Console.WriteLine(testGSM.ResentCall.Duration.ToString());
            Console.WriteLine(testGSM.ResentCall.LastNumber);

            double totalPrice = testGSM.TotalPriceOfCalls(testGSM);
            Console.WriteLine(totalPrice);

            int longestTalkIndex = 0;
            for (int i = 1; i < testGSM.CallHistory.Count; i++)
            {
                if (testGSM.CallHistory[i - 1].Duration > testGSM.CallHistory[i].Duration)
                {
                    {
                        longestTalkIndex = i - 1;
                    }
                }

                if (i == testGSM.CallHistory.Count - 1 && testGSM.CallHistory[i - 1].Duration < testGSM.CallHistory[i].Duration)
                {
                    longestTalkIndex = i;
                }
            }

            testGSM.CallHistory.RemoveAt(longestTalkIndex);
            double newTotalPrice = testGSM.TotalPriceOfCalls(testGSM);
            Console.WriteLine(newTotalPrice);
            for (int i = 0; i < testGSM.CallHistory.Count; i++)
            {
                Console.WriteLine(testGSM.CallHistory[i].LastNumber);
                testGSM.CallHistory.RemoveAt(i);
            }
        }
Exemplo n.º 16
0
        public GSMTest()
        {
            for (int i = 0; i < collectionOfGSM.Length; i++)
            {
                string manifacturer = Console.ReadLine();
                string model        = Console.ReadLine();
                double price        = double.Parse(Console.ReadLine());
                string owner        = Console.ReadLine();
                collectionOfGSM[i] = new GSM(model, manifacturer, price, owner);
            }

            GSM.IPhone4S = new GSM("iphone 4S", "Apple");

            for (int i = 0; i < collectionOfGSM.Length; i++)
            {
                Console.WriteLine(collectionOfGSM[i].ToString());
            }
            Console.WriteLine(GSM.IPhone4S.ToString());
        }
Exemplo n.º 17
0
        public static void Test()
        {
            var phone1 = new GSM("MyModel", "MadeInTheGarage");
            var phone2 = GSM.IPhone6Splus;

            var bat    = new Battery("5000mAh", BateryType.Li_Ion, 10, 10);
            var dis    = new Display(5.5, 100);
            var phone3 = new GSM("MyAnotherModel", "Lenovo", "me", 50, bat, dis);

            var arr = new GSM[3] {
                phone1, phone2, phone3
            };

            foreach (GSM phone in arr)
            {
                Console.WriteLine(phone.ToString());
                Console.WriteLine("----------------------------------------");
            }
        }
Exemplo n.º 18
0
        static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            Battery myBattery = new Battery("Bateria");
            Display myDisplay = new Display();
            GSM myGSM = new GSM("Nokia","Nokia", 100.23M, "Pesho",myBattery,myDisplay);
            string myGSMinfo = myGSM.ToString();
            Console.WriteLine(myGSMinfo);

            GSM mySecondGSM = GSM.IPhone4S;

            Console.WriteLine(mySecondGSM);

            GSMTest test = new GSMTest();
            test.Create4GSMs();

            GSMCallHistoryTest secondTest = new GSMCallHistoryTest();
            secondTest.CallHistoryTest();
        }
Exemplo n.º 19
0
        static void Main()
        {
            var phones = new List <GSM>();

            var peshoPhone = new GSM("3310", "Nokia", 50, "Pesho");
            var goshoPhone = new GSM("Galaxy S6", "Samsung", 200, "Gosho");
            var toshoPhone = new GSM("p9", "Huawei", 250, "Tosho");

            GSM.IPhone4S = new GSM("s6", "Apple", 300, "Ivan");
            phones.Add(peshoPhone);
            phones.Add(goshoPhone);
            phones.Add(toshoPhone);
            phones.Add(GSM.IPhone4S);
            foreach (var phone in phones)
            {
                Console.WriteLine(phone.ToString());
            }

            GSMCallHistoryTest test = new GSMCallHistoryTest();
        }
Exemplo n.º 20
0
        public static void Main(string[] args)
        {
            GSM[] phones = new GSM[3];
            phones[0] = new GSM("Samsung", "GalaxyS", 500.00m, "Jhon", "Smith", "Li-Ion", 730, 16, BatteryType.LiIon, 6d, 2000000);
            phones[1] = new GSM("Sony", "Xperia");
            //phones[2] = new GSM(); // try to instance parameterless GSM - compile error
            phones[2] = GSM.IPhone4s;
            //phones[2].Model = "Samsung"; //try to change ReadOnly field - compile error

            phones[1].Owner = new Owner("Peter", "Pan");

            //phones[2].DisplayNumberOfColors = -20; // try to set negative numbers of colors - throw exception
            phones[1].Display.NumberOfColors = 500;
            phones[1].Battery.Model          = "7m";

            foreach (var phone in phones)
            {
                Console.WriteLine(phone);
                Console.WriteLine();
            }
        }
 public void CallHistoryTest()
 {
     GSM myPhone = new GSM("Lumia", "Nokia");
             //public Call(string date, string time, string dialed, long duration)
     List<Call> someCalls =new List<Call> {
     new Call("02.02.2015", "15:45", "0896232333", 56),
     new Call("03.18.2015", "11:45", "0852454555", 13),
     new Call("01.02.2015", "00:05", "0899656598", 118),
     new Call("03.15.2015", "18:32", "0896232333", 65)};
     foreach (Call a in someCalls)
     { myPhone.AddCall(a); }
     myPhone.DisplayCalls();
     double price = 0.37;
     Console.WriteLine("With price of 0.37 per minute, the total cost of the calls:" + myPhone.CalcPrice(price/60));
     Console.WriteLine("Removing the longest call ...");
     myPhone.DeleteCall(someCalls[2]);
     Console.WriteLine("With price of 0.37 per minute, the total cost of the calls:" + myPhone.CalcPrice(price / 60));
     myPhone.ClearHistory();
     Console.WriteLine("History Cleared");
     Console.WriteLine("Current History:");
     myPhone.DisplayCalls();
 }
Exemplo n.º 22
0
        static void CallHistoryTest()
        {
            decimal pricePerMinute = 0.37m;

            Console.WriteLine("Let we test th call history! Ready? ...................\n");

            GSM GFlex = new GSM("G-Flex", "LG", (decimal)399.99, "Pavkata",
                                new Battery("G5", 90, 8, BatteryType.LithiumPolymer),
                                new Display((decimal)5.2, 16000000));

            GFlex.AddCall(new Calls("01/01/2001", "00:01", "0883654675", 567));
            GFlex.AddCall(new Calls("20/07/2013", "22:40", "0894223760", 120));
            GFlex.AddCall(new Calls("29/02/2016", "05:10", "0899132465", 221));
            GFlex.AddCall(new Calls("16/06/2016", "11:59", "0895386583", 21));
            GFlex.AddCall(new Calls("31/06/2016", "06:09", "0877975201", 243));

            for (int i = 0; i < GFlex.History.Count; i++)
            {
                Console.WriteLine(GFlex.History[i]);
            }

            Console.WriteLine("Calls Price: {0:F2}", GFlex.totalPrice(pricePerMinute));

            Calls longest = GFlex.History[0];

            foreach (var call in GFlex.History)
            {
                if (call.CallDuration > longest.CallDuration)
                {
                    longest = call;
                }
            }
            GFlex.DeleteCall(longest);
            Console.WriteLine("Calls Price without longest: {0:F2}", GFlex.totalPrice(pricePerMinute));

            GFlex.ClearCallHistory();
            Console.WriteLine("Call history cleared!");
        }
Exemplo n.º 23
0
        public static void Test()
        {
            GSM phone = new GSM("Samsung", "Galaxy S3");

            //Add calls
            GSMCallHistoryTest.Calls = new List <Calls>
            {
                new Calls(new DateTime(2015, 03, 17, 10, 32, 23), "0887591529", 35),
                new Calls(new DateTime(2015, 03, 17, 11, 32, 23), "0887595629", 56),
                new Calls(new DateTime(2015, 03, 17, 13, 32, 23), "0887576529", 39)
            };
            foreach (Calls call in GSMCallHistoryTest.Calls)
            {
                phone.AddCall(call);
            }

            GSMCallHistoryTest.PrintInfoCalls(GSM.CallHistory);

            Console.WriteLine("Total price is {0:F2}", GSM.CalculateTotalPrice(0.37));
            RemoveLongestCall(phone, GSM.CallHistory);
            Console.WriteLine("Total price without the longest call is {0:F2}", GSM.CalculateTotalPrice(0.37));
            phone.ClearCallHistory();
        }
Exemplo n.º 24
0
        public static void Test()
        {
            GSM phone = new GSM("Samsung", "Galaxy S3");

            //Add calls
            GSMCallHistoryTest.Calls = new List<Calls>
            {
                new Calls(new DateTime(2015, 03, 17, 10, 32, 23), "0887591529", 35),
                new Calls(new DateTime(2015, 03, 17, 11, 32, 23), "0887595629", 56),
                new Calls(new DateTime(2015, 03, 17, 13, 32, 23), "0887576529", 39)
            };
            foreach (Calls call in GSMCallHistoryTest.Calls)
            {
                phone.AddCall(call);
            }

            GSMCallHistoryTest.PrintInfoCalls(GSM.CallHistory);

            Console.WriteLine("Total price is {0:F2}", GSM.CalculateTotalPrice(0.37));
            RemoveLongestCall(phone, GSM.CallHistory);
            Console.WriteLine("Total price without the longest call is {0:F2}", GSM.CalculateTotalPrice(0.37));
            phone.ClearCallHistory();
        }
Exemplo n.º 25
0
        public static void CallHistoryTest()
        {
            Console.WriteLine("*************Call History Test*************");
            //Create an instance of the GSM class.
            GSM samsung = new GSM("S5", "Samsung", 1000, "Ivancho", new Battery("G2", 50, 5, BatteryType.LiIon), new Display(5, 500000));

            //Add few calls.
            samsung.AddCall(new Call("30/05/2016", "14:06", "0884089756", 104));
            samsung.AddCall(new Call("23/01/2015", "12:42", "0883208975", 311));
            samsung.AddCall(new Call("31/04/2016", "11:12", "0884589752", 151));

            //Display the information about the calls.
            for (int i = 0; i < samsung.CallHistory.Count; i++)
            {
                Console.WriteLine(samsung.CallHistory[i]);
            }

            //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            Console.WriteLine("Calls Price: {0:f2}", samsung.GetTotalCallPrice(0.37m));

            //Remove the longest call from the history and calculate the total price again.
            Call longestCall = samsung.CallHistory[0];

            foreach (var call in samsung.CallHistory)
            {
                if (call.Duration > longestCall.Duration)
                {
                    longestCall = call;
                }
            }
            samsung.DeleteCall(longestCall);
            Console.WriteLine("Calls Price without longest: {0:f2}", samsung.GetTotalCallPrice(0.37m));

            //Finally clear the call history and print it.
            samsung.ClearCallHistory();
            Console.WriteLine("Call history cleared!");
        }
Exemplo n.º 26
0
        public static void Test()
        {
            Console.WriteLine("Let we make a GSM test...\n");

            GSM[] phoneTest = new GSM[]
            {
                new GSM("Xperia Z5", "Sony", 1000, "Bastian Schweinsteiger",
                        new Battery("Zver", 120, 20, BatteryType.LiIon),
                        new Display((decimal)5.5, 16000000)),
                new GSM("G-Flex", "LG", (decimal)399.99, "Pavkata",
                        new Battery("G5", 90, 8, BatteryType.LithiumPolymer),
                        new Display((decimal)5.2, 16000000)),
                new GSM("T280i", "Sony Ericsson", 40, "Yanko",
                        new Battery("2005", 48, 3, BatteryType.NiCd),
                        new Display((decimal)1.7, 65000)),
                GSM.Iphone4S
            };

            foreach (var gsm in phoneTest)
            {
                Console.WriteLine(gsm.ToString());
            }
            Console.WriteLine();
        }
Exemplo n.º 27
0
        public void CallHistoryTest()
        {
            GSM peshoGSM = new GSM("Nokia", "Nokia");
            Call firstCall = new Call(DateTime.Now, "0888080808", 3000);
            Call secondCall = new Call(DateTime.Now,"0888080808", 3500);
            Call thirdCall = new Call(DateTime.Now, "0888080808", 2000);
            peshoGSM.AddCall(firstCall);
            peshoGSM.AddCall(secondCall);
            peshoGSM.AddCall(thirdCall);

            Console.WriteLine(peshoGSM.CallHistoryInfo());

            decimal price = 0.37M;

            Console.WriteLine("Total price: {0:F2}",peshoGSM.CalculateTotalPriceOfCalls(price));

            int longest=0;
            Call longestCall = new Call(DateTime.Now,"0888888888",0);

            for (int i = 0; i < peshoGSM.CallHistory.Count; i++)
            {
                if (peshoGSM.CallHistory[i].Duration > longest)
                {
                    longest = peshoGSM.CallHistory[i].Duration;
                    longestCall = peshoGSM.CallHistory[i];
                }
            }

            peshoGSM.DeleteCall(longestCall);

            Console.WriteLine("Total price after longest call has been removed: {0:F2}", peshoGSM.CalculateTotalPriceOfCalls(price));

            peshoGSM.ClearCalls();

            peshoGSM.CallHistoryInfo();
        }
Exemplo n.º 28
0
 /// <summary>
 /// Adding and removing calls
 /// </summary>
 /// <param name="decision">add/remove</param>
 public void AddAndRemove(string decision, GSM currentGSM)
 {
     if (decision.ToLower() == "add")
     {
         Console.WriteLine("Enter number: ");
         string number = Console.ReadLine();
         currentGSM.resentCall = new Call(number);
         this.CallHistory.Add(currentGSM.resentCall);
     }
     else if (decision.ToLower() == "remove")
     {
         Console.WriteLine("Enter the position of the number you want to remove [from 1 to {0}]", this.CallHistory.Count);
         int removeIndexer = int.Parse(Console.ReadLine()) - 1;
         if (removeIndexer < 0 || removeIndexer > this.CallHistory.Count - 1)
         {
             throw new ArgumentException("Wrong index");
         }
         else
         {
             Console.WriteLine("You removed the call with number {0}", this.CallHistory[removeIndexer].LastNumber);
             this.CallHistory.RemoveAt(removeIndexer);
         }
     }
 }
Exemplo n.º 29
0
        public static void Test()
        {
            var phone = new GSM("MyPhone", "Apple");

            phone.AddCall(new Call(DateTime.Now, "Pesho", 45));
            phone.AddCall(new Call(DateTime.Now, "Ivan", 18));
            phone.AddCall(new Call(DateTime.Now, "Gosho", 80));

            // phone.PrintCalls();
            Console.WriteLine(phone.CallsToString());

            Console.WriteLine("Total Price: {0:f2}", phone.CallsPrice(0.37));

            var longestCall = phone
                              .CheckCalls()
                              .OrderByDescending(x => x.Duration)
                              .FirstOrDefault();

            if (phone.RemoveCall(longestCall))
            {
                Console.WriteLine("Longest call was removed");
            }
            else
            {
                // if cant remove longest call then probably list is empty
                Console.WriteLine("Are you sure there are calls in phone call history?");
            }


            Console.WriteLine("Total Price: {0:f2}", phone.CallsPrice(0.37));

            phone.ClearHistory();

            //phone.PrintCalls();
            Console.WriteLine(phone.CallsToString());
        }
Exemplo n.º 30
0
 /// <summary>
 /// Adding and removing calls
 /// </summary>
 /// <param name="decision">add/remove</param>
 public void AddAndRemove(string decision, GSM currentGSM)
 {
     if (decision.ToLower() == "add")
     {
         Console.WriteLine("Enter number: ");
         string number = Console.ReadLine();
         currentGSM.resentCall = new Call(number);
         this.CallHistory.Add(currentGSM.resentCall);
     }
     else if (decision.ToLower() == "remove")
     {
         Console.WriteLine("Enter the position of the number you want to remove [from 1 to {0}]", this.CallHistory.Count);
         int removeIndexer = int.Parse(Console.ReadLine()) - 1;
         if (removeIndexer < 0 || removeIndexer > this.CallHistory.Count - 1)
         {
             throw new ArgumentException("Wrong index");
         }
         else
         {
             Console.WriteLine("You removed the call with number {0}", this.CallHistory[removeIndexer].LastNumber);
             this.CallHistory.RemoveAt(removeIndexer);
         }
     }
 }
Exemplo n.º 31
0
        public static void GSM_Test()
        {
            Console.WriteLine("*************GSM Test*************");

            //Creating an array of few instances of the GSM class.
            GSM[] phones = new GSM[]
            {
                new GSM("IPhone 6S", "Apple", 3000, "Gosho",
                        new Battery("G5", 444, 155, BatteryType.Toshiba), new Display(12, 51515561)),
                new GSM("S7", "Samsung", 3000, "Dobri",
                        new Battery("G5", 422, 134, BatteryType.NiMH), new Display(7, 323145151)),
                new GSM("S5", "Samsung", 1000, "Ivancho",
                        new Battery("G2", 50, 5, BatteryType.LiIon), new Display(5, 500000))
            };

            //Display the information about the GSMs in the array.
            for (int i = 0; i < phones.Length; i++)
            {
                Console.WriteLine(phones[i]);
            }

            //Display the information about the static property IPhone4S.
            Console.WriteLine(GSM.IPhone4S);
        }
Exemplo n.º 32
0
        public static void CallHistoryTest()
        {
            // Create an instance of the GSM class.
            GSM myFirstIPhone = new GSM(
                "IPhone5",
                "Apple",
                55.99,
                "Gosho Bacov",
                new Display(9, 500000000),
                new Battery(BatteryType.LithiumSulfur, "Li-lon", 10, 4.5),
                new Call(DateTime.Now, "0899 513 321", 60));


            // Add few calls.
            myFirstIPhone.AddCall(new Call(DateTime.UtcNow, "0888 888 888", 162));
            myFirstIPhone.AddCall(new Call(DateTime.Today, "0999 235 123", 42));
            myFirstIPhone.AddCall(new Call(DateTime.Now, "0999 999 999", 70));


            // Display the information about the calls.
            var historyCalls = myFirstIPhone.CallHistory;

            foreach (var call in historyCalls)
            {
                Console.WriteLine(call.ToString());
                Console.WriteLine();
            }


            // Assuming that the price per minute is 0.37 calculate
            // and print the total price of the calls in the history.
            double price;

            price = myFirstIPhone.CallPrice(myFirstIPhone.CallHistory);
            Console.WriteLine($"{price:F2}");
            Console.WriteLine();


            // Remove the longest call from the history and calculate the total price again.
            var  historyCallsList = myFirstIPhone.CallHistory;
            int  longestCall      = historyCallsList[0].DurationInSeconds;
            Call callForRemuve    = myFirstIPhone.CallHistory[0];

            foreach (var call in historyCallsList)
            {
                if (longestCall < call.DurationInSeconds)
                {
                    callForRemuve = call;
                }
            }
            myFirstIPhone.DelCall(callForRemuve);

            // print again
            historyCalls = myFirstIPhone.CallHistory;
            foreach (var call in historyCalls)
            {
                Console.WriteLine(call.ToString());
                Console.WriteLine();
            }

            double newPrice;

            newPrice = myFirstIPhone.CallPrice(myFirstIPhone.CallHistory);
            Console.WriteLine($"{newPrice:F2}");
            Console.WriteLine();


            // Finally clear the call history and print it.
            myFirstIPhone.ClearHistory();

            if (myFirstIPhone.CallHistory.Count == 0)
            {
                Console.WriteLine("Call history is EMPTY !!!");
            }
            else
            {
                historyCalls = myFirstIPhone.CallHistory;
                foreach (var call in historyCalls)
                {
                    Console.WriteLine(call.ToString());
                    Console.WriteLine();
                }
            }
        }
Exemplo n.º 33
0
 private static void PrintTotal(GSM myPhone)
 {
     myPhone.PrintCallsHistory();
     Console.WriteLine(">>>>> Total price: {0:f2} <<<<<", myPhone.TotalPrice());
     Console.WriteLine();
 }
Exemplo n.º 34
0
 public GSMTest(GSM[] phone)
 {
     GSMTest.phone = phone;
 }
Exemplo n.º 35
0
        private static void Main()
        {
            // Inserting data:
            GSM myPhone = new GSM("Nokia", "Nokia OOD");
            myPhone.Price = 500;
            myPhone.Owner = "Ivancho";
            myPhone.battery = new Battery(BatteryType.NiMH);
            myPhone.battery.HourIdle = 12;
            myPhone.battery.HoursTalk = 520;
            myPhone.display = new Display(12);
            myPhone.display.NumberOfColors = 326;

            // Transfering data and printing
            Console.WriteLine(myPhone.PrintMobileInfo(myPhone.battery, myPhone.display));

            // Iphone4S data:
            string theIPhoneInfo = GSM.IPhone4S;
            Console.WriteLine(theIPhoneInfo);

            // and ETC
            GSM phone = new GSM("Alcatel", "Alacatelov");
            GSMTest.CreateAFewGSMs(5);

            // Adding calls
            myPhone.resentCall = new Call("0898123231");
            Console.WriteLine(myPhone.resentCall.LastNumber);
            myPhone.CallHistory.Add(myPhone.resentCall);

            // Adding a second call
            myPhone.resentCall = new Call("08788765426");

            // Adding the call to the list
            myPhone.CallHistory.Add(myPhone.resentCall);
            foreach (Call talk in myPhone.CallHistory)
            {
                Console.WriteLine(talk.LastNumber);
            }

            // From here on, the adding to the callHistory is automatic
            myPhone.AddAndRemove("add", myPhone);
            myPhone.AddAndRemove("remove", myPhone);
            double totalPrice = myPhone.TotalPriceOfCalls(myPhone);

            // Not working because I don't have thread.sleep or something to make timespan
            Console.WriteLine("Total price: {0}", totalPrice);

            // Clearing the history
            myPhone.ClearHistory();
            GSMCallHistoryTest.GSMTest();
        }
Exemplo n.º 36
0
 public static void getInfoForIphone()
 {
     GSM.displayIphone4S();
 }
Exemplo n.º 37
0
Arquivo: GSMTest.cs Projeto: GAlex7/TA
 private static void PrintTotal(GSM myPhone)
 {
     myPhone.PrintCallsHistory();
     Console.WriteLine(">>>>> Total price: {0:f2} <<<<<", myPhone.TotalPrice());
     Console.WriteLine();
 }
Exemplo n.º 38
0
 static void Main(string[] args)
 {
     Battery battery1 = new Battery("asdasasd", "asdasdasd", "asdasdas", BatteryType.LIon);
     Display display1 = new Display("10x10", "Niggerian");
     GSM     number1  = new GSM("samsung", "galaxy", 300, "Shefa", battery1, display1);
 }
Exemplo n.º 39
0
        public double TotalPriceOfCalls(GSM currentGSM)
        {
            double totalPrice = 0;
            foreach (Call talk in currentGSM.CallHistory)
            {
                double totalMinutes = double.Parse(talk.Duration.Minutes.ToString());
                totalPrice += totalMinutes * 0.37;
            }

            return totalPrice;
        }