示例#1
0
        static void Main()
        {
            var mobileList = new List <GSM>();

            Battery nokiaBattery   = new Battery("BJ51", 40, 12, BatteryType.LiIon);
            Battery sonyBattery    = new Battery("BA900", 30, 15, BatteryType.NiCd);
            Battery samsungBattery = new Battery("EB-L1G6LLA", 30, 15, BatteryType.NiMH);

            Display smallDisplay  = new Display(5, 16000000);
            Display mediumDisplay = new Display(7, 16000000);
            Display bigDisplay    = new Display(11, 16000000);

            GSM nokiaLumia = new GSM("Lumia630", "Nokia", 300.00, "Microsoft", nokiaBattery, smallDisplay);

            mobileList.Add(nokiaLumia);
            GSM sonyExperia = new GSM("XperiaM", "Sony", 350.00, "Sony", sonyBattery, mediumDisplay);

            mobileList.Add(sonyExperia);
            GSM samsungNote = new GSM("GalaxyNote", "Samsung", 600.00, "Samsung", samsungBattery, bigDisplay);

            mobileList.Add(samsungNote);

            foreach (var phone in mobileList)
            {
                Console.WriteLine(phone.ToString());
            }
            Console.WriteLine(GSM.GetIPhone());
        }
示例#2
0
        static void Main()
        {
            var mobileList = new List<GSM>();

            Battery nokiaBattery = new Battery("BJ51", 40, 12, BatteryType.LiIon);
            Battery sonyBattery = new Battery("BA900", 30, 15, BatteryType.NiCd);
            Battery samsungBattery = new Battery("EB-L1G6LLA", 30, 15, BatteryType.NiMH);

            Display smallDisplay = new Display(5, 16000000);
            Display mediumDisplay = new Display(7, 16000000);
            Display bigDisplay = new Display(11, 16000000);

            GSM nokiaLumia = new GSM("Lumia630", "Nokia", 300.00, "Microsoft", nokiaBattery, smallDisplay);
            mobileList.Add(nokiaLumia);
            GSM sonyExperia = new GSM("XperiaM", "Sony", 350.00, "Sony", sonyBattery, mediumDisplay);
            mobileList.Add(sonyExperia);
            GSM samsungNote = new GSM("GalaxyNote", "Samsung", 600.00, "Samsung", samsungBattery, bigDisplay);
            mobileList.Add(samsungNote);

            foreach (var phone in mobileList)
            {
                Console.WriteLine(phone.ToString());
            }
            Console.WriteLine(GSM.GetIPhone());
        }
示例#3
0
        static void Test()
        {
            GSM firstPhone  = new GSM("Galaxy Core Dou", "Samsung", 250, " ", "HugeBat", 200, 20, 5, 16000000);
            GSM secondPhone = new GSM("Galaxy Core Dou", "Samsung", 250);

            Console.WriteLine(GSM.IPhone4S);
            Console.WriteLine(firstPhone);
            Console.WriteLine(secondPhone);
        }
示例#4
0
 static void Main(string[] args)
 {
     GSM[] phoneArray = new GSM[2];
     phoneArray[0] = new GSM("Asha", "Nokia", "Jorj Ganchev", 120.99d,
                             new Battery("Nokia battery", 12d, 10.5d, BatteryType.LiIon),
                             new Display(7.5d, 16000000l));
     phoneArray[1] = new GSM("Desire", "HTC", "HTC owner");
     foreach (var phone in phoneArray)
     {
         Console.WriteLine(phone);
     }
     Console.WriteLine(GSM.IPhone4S);
 }
示例#5
0
文件: GSMTest.cs 项目: bankova/CSharp
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            GSM Nokia=new GSM("Nokia","NN",250, "Gogo", new Battery("82L", 12,10, BatteryType.LiIon), new Display(20,64));
            GSM HTC = new GSM("HTC", "NK", 130, "Na", new Battery("K9092", 26, 9, BatteryType.NiCd), new Display(10, 128));
            GSM Motorolla = new GSM("Motorolla", "NKH", 10, "Na", new Battery("L92", 13, 3, BatteryType.NiMH), new Display(12, 1024));

            GSM[] gsms=new GSM[]{Nokia, HTC, Motorolla};
            foreach (GSM phone in gsms)
            {
                Console.WriteLine(phone.ToString());
                Console.WriteLine();
            }
            Console.WriteLine(GSM.IPhone4s);
        }
示例#6
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            GSM Alcatel   = new GSM("OT-11", "Alcatel", 34.25m, new Person("Misho"), new Battery("j89", 5.4, 3.2, BatteryType.LiIon), new Display(3.6, 256));
            GSM Nokia     = new GSM("100", "Nokia", 250m, new Person("Gogo"), new Battery("82L", 12, 10, BatteryType.LiIon), new Display(20, 64));
            GSM HTC       = new GSM("NK", "HTC", 130m, new Person("Nana"), new Battery("K9092", 26, 9, BatteryType.NiCd), new Display(10, 128));
            GSM Motorolla = new GSM("A-12", "Motorolla", 10m, new Person("Ivo"), new Battery("L92", 13, 3, BatteryType.NiMH), new Display(12, 1024));

            GSM[] gsms = new GSM[] { Nokia, HTC, Motorolla };
            foreach (GSM phone in gsms)
            {
                Console.WriteLine(phone.ToString());
                Console.WriteLine();
            }
            Console.WriteLine(GSM.IPhone4S.ToString());
        }
        static void Main()
        {
            var phones = new GSM[]
            {
                new GSM("VIBE", "Lenovo"),
                new GSM("6", "IPhone", 1000m),
                new GSM("Galaxy S5", "Samsung", 850m, "Jhon Jakson"),
                new GSM("Mi5", "Xiaomi", 800m, "Natalie Klein", new Battery(BatteryType.LiIon, 250, 678)),
                new GSM("Xperia Z1", "Sony", 700m, "Niko Tomson", new Battery(BatteryType.NiCd, 150, 222))
            };

            foreach (var gsm in phones)
            {
                Console.WriteLine(gsm.ToString());
            }
        }
        static void Main()
        {
            GSM[] gsmArr = new GSM[3]
            {
                new GSM("Lumia ", " Nokia ", 850, " Pesho"),
                new GSM("Lumia925 ", " Nokia ", 450, " Gosho"),
                new GSM("3310 ", " Nokia ", 50, " Ivan"),
            };

            foreach (GSM item in gsmArr)
            {
                Console.WriteLine(item.ToString());
            }
            Console.WriteLine();
            Console.WriteLine("Apple phone: ");
            Console.WriteLine(GSM.IPhone4S);
        }
        static void Main()
        {
            GSM[] gsmArr = new GSM[3]
            {
            new GSM("Lumia ", " Nokia ", 850, " Pesho"),
            new GSM("Lumia925 ", " Nokia ", 450, " Gosho"),
            new GSM("3310 ", " Nokia ", 50, " Ivan"),
            };

            foreach (GSM item in gsmArr)
            {
                Console.WriteLine(item.ToString());
            }
            Console.WriteLine();
            Console.WriteLine("Apple phone: ");
            Console.WriteLine(GSM.IPhone4S);
        }
示例#10
0
        static void Main()
        {
            // Initializa with full constructor with inner instances
            GSM apple = new GSM("iPhone5s", "Apple", 1200, "Steve Jobs",
                                new Battery("Non-removable Li-Po 1560 mAh battery (5.92 Wh)", 250, 10, BatteryType.LiPro),
                                new Display(16, 1136, 640));

            // Declaring separate variable for Battery and Display
            Battery nokiaBattery = new Battery("Non-removable Li-Ion 3400 mAh battery (BV-4BW)", 672, 25, BatteryType.LiIon);
            Display nokiaDisplay = new Display(16, 1280, 720);

            // Initializa with full constructor with outer instances
            GSM nokia = new GSM("Lumia 1320", "Nokia", 1000, "Pesho", nokiaBattery, nokiaDisplay);

            // Initialize with minimum requested constructor
            GSM samsung = new GSM("Galaxy S4", "Samsung");

            // Using properties to set phone parameters
            samsung.Price   = 1250;
            samsung.Owner   = "Dr. Oh-Hyun Kwon";
            samsung.Battery = new Battery("Li-Ion 2600 mAh battery", 370, 17, BatteryType.LiIon);
            samsung.Display = new Display(16, 1920, 1080);

            // Creating array of gsms
            GSM[] gsms = new GSM[] { apple, nokia, samsung };

            // Print information about the gsms.
            // Note that method ToString() is overriden only to return the fields for the minimum requested. Otherwise there will be exceptions, because some of the fields may not be initialized
            for (int i = 0; i < gsms.Length; i++)
            {
                Console.WriteLine(gsms[i]); // No need to explicitly call ToString()
                Console.WriteLine("Price: {0}", gsms[i].Price);
                Console.WriteLine("Owner: {0}", gsms[i].Owner);
                Console.WriteLine(gsms[i].Battery);
                Console.WriteLine("Display size: {0}", gsms[i].Display.Size);
                Console.WriteLine();
            }

            // Print the static propertie IPhone4s
            Console.WriteLine(GSM.IPhone4s); // No need to explicitly call ToString()
            Console.WriteLine("Price: {0}", GSM.IPhone4s.Price);
            Console.WriteLine("Owner: {0}", GSM.IPhone4s.Owner);
            Console.WriteLine(GSM.IPhone4s.Battery);
            Console.WriteLine("Display size: {0}", GSM.IPhone4s.Display.Size);
        }
示例#11
0
        static void Main(string[] args)
        {
            GSM[] gsmDevices = new GSM[5];

            gsmDevices[0] = new GSM(
                "N95",
                "Nokia",
                650.60m,
                "Kukata",
                new Display(15, 65000),
                new Battery("Takashi", Battery.BatteryType.NiMH, 0, 0));

            gsmDevices[1] = new GSM("Touch Pro 2", "HTC", "VGeorgiev");
            gsmDevices[2] = new GSM("Galaxy", "Samsung", "Penka");
            gsmDevices[3] = new GSM("Touch Diamond", "HTC", "Stoki");
            gsmDevices[4] = new GSM();

            for (int i = 0; i < gsmDevices.Length; i++)
            {
                Console.WriteLine("Manufacturer: {0} , Model: {1}", gsmDevices[i].Manufacturer, gsmDevices[i].Model);
            }

            Console.WriteLine();

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

            // CAll i

            var device = new GSM("Touch Pro 2", "HTC", "Vlado");

            Call firstCall  = new Call(DateTime.Now, 180);
            Call secondCall = new Call(DateTime.Now, 560);
            Call thirdCall  = new Call(DateTime.Now, 340);

            device.AddCall(firstCall);
            device.AddCall(secondCall);
            device.AddCall(thirdCall);

            device.DeleteCall(firstCall);

            Console.WriteLine("Call duration: {0}s, Call price: {1:c}", device.CallHistoryDuration(), device.CallHystoryPrice());

            GSM.IPhone4S.Owner = "Pesho";
            Console.WriteLine(GSM.IPhone4S.Owner);
        }
示例#12
0
        static void Main()
        {
            GSM[] phones = new GSM[] { new GSM("Lumia", "Microsoft", "Pesho"), new GSM("Galaxy", "Samsung", "Gosho"), new GSM("Iphone 6", "Apple", "Asen") };

            phones[0].BatteryInfo.HoursTalk   = 325;
            phones[0].BatteryInfo.MAhCapacity = 4000;
            phones[1].DisplayInfo.Colors      = 256;
            phones[1].Price                   = 200;
            phones[2].DisplayInfo.Size        = 6;
            phones[2].BatteryInfo.MAhCapacity = 2000;

            foreach (GSM phone in phones)
            {
                Console.WriteLine(phone);
                Console.WriteLine();
            }

            Console.WriteLine(GSM.IPhone4S.Manufacturer + " " + GSM.IPhone4S.Model);
        }
示例#13
0
        static void Main(string[] args)
        {
            GSM[] gsms = new GSM[]
            {
                new GSM("N70", "Nokia"),
                new GSM("Sony Ericson", "Sony", 250, "Pesho", new Battery("model1", 20, 5, BatteryType.Li_Ion), new Display(3, 256)),
                new GSM("Galaxy S3III", "Samsung", 500, "Goro", new Battery("model4", 22, 7, BatteryType.NiCd), new Display(4, 1024)),
                new GSM("N70", "Nokia", 270, "Ivan", new Battery("model2", 20, 5, BatteryType.Li_Ion), new Display()),
                new GSM("Galaxy S3III", "Samsung", 150, "Stoyan", new Battery(), new Display(7, 512)),
            };

            foreach (var gsm in gsms)
            {
                Console.WriteLine(gsm.ToString());
                Console.WriteLine();
            }

            Console.WriteLine(GSM.IPhone4S);
        }
示例#14
0
 static void Main()
 {
     GSM[] phones = new GSM[10];
     for (int i = 0; i < phones.Length; i++)
     {
         string  model        = "Model " + (i + 1);
         string  manufacturer = "Manufacture " + (i * 10);
         decimal price        = i * 142M;
         string  owner        = "Pesho" + (i + 1);
         Display display      = new Display(0.5 * i + 1, (i + 2) * 1000);
         Battery battery      = new Battery("Bat" + i, (i + 1) * 12, (i + 1) * 3);
         battery.Type = (BatteryType)(i % 3);
         phones[i]    = new GSM(model, manufacturer, price, owner, battery, display);
     }
     foreach (var gsm in phones)
     {
         Console.WriteLine(gsm.ToString());
         Console.WriteLine();
     }
     Console.WriteLine(GSM.IPhone4S.ToString());
 }
示例#15
0
        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].OwnerFirstName  = "Peter";
            phones[1].OwnerSecondName = "Pan";

            phones[2].DisplayNumberOfColors = -20; // try to set negative numbers of colors - throw exeption
            phones[1].DisplayNumberOfColors = 500;
            phones[1].BatteryModel          = "7m";

            foreach (var phone in phones)
            {
                Console.WriteLine(phone);
                Console.WriteLine();
            }
        }
示例#16
0
 static GSM()
 {
     iPhone = new GSM("iPhone 4S", "Apple", 1000, "Will Smith",
                      new Battery("Apple", 12, 36, BatteryType.LiIon), new Display(7, 16000000));
 }
示例#17
0
 /// <summary>
 /// Static constructor, to initialize the static field
 /// </summary>
 static GSM()
 {
     IPhone4S = new GSM("iPhone4s", "Apple", 450, "Pesho",
                        new Battery("Non-removable Li-Po 1432 mAh battery (5.3 Wh)", 200, 14, BatteryType.LiPro),
                        new Display(16, 960, 640));
 }
示例#18
0
 static GSM()
 {
     iPhone = new GSM("iPhone 4S", "Apple", 1000, "Will Smith",
         new Battery("Apple", 12, 36, BatteryType.LiIon), new Display(7, 16000000));
 }