Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- class MyGSM
- {
- static void Main()
- {
- // some test what happens
- GSM mygsm = new GSM("k850", "sony ericsson");
- Console.Write("Phone manufacturer: {0}\nPhone model: {1}\nPhopne price: {2}\nPhone owner: {3}",mygsm.Manufacturer, mygsm.Model,mygsm.Price, mygsm.Owner);
- Console.WriteLine();
- //some other test
- //add gsm properties directly
- mygsm.Owner = "me";
- mygsm.Price = 0; //no negative value check implemented int this property!
- mygsm.Display.Size = 1000;
- mygsm.Display.Colors = 2;
- mygsm.Battery.HoursIdle = 1;
- mygsm.Battery.HoursTalk = 1;
- mygsm.Battery.Model = "who cares";
- //....
- //add new batery and than add it to the gsm
- Battery mybaterry = new Battery();
- mybaterry.Model = "blabla";
- mybaterry.HoursIdle = 1;
- mybaterry.HoursTalk = 0;
- mygsm.Battery = mybaterry;
- //and no more tests...I`m lazy
- }
- }
- public class GSM
- {
- Display gsmDisplay = new Display();
- Battery gsmBattery = new Battery();
- private string model;
- private string manufacturer;
- private int? price = null;
- private string owner = null;
- private Display display = new Display();
- private Battery battery = new Battery();
- public Display Display
- {
- get { return this.display; }
- set { this.display = value; }
- }
- public Battery Battery
- {
- get { return this.battery; }
- set { this.battery = value; }
- }
- public string Model
- {
- get { return this.model; }
- set { this.model = value; }
- }
- public string Manufacturer
- {
- get { return this.manufacturer; }
- set { this.manufacturer = value; }
- }
- public int? Price
- {
- get { return this.price; }
- set { this.price = value; }
- }
- public string Owner
- {
- get { return this.owner; }
- set { this.owner = value; }
- }
- public GSM(string model, string manufacturer)
- {
- this.Model = model;
- this.Manufacturer = manufacturer;
- }
- public GSM(string model, string manufacturer, int price) : this(model, manufacturer)
- {
- this.Price = price;
- }
- public GSM(string model, string manufacturer, int price, Display gsmDisplay, Battery gsmBattery)
- : this(model, manufacturer, price)
- {
- this.gsmDisplay = gsmDisplay;
- this.gsmBattery = gsmBattery;
- }
- public GSM(string model, string manufacturer, int price, Display gsmDisplay, Battery gsmBattery, string owner)
- : this(model, manufacturer, price, gsmDisplay, gsmBattery)
- {
- this.Owner = owner;
- }
- }
- public class Display
- {
- private int? size = null;
- private int? colors = null;
- public int? Size
- {
- get { return this.size; }
- set { this.size = value; }
- }
- public int? Colors
- {
- get { return this.colors; }
- set { this.colors = value; }
- }
- public Display()
- {
- }
- public Display(int size)
- {
- this.Size = size;
- }
- public Display(int size, int colors)
- : this(size)
- {
- this.Colors = colors;
- }
- }
- public class Battery
- {
- private string model = null;
- private int? hoursIdle = null;
- private int? hoursTalk = null;
- public string Model
- {
- get { return this.model; }
- set { this.model = value; }
- }
- public int? HoursIdle
- {
- get { return this.hoursIdle; }
- set { this.hoursIdle = value; }
- }
- public int? HoursTalk
- {
- get { return this.hoursTalk; }
- set { this.hoursTalk = value; }
- }
- public Battery()
- {
- }
- public Battery(string model)
- {
- this.Model = model;
- }
- public Battery(string model, int hoursIdle) : this(model)
- {
- this.HoursIdle = hoursIdle;
- }
- public Battery(string model, int hoursIdle, int hoursTalk) : this(model, hoursIdle)
- {
- this.HoursTalk = hoursTalk;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement