Advertisement
Guest User

Untitled

a guest
Sep 21st, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.97 KB | None | 0 0
  1. using System;
  2.  
  3. namespace MobilePhoneDevice
  4. {
  5.     internal class GSM
  6.     {
  7.         private string model;
  8.         private string manufacturer;
  9.         private Battery battery;
  10.  
  11.         public GSM(string model, string manufacturer, Battery battery)
  12.         {
  13.             this.Model = model;
  14.             this.Manufacturer = manufacturer;
  15.             this.Battery = battery;
  16.         }
  17.         public string Model
  18.         {
  19.             get
  20.             {
  21.                 return this.model;
  22.             }
  23.             set
  24.             {
  25.                 this.model = value;
  26.             }
  27.         }
  28.  
  29.         public string Manufacturer
  30.         {
  31.             get
  32.             {
  33.                 return this.manufacturer;
  34.             }
  35.             set
  36.             {
  37.                 this.manufacturer = value;
  38.             }
  39.         }
  40.  
  41.         public Battery Battery
  42.         {
  43.             get
  44.             {
  45.                 return this.battery;
  46.             }
  47.             set
  48.             {
  49.                 //if (this.battery.HoursIdle < 0)
  50.                 //{
  51.                 //    throw new IndexOutOfRangeException("Hours idle cant be a negative number");
  52.                 //}
  53.                 this.battery = value;
  54.             }
  55.         }
  56.     }
  57.  
  58.     class Battery
  59.     {
  60.         private int hoursIdle;
  61.         public Battery(int hoursIdle)
  62.         {
  63.             this.HoursIdle = hoursIdle;
  64.         }
  65.  
  66.         public int HoursIdle
  67.         {
  68.             get
  69.             {
  70.                 return this.hoursIdle;
  71.             }
  72.             set
  73.             {
  74.                 if (value < 0)
  75.                 {
  76.                     throw new IndexOutOfRangeException("Hours idle cant be a negative number");
  77.                 }
  78.                 this.hoursIdle = value;
  79.             }
  80.         }
  81.     }
  82.  
  83.     public class MobilePhoneDevice
  84.     {
  85.         static void Main()
  86.         {
  87.             GSM asdf = new GSM("3310", "Nokia", new Battery(-1));
  88.         }
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement