示例#1
0
 //, Display display
 // constructor
 public GSM(string model, string manufacturer, decimal price, string owner, Battery battery)
 {
     this.Model = model;
     this.Manufacturer = manufacturer;
     this.Price = price;
     this.Owner = owner;
     //this.DisplayPr = display; // ? can do this without this settings ? how ? what is differences ?
     this.BatteryPr = battery;
 }
示例#2
0
        static void Main(string[] args)
        {
            #region problem1
            GSM firstGSM = new GSM();
            firstGSM.Model = "Nokia";
            firstGSM.Manufacturer = "Germany";
            firstGSM.Price = 105.95M;
            firstGSM.Owner = "Peter";
            GSM secondGSM = new GSM();

            Console.WriteLine("\"{0}\" this is first model made in {2}, price - {3:C}, Owner - {4} \nand this \"{1}\" is second model.", firstGSM.Model, secondGSM.Model, firstGSM.Manufacturer, firstGSM.Price, firstGSM.Owner);

            Battery test = new Battery("NiCd", 14, 12);
            Console.WriteLine(test.ModelBattery + " - " + test.HoursIDLE + " - " + test.HoursTalk);
            GSM prob = new GSM();
            prob.DisplayPr.Size = 12;
            prob.DisplayPr.NumberColor = 32;
            prob.BatteryPr.HoursTalk = 10;

            Console.WriteLine("size - {0}, number of color(s) - {1}", prob.DisplayPr.Size, prob.DisplayPr.NumberColor);
            Console.WriteLine("Talk time {0} hour(s)", prob.BatteryPr.HoursTalk);
            Console.WriteLine();
            #endregion

            #region problem2
            // Problem 2
            Console.WriteLine("===== - Problem 2 - =====");
            double price = 199.90D;
            GSM problem2 = new GSM("Alcatel", 250);
            Console.WriteLine("New model of {0} cost {1} BGN", problem2.Model, problem2.Price);

            // second test2
            Battery batteryT2 = new Battery("Li-Ion");
            Display displayT2 = new Display(12.5);
            string nameT2 = "Motorola";
            GSM gsmT2 = new GSM(batteryT2, displayT2);
            Console.WriteLine("GSM {0}. Have battery - '{1}' and display - '{2}'.", nameT2, batteryT2.ModelBattery, displayT2.Size);
            Console.WriteLine();
            #endregion

            // problem 3
            #region problem3
            Console.WriteLine("===== - Problem 3 - =====");
            // BatteryType (Li-Ion, NiMH, NiCd, …)
            // BatteryType batteryT2 = new BatteryType();
            //Battery batteryT3 = new Battery(BatteryType.NiMH);
            //Console.WriteLine(batteryT3);
               // Display displayT3 = new Display(5);
               // GSM gsmT3 = new GSM(batteryT3, displayT3);
               // Console.WriteLine(gsmT3.BatteryPr.BatteryType);

            Console.WriteLine();
            #endregion
        }
示例#3
0
 // part constr
 public GSM(Battery battery, Display display)
 {
     this.BatteryPr = battery;
     this.DisplayPr = display;
 }