Advertisement
Guest User

HW07

a guest
Oct 21st, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Hw07
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Regular Regular = new Regular();
  11.             Premium Premium = new Premium();
  12.             Linen Linen = new Linen();
  13.  
  14.             List<IIron> Irons = new List<IIron>();
  15.             Irons.Add(Regular);
  16.  
  17.             foreach (IIron a in Irons)
  18.             {
  19.                 a.TurnOn();
  20.                 a.doIroning();
  21.                 a.UseSteam();
  22.                 a.doIroning("Synthgetics");
  23.                 a.UseSteam();
  24.                 a.UseSteam();
  25.                 a.doIroning();
  26.                 a.doIroning();
  27.                 a.doIroning();
  28.                 a.Descale();
  29.                 a.doIroning(265);
  30.                 a.doIroning(2654);
  31.                 a.doIroning("Linen");
  32.             }
  33.         }
  34.     }
  35. }
  36.  
  37. --------------------------------------------------
  38.  
  39. using System;
  40. using System.Collections.Generic;
  41. using System.Text;
  42.  
  43. namespace Hw07
  44. {
  45.     interface IIron
  46.     {
  47.         void Descale();
  48.         void TurnOn();
  49.         void TurnOff();
  50.         void UseSteam();
  51.         void doIroning();
  52.         void doIroning(int Temperature);
  53.         void doIroning(string method);
  54.  
  55.     }
  56.  
  57.     class iron : IIron
  58.     {
  59.         internal string _power = ("Off");
  60.         internal int _temp;
  61.         internal int _uses;
  62.         internal string _Type;
  63.         internal string _usesSteam;
  64.         internal int _timesSteamIsUsed;
  65.  
  66.         public void Descale()
  67.         {
  68.             Console.WriteLine("Cleaned the machine!");
  69.             _uses = 0;
  70.         }
  71.  
  72.         public void TurnOn()
  73.         {
  74.             _power = ("On");
  75.         }
  76.  
  77.         public void TurnOff()
  78.         {
  79.             _power = ("Off");
  80.         }
  81.  
  82.         public void UseSteam()
  83.         {
  84.             if (_usesSteam != ("with steam"))
  85.             {
  86.                 _usesSteam = ("with steam");
  87.                 _timesSteamIsUsed++;
  88.             }
  89.             else
  90.             {
  91.                 Console.WriteLine("Steam is already on");
  92.             }
  93.  
  94.             if (_Type == ("Premium"))
  95.             {
  96.                 if (_timesSteamIsUsed >= 2)
  97.                 {
  98.                     Console.WriteLine("*Steam light is on*");
  99.                 }
  100.             }
  101.            
  102.  
  103.         }
  104.  
  105.         public void doIroning()
  106.         {
  107.             if (_uses <= 3)
  108.             {
  109.                 if (_power == ("On"))
  110.                 {
  111.                     Console.WriteLine("Ironing {0}", _usesSteam);
  112.                 }
  113.                 else
  114.                 {
  115.                     Console.WriteLine("You have to turn on the iron brfore you can use it");
  116.                 }
  117.             }
  118.             else
  119.             {
  120.                 if (_Type == ("Premium"))
  121.                 {
  122.                     Console.WriteLine("Machine needs cleaning, which is done automaticaly");
  123.                     _uses = 0;
  124.                 }
  125.                 else
  126.                 {
  127.                     Console.WriteLine("Machine must be cleaned!");
  128.                 }
  129.             _uses++;
  130.             }
  131.            
  132.             _usesSteam = ("");
  133.         }
  134.  
  135.         public void doIroning(string program)
  136.         {
  137.             if (_uses <= 3)
  138.             {
  139.                 if (program == ("Linen"))
  140.                 {
  141.                     if (_Type == ("Linen"))
  142.                     {
  143.                         _usesSteam = ("");
  144.                         _uses++;
  145.                         Console.WriteLine("Ironing at 221 degrees {0}!", _usesSteam);
  146.                     }
  147.                     else
  148.                     {
  149.                         Console.WriteLine("This model can't do Linen program!");
  150.                     }
  151.                 }
  152.                 else if (program == ("Cotton"))
  153.                 {
  154.                     Console.WriteLine("Ironing at 164 degrees {0}!", _usesSteam);
  155.                 }
  156.                 else if (program == ("Silk"))
  157.                 {
  158.                     _usesSteam = ("");
  159.                     _uses++;
  160.                     Console.WriteLine("Ironing at 124 degrees {0}!", _usesSteam);
  161.                 }
  162.                 else if(program == ("Synthetics"))
  163.                 {
  164.                     _usesSteam = ("");
  165.                     _uses++;
  166.                     if (_usesSteam == ("with steam"))
  167.                     {
  168.                         _usesSteam = ("without steam because temperature is not high enough!");
  169.                     }                  
  170.                     Console.WriteLine("Ironing at 101 degrees {0}!", _usesSteam);
  171.                 }
  172.                 else
  173.                 {
  174.                     Console.WriteLine("This machine can not do {0} prgram!", program);
  175.                 }
  176.                
  177.                 _usesSteam = ("");
  178.                 _uses++;
  179.             }
  180.             else
  181.             {
  182.                 if (_Type == ("Premium"))
  183.                 {
  184.                     Console.WriteLine("Machine needs cleaning, which is done automaticaly");
  185.                     _uses = 0;
  186.                 }
  187.                 else
  188.                 {
  189.                     Console.WriteLine("Machine must be cleaned!");
  190.                 }
  191.             }
  192.            
  193.         }
  194.         public void doIroning(int temperature)
  195.         {
  196.  
  197.             if (_uses <= 3)
  198.             {
  199.                 if (temperature >  90 && temperature < 119)
  200.                 {
  201.                     if (_usesSteam == ("with steam"))
  202.                     {
  203.                         _usesSteam = ("without steam because temperature is not high enough!");
  204.                     }
  205.                     Console.WriteLine("Ironing with synthectics program {0}", _usesSteam);
  206.                 }
  207.                 else if (temperature > 120 && temperature < 149)
  208.                 {
  209.                     Console.WriteLine("Ironing with silk program");
  210.                 }
  211.                 else if (temperature > 150 && temperature < 199)
  212.                 {
  213.                     Console.WriteLine("Ironing with cotton program");
  214.                 }
  215.                 else if (temperature > 200 && temperature < 230)
  216.                 {
  217.                     if (_Type == ("Linen"))
  218.                     {
  219.                         Console.WriteLine("Ironing with linen program");
  220.                     }
  221.                     else
  222.                     {
  223.                         Console.WriteLine("This machine can't iron with linen progam");
  224.                     }
  225.                 }
  226.                 _uses++;
  227.                 _usesSteam = ("");
  228.  
  229.             }
  230.             else
  231.             {
  232.                 if (_Type == ("Premium"))
  233.                 {
  234.                     Console.WriteLine("Machine needed cleaning so it cleaned itself!");
  235.                     _uses = 0;
  236.                 }
  237.                 else
  238.                 {
  239.                     Console.WriteLine("Machine needes cleaning!");
  240.                 }
  241.             }
  242.            
  243.         }
  244.  
  245.     }
  246.     class Regular : iron
  247.     {
  248.         public Regular()
  249.         {
  250.             _Type = ("Regular");
  251.         }
  252.            
  253.     }
  254.     class Premium : iron
  255.     {
  256.         public Premium()
  257.         {
  258.             _Type = ("Premium");
  259.         }
  260.     }
  261.         class Linen : iron
  262.         {
  263.         public Linen()
  264.         {
  265.             _Type = ("Linen");
  266.         }
  267.     }
  268.    
  269. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement