Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 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 Kodutöö6
  8. {
  9. interface IIron
  10. {
  11. void Descale();
  12. void DoIroning(string f);
  13. void DoIroning(int n);
  14. void UseSteam();
  15. void TurnOn();
  16. void TurnOff();
  17. }
  18. class RegularIron : IIron
  19. {
  20. public int temp;
  21. public string programName;
  22. public string ironType;
  23. public int used = 0;
  24. bool steam = false;
  25. bool on;
  26. public bool lin;
  27.  
  28.  
  29. public RegularIron()
  30. {
  31. ironType = "Regular Machiene";
  32. lin = false;
  33. }
  34.  
  35.  
  36.  
  37.  
  38. public virtual void Descale()
  39. {
  40. used = 0;
  41. Console.WriteLine("The machiene is cleaned");
  42. }
  43. public virtual void DoIroning(int _temp)
  44. {
  45. temp = _temp;
  46. if (used < 3 && on)
  47. {
  48. if (temp >= 90 && temp <= 119)
  49. {
  50. programName = "Synthetics program";
  51. }
  52. else if (temp >= 120 && temp <= 149)
  53. {
  54. programName = "Silk program";
  55. }
  56. else if (temp >= 150 && temp <= 199)
  57. {
  58. programName = "Cotton program";
  59. }
  60. else if (temp >= 200 && temp <= 230 && lin)
  61. {
  62. programName = "Linen program";
  63. UseSteam();
  64. }
  65. else
  66. {
  67. Console.WriteLine("Invalid temperature");
  68. }
  69. if (!steam)
  70. {
  71. Console.WriteLine(ironType + " is ironing with " + programName);
  72. }
  73. else
  74. {
  75. Console.WriteLine(ironType + " is ironing with " + programName + " with steam");
  76. steam = false;
  77. }
  78. used++;
  79.  
  80. }
  81. else
  82. {
  83. Console.WriteLine("The machiene needs cleaning, please descale");
  84. }
  85.  
  86. }
  87. public virtual void DoIroning(string programName)
  88. {
  89. Random rnd = new Random();
  90. if (used < 3 && on)
  91. {
  92.  
  93.  
  94.  
  95. if (programName == "Synthetics program")
  96. {
  97. temp = rnd.Next(90, 119);
  98. }
  99. else if (programName == "Silk program")
  100. {
  101. temp = rnd.Next(120, 149);
  102. }
  103. else if (programName == "Cotton program")
  104. {
  105. temp = rnd.Next(150, 199);
  106. }
  107. else if (programName == "Linen program" && lin)
  108. {
  109. temp = rnd.Next(200, 230);
  110. UseSteam();
  111. }
  112. else
  113. {
  114. Console.WriteLine("Invalid program! Use one of the four: Linen program, Cotton program, Silk program, Synthetics program");
  115. }
  116.  
  117. if (!steam)
  118. {
  119. Console.WriteLine(ironType + " is ironing with " + temp + "C");
  120. }
  121. else
  122. {
  123. Console.WriteLine(ironType + " is ironing with " + temp + "C" + " with steam");
  124. steam = false;
  125. }
  126. used++;
  127. }
  128. else
  129. {
  130. Console.WriteLine("The machiene needs cleaning, please descale");
  131. }
  132. }
  133. public virtual void UseSteam()
  134. {
  135. if (!steam && temp >= 120)
  136. {
  137. steam = true;
  138.  
  139. }
  140. else if (steam)
  141. {
  142. Console.WriteLine("Steam is already on");
  143. }
  144. else
  145. {
  146. Console.WriteLine("Not High enough temperature ");
  147. steam = false;
  148. }
  149.  
  150. }
  151. public void TurnOn()
  152. {
  153. on = true;
  154. Console.WriteLine("The iron is turned on!");
  155. }
  156. public void TurnOff()
  157. {
  158. on = false;
  159. Console.WriteLine("The console is turned off.");
  160. }
  161. }
  162. class PremiumIron : RegularIron
  163. {
  164. private bool light = false;
  165. private int usedSteam;
  166.  
  167. public PremiumIron()
  168. {
  169. ironType = ("Premium machiene");
  170. lin = false;
  171. }
  172.  
  173. public override void UseSteam()
  174. {
  175. base.UseSteam();
  176. usedSteam++;
  177. if(usedSteam == 2)
  178. {
  179. light = true;
  180. Console.WriteLine("Water low!");
  181. }
  182.  
  183. }
  184. public override void DoIroning(int _temp)
  185. {
  186. base.DoIroning(_temp);
  187. if (used == 3)
  188. {
  189. Descale();
  190. }
  191. }
  192. public override void DoIroning(string programName)
  193. {
  194. base.DoIroning(programName);
  195. if(used == 3)
  196. {
  197. Descale();
  198. }
  199. }
  200. }
  201. class LinenIron : RegularIron
  202. {
  203.  
  204. internal LinenIron()
  205. {
  206. ironType = "Linen machiene";
  207. lin = true;
  208. }
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217. }
  218. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement