Advertisement
tutzy

Untitled

Jun 3rd, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _02.Laptop_Shop
  8. {
  9. class Laptop
  10. {
  11. private string model;
  12. private string manufacturer;
  13. private string processor;
  14. private int RAM;
  15. private string graphicsCard;
  16. private string HDD;
  17. private string screen;
  18. private double price;
  19. private Battery battryModel;
  20. private Battery batteryLife;
  21.  
  22. public Laptop(string model, double price) // first constructor
  23. {
  24. this.model = model;
  25. this.price = price;
  26. }
  27. public string Model // first property of first constructoe
  28. {
  29. get { return this.model; }
  30. set
  31. {
  32. if (String.IsNullOrEmpty(value))
  33. throw new ArgumentNullException("the model can`t be empty !");
  34. this.model = value;
  35. }
  36. }
  37. public double Price // second property of first constructoe
  38. {
  39. get { return this.price; }
  40. set
  41. {
  42. if (price < 0)
  43. throw new ArgumentOutOfRangeException("price can`t be negative number !");
  44. this.price = value;
  45. }
  46. }
  47.  
  48. public Laptop(string manufacturer = null, //second constructor
  49. string processor = null,
  50. int RAM = 0,
  51. string gaphicsCard = null,
  52. string hdd = null,
  53. string screen = null)
  54. {
  55. this.Manufacturer = manufacturer;
  56. this.Processor = processor;
  57. this.RAM = RAM;
  58. this.GaphicsCard = gaphicsCard;
  59. this.Hdd = hdd;
  60. }
  61.  
  62. public string Manufacturer
  63. {
  64. get { return this.manufacturer; }
  65. set
  66. {
  67. if (String.IsNullOrEmpty(value))
  68. this.manufacturer = "no set";
  69. }
  70. }
  71. public string Processor
  72. {
  73. get { return this.processor; }
  74. set
  75. {
  76. if (string.IsNullOrEmpty(value))
  77. this.processor = "no set";
  78. }
  79. }
  80. public int Ram
  81. {
  82. get { return this.Ram; }
  83. set
  84. {
  85. if (Ram < 0)
  86. {
  87. throw new ArgumentException("Ram must be positive number!");
  88. }
  89. this.Ram = value;
  90. }
  91. }
  92. public string GaphicsCard
  93. {
  94. get { return this.graphicsCard; }
  95. set { if(String.IsNullOrEmpty(value))
  96. this.graphicsCard = "no set"; }
  97. }
  98. public string Hdd
  99. {
  100. get { return this.Hdd; }
  101. set { if(String.IsNullOrEmpty(value))
  102. this.HDD = "no set"; }
  103. }
  104. public string Screen
  105. {
  106. get { return this.processor; }
  107. set {
  108. if(String.IsNullOrEmpty(value))
  109. this.processor = "no set"; }
  110. }
  111.  
  112. public Laptop(string model, double price, Battery baterryModel, double baterryLife)
  113. {
  114. }
  115.  
  116. public override string ToString()
  117. {
  118. 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);
  119. }
  120.  
  121.  
  122.  
  123.  
  124. }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement