Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace MobilePhoneDevice
- {
- internal class GSM
- {
- private string model;
- private string manufacturer;
- private Battery battery;
- public GSM(string model, string manufacturer, Battery battery)
- {
- this.Model = model;
- this.Manufacturer = manufacturer;
- this.Battery = battery;
- }
- public string Model
- {
- get
- {
- return this.model;
- }
- set
- {
- this.model = value;
- }
- }
- public string Manufacturer
- {
- get
- {
- return this.manufacturer;
- }
- set
- {
- this.manufacturer = value;
- }
- }
- public Battery Battery
- {
- get
- {
- return this.battery;
- }
- set
- {
- //if (this.battery.HoursIdle < 0)
- //{
- // throw new IndexOutOfRangeException("Hours idle cant be a negative number");
- //}
- this.battery = value;
- }
- }
- }
- class Battery
- {
- private int hoursIdle;
- public Battery(int hoursIdle)
- {
- this.HoursIdle = hoursIdle;
- }
- public int HoursIdle
- {
- get
- {
- return this.hoursIdle;
- }
- set
- {
- if (value < 0)
- {
- throw new IndexOutOfRangeException("Hours idle cant be a negative number");
- }
- this.hoursIdle = value;
- }
- }
- }
- public class MobilePhoneDevice
- {
- static void Main()
- {
- GSM asdf = new GSM("3310", "Nokia", new Battery(-1));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement