Advertisement
rendex

LaptopShop

Nov 19th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.26 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. namespace _2.LaptopShop
  5. {
  6. public class Laptop
  7. {
  8. private string model;
  9. private string manifacturer;
  10. private string processor;
  11. private int ram;
  12. private string graphicsCard;
  13. private string hdd;
  14. private string screen;
  15. private Baterry laptobBaterry;
  16. private double price;
  17.  
  18. public Laptop(string model, double price)
  19. {
  20. this.Model = model;
  21. this.Price = price;
  22. }
  23. public Laptop(string model, double price, string manifacturer = null, string processor = null, int ram = 0, string graphicsCard = null,
  24. string hdd = null, string screen = null, string batt = null, decimal battLife = 0):this(model,price)
  25. {
  26. this.Manifacturer = manifacturer;
  27. this.Processor = processor;
  28. this.Ram = ram;
  29. this.GraphicsCard = graphicsCard;
  30. this.Hdd = hdd;
  31. this.Screen = screen;
  32. this.laptobBaterry = new Baterry(batt, battLife);
  33. }
  34.  
  35. public string Model
  36. {
  37. get
  38. {
  39. return this.model;
  40. }
  41. set
  42. {
  43. if (string.IsNullOrEmpty(value))
  44. {
  45. throw new ArgumentException("The model cannot be a empty");
  46. }
  47. this.model = value;
  48. }
  49. }
  50. public string Manifacturer
  51. {
  52. get
  53. {
  54. return this.manifacturer;
  55. }
  56. set
  57. {
  58. if (string.IsNullOrEmpty(value))
  59. {
  60. throw new ArgumentException("Manifacturer value cannot be a empty");
  61. }
  62. this.manifacturer = value;
  63. }
  64. }
  65.  
  66. public string Processor
  67. {
  68. get
  69. {
  70. return this.processor;
  71. }
  72. set
  73. {
  74. if (string.IsNullOrEmpty(value))
  75. {
  76. throw new ArgumentException("Processor value cannot be a empty");
  77. }
  78. this.processor = value;
  79. }
  80. }
  81. public int Ram
  82. {
  83. get
  84. {
  85. return this.ram;
  86. }
  87. set
  88. {
  89. if (value < 0)
  90. {
  91. throw new ArgumentException("RAM cannot be a negative");
  92. }
  93. this.ram = value;
  94. }
  95. }
  96. public string GraphicsCard
  97. {
  98. get
  99. {
  100. return this.graphicsCard;
  101. }
  102. set
  103. {
  104. if (string.IsNullOrEmpty(value))
  105. {
  106. throw new ArgumentException("The graphicsCard cannot be a empty");
  107. }
  108. this.graphicsCard = value;
  109. }
  110. }
  111. public string Hdd
  112. {
  113. get
  114. {
  115. return this.hdd;
  116. }
  117. set
  118. {
  119. if (string.IsNullOrEmpty(value))
  120. {
  121. throw new ArgumentException("hdd cannot be a empty");
  122. }
  123. this.hdd = value;
  124. }
  125. }
  126. public string Screen
  127. {
  128. get
  129. {
  130. return this.screen;
  131. }
  132. set
  133. {
  134. if (string.IsNullOrEmpty(value))
  135. {
  136. throw new ArgumentException("The screen cannot be a empty");
  137. }
  138. this.screen = value;
  139. }
  140. }
  141. public double Price
  142. {
  143. get
  144. {
  145. return this.price;
  146. }
  147. set
  148. {
  149. if (value < 0)
  150. {
  151. throw new ArgumentException("The price cannot be a negative");
  152. }
  153. this.price = value;
  154. }
  155. }
  156.  
  157.  
  158.  
  159. public override string ToString()
  160. {
  161. string output = string.Format("Model: {0}\n", this.model);
  162. output += string.Format("Manifacturer: {0}\n", this.manifacturer);
  163. output += string.Format("Processor: {0}\n", this.processor);
  164. output += string.Format("RAM: {0} GB\n", this.ram);
  165. output += string.Format("GraphicssCard: {0}\n", this.graphicsCard);
  166. output += string.Format("HDD: {0}\n", this.hdd);
  167. output += string.Format("Screen: {0}\n", this.screen);
  168. output += string.Format("{0}", this.laptobBaterry);
  169. output += string.Format("Price: {0:f2}lv", this.price);
  170. return output;
  171. }
  172.  
  173.  
  174. static void Main()
  175. {
  176. Laptop lenovo = new Laptop("Lenovo Yoga 2 Pro", 2259.00, "Lenovo", "Intel Core i5-4210U (2-core, 1.70 - 2.70 GHz, 3MB cache)",
  177. 8, "Intel HD Graphics 4400", "128GB SSD", "13.3\" (33.78 cm) – 3200 x 1800 (QHD+), IPS sensor display",
  178. "Li-Ion, 4-cells, 2550 mAh", 4.5m);
  179. Console.WriteLine(lenovo.ToString());
  180.  
  181.  
  182.  
  183. }
  184. }
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement