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;
- namespace _02.Laptop_Shop
- {
- class Laptop
- {
- private string model;
- private string manufacturer;
- private string processor;
- private int RAM;
- private string graphicsCard;
- private string HDD;
- private string screen;
- private double price;
- private Battery battryModel;
- private Battery batteryLife;
- public Laptop(string model, double price) // first constructor
- {
- this.model = model;
- this.price = price;
- }
- public string Model // first property of first constructoe
- {
- get { return this.model; }
- set
- {
- if (String.IsNullOrEmpty(value))
- throw new ArgumentNullException("the model can`t be empty !");
- this.model = value;
- }
- }
- public double Price // second property of first constructoe
- {
- get { return this.price; }
- set
- {
- if (price < 0)
- throw new ArgumentOutOfRangeException("price can`t be negative number !");
- this.price = value;
- }
- }
- public Laptop(string manufacturer = null, //second constructor
- string processor = null,
- int RAM = 0,
- string gaphicsCard = null,
- string hdd = null,
- string screen = null)
- {
- this.Manufacturer = manufacturer;
- this.Processor = processor;
- this.RAM = RAM;
- this.GaphicsCard = gaphicsCard;
- this.Hdd = hdd;
- }
- public string Manufacturer
- {
- get { return this.manufacturer; }
- set
- {
- if (String.IsNullOrEmpty(value))
- this.manufacturer = "no set";
- }
- }
- public string Processor
- {
- get { return this.processor; }
- set
- {
- if (string.IsNullOrEmpty(value))
- this.processor = "no set";
- }
- }
- public int Ram
- {
- get { return this.Ram; }
- set
- {
- if (Ram < 0)
- {
- throw new ArgumentException("Ram must be positive number!");
- }
- this.Ram = value;
- }
- }
- public string GaphicsCard
- {
- get { return this.graphicsCard; }
- set { if(String.IsNullOrEmpty(value))
- this.graphicsCard = "no set"; }
- }
- public string Hdd
- {
- get { return this.Hdd; }
- set { if(String.IsNullOrEmpty(value))
- this.HDD = "no set"; }
- }
- public string Screen
- {
- get { return this.processor; }
- set {
- if(String.IsNullOrEmpty(value))
- this.processor = "no set"; }
- }
- public Laptop(string model, double price, Battery baterryModel, double baterryLife)
- {
- }
- public override string ToString()
- {
- return string.Format("model: {0} manufacturer: {1} processor: {2} RAM: {3} graphicsCard: {4} HDD: {5} screen: {6} price: {7} battery: {8} battery life: {9}", this.model, this.manufacturer, this.processor, this.Ram, this.graphicsCard, this.HDD, this.screen, this.price, this.battryModel, this.batteryLife);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement