Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Define a class that holds information about a mobile phone device: model, manufacturer, price, owner, battery characteristics (model, hours idle and hours talk) and display characteristics (size and number of colors). Define 3 separate classes (class GSM holding instances of the classes Battery and Display).*/
- namespace GSM
- {
- using System;
- using System.Text;
- using System.Collections.Generic;
- //model, manufacturer, price, owner
- public class GSM
- {
- private readonly string model = null; //Declare only once
- private readonly string manufacturer = null;
- private int price = 0;
- private string owner = null;
- private Battery batery;
- private Display display;
- //private Display displayCharacters = new Display();
- public string Model
- {
- get { return this.model; }
- }
- public string Manufacturer
- {
- get { return this.manufacturer; }
- }
- public int Price
- {
- get { return this.price; }
- set
- {
- if (value < 0)
- {
- throw new ArgumentException("Invalid price : price can't be negative");
- }
- this.price = value;
- }
- } // check for price
- public string Owner
- {
- get { return this.owner; }
- set { this.owner = value; }
- }
- public GSM(string model, string manufacturer, int price, string owner)
- {
- this.model = model;
- this.manufacturer = manufacturer;
- this.price = price;
- this.owner = owner;
- this.batery = new Battery();
- this.display = new Display();
- }
- static void Main()
- {
- GSM firstGsm = new GSM("E51", "Manja", 700, "Pencho");
- firstGsm.batery.Model = "Li/Ion";
- firstGsm.batery.HoursIdle = 7;
- firstGsm.batery.HoursTalk = 7;
- firstGsm.display.Color = "16 milion";
- firstGsm.display.Size = "3 inch";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement