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;
- namespace _01.GSM_All_In_One
- {
- class Battery
- {
- public string Model { get; set; }
- public double? Idle { get; set; }
- public double? Talk { get; set; }
- //Print all Battery information
- public void Print()
- {
- Console.WriteLine("Battery Properties");
- Console.WriteLine("===================");
- Console.WriteLine("Model: {0}", this.Model);
- Console.WriteLine("Idle hours: {0}:{1,2} hours", (int)this.Idle, (this.Idle - (int)this.Idle)*60);
- Console.WriteLine("Talk hours: {0}:{1,2} hours", (int)this.Talk, (this.Talk - (int)this.Talk)*60);
- Console.WriteLine("===================");
- }
- }
- class Display
- {
- public double? Size { get; set; }
- public double? Colors { get; set; }
- //print all Display information
- public void Print()
- {
- Console.WriteLine("Display Properties");
- Console.WriteLine("===================");
- Console.WriteLine("Size: {0}''", this.Size);
- Console.WriteLine("Colors: {0} millions", this.Colors);
- Console.WriteLine("===================");
- }
- }
- class GSM
- {
- public string Model { get; set; }
- public string Manafacturer { get; set; }
- public decimal Price { get; set; }
- public string Owner { get; set; }
- public Battery Battery = new Battery();
- public Display Display = new Display();
- //Print all GSM information
- public void Print()
- {
- Console.WriteLine("GSM Properties");
- Console.WriteLine("===================");
- Console.WriteLine("Model: {0}", this.Model);
- Console.WriteLine("Manafacturer: {0}", this.Manafacturer);
- Console.WriteLine("Owner: {0}", this.Owner);
- Console.WriteLine("Price: {0} EUR", this.Price);
- Console.WriteLine("===================");
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- GSM myGSM = new GSM(); //by default all the value are null
- myGSM.Model = "3310";
- myGSM.Manafacturer = "Nokia";
- myGSM.Owner = "Kiril Petrov"; //fake name :)
- myGSM.Price = 345.21m;
- myGSM.Battery.Model = "Belkin";
- myGSM.Battery.Idle = 6.5; //hours in idle mode of type double
- myGSM.Battery.Talk = 1.5; //hours in talk mode of type double
- myGSM.Display.Size = 7.4; //size in inches
- myGSM.Display.Colors = 16.5; //colors in millions
- myGSM.Print(); //print GSM properties
- myGSM.Battery.Print(); //print Battery properties
- myGSM.Display.Print(); //print Display properties
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement