Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Hw07
- {
- class Program
- {
- static void Main(string[] args)
- {
- Regular Regular = new Regular();
- Premium Premium = new Premium();
- Linen Linen = new Linen();
- List<IIron> Irons = new List<IIron>();
- Irons.Add(Regular);
- foreach (IIron a in Irons)
- {
- a.TurnOn();
- a.doIroning();
- a.UseSteam();
- a.doIroning("Synthgetics");
- a.UseSteam();
- a.UseSteam();
- a.doIroning();
- a.doIroning();
- a.doIroning();
- a.Descale();
- a.doIroning(265);
- a.doIroning(2654);
- a.doIroning("Linen");
- }
- }
- }
- }
- --------------------------------------------------
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace Hw07
- {
- interface IIron
- {
- void Descale();
- void TurnOn();
- void TurnOff();
- void UseSteam();
- void doIroning();
- void doIroning(int Temperature);
- void doIroning(string method);
- }
- class iron : IIron
- {
- internal string _power = ("Off");
- internal int _temp;
- internal int _uses;
- internal string _Type;
- internal string _usesSteam;
- internal int _timesSteamIsUsed;
- public void Descale()
- {
- Console.WriteLine("Cleaned the machine!");
- _uses = 0;
- }
- public void TurnOn()
- {
- _power = ("On");
- }
- public void TurnOff()
- {
- _power = ("Off");
- }
- public void UseSteam()
- {
- if (_usesSteam != ("with steam"))
- {
- _usesSteam = ("with steam");
- _timesSteamIsUsed++;
- }
- else
- {
- Console.WriteLine("Steam is already on");
- }
- if (_Type == ("Premium"))
- {
- if (_timesSteamIsUsed >= 2)
- {
- Console.WriteLine("*Steam light is on*");
- }
- }
- }
- public void doIroning()
- {
- if (_uses <= 3)
- {
- if (_power == ("On"))
- {
- Console.WriteLine("Ironing {0}", _usesSteam);
- }
- else
- {
- Console.WriteLine("You have to turn on the iron brfore you can use it");
- }
- }
- else
- {
- if (_Type == ("Premium"))
- {
- Console.WriteLine("Machine needs cleaning, which is done automaticaly");
- _uses = 0;
- }
- else
- {
- Console.WriteLine("Machine must be cleaned!");
- }
- _uses++;
- }
- _usesSteam = ("");
- }
- public void doIroning(string program)
- {
- if (_uses <= 3)
- {
- if (program == ("Linen"))
- {
- if (_Type == ("Linen"))
- {
- _usesSteam = ("");
- _uses++;
- Console.WriteLine("Ironing at 221 degrees {0}!", _usesSteam);
- }
- else
- {
- Console.WriteLine("This model can't do Linen program!");
- }
- }
- else if (program == ("Cotton"))
- {
- Console.WriteLine("Ironing at 164 degrees {0}!", _usesSteam);
- }
- else if (program == ("Silk"))
- {
- _usesSteam = ("");
- _uses++;
- Console.WriteLine("Ironing at 124 degrees {0}!", _usesSteam);
- }
- else if(program == ("Synthetics"))
- {
- _usesSteam = ("");
- _uses++;
- if (_usesSteam == ("with steam"))
- {
- _usesSteam = ("without steam because temperature is not high enough!");
- }
- Console.WriteLine("Ironing at 101 degrees {0}!", _usesSteam);
- }
- else
- {
- Console.WriteLine("This machine can not do {0} prgram!", program);
- }
- _usesSteam = ("");
- _uses++;
- }
- else
- {
- if (_Type == ("Premium"))
- {
- Console.WriteLine("Machine needs cleaning, which is done automaticaly");
- _uses = 0;
- }
- else
- {
- Console.WriteLine("Machine must be cleaned!");
- }
- }
- }
- public void doIroning(int temperature)
- {
- if (_uses <= 3)
- {
- if (temperature > 90 && temperature < 119)
- {
- if (_usesSteam == ("with steam"))
- {
- _usesSteam = ("without steam because temperature is not high enough!");
- }
- Console.WriteLine("Ironing with synthectics program {0}", _usesSteam);
- }
- else if (temperature > 120 && temperature < 149)
- {
- Console.WriteLine("Ironing with silk program");
- }
- else if (temperature > 150 && temperature < 199)
- {
- Console.WriteLine("Ironing with cotton program");
- }
- else if (temperature > 200 && temperature < 230)
- {
- if (_Type == ("Linen"))
- {
- Console.WriteLine("Ironing with linen program");
- }
- else
- {
- Console.WriteLine("This machine can't iron with linen progam");
- }
- }
- _uses++;
- _usesSteam = ("");
- }
- else
- {
- if (_Type == ("Premium"))
- {
- Console.WriteLine("Machine needed cleaning so it cleaned itself!");
- _uses = 0;
- }
- else
- {
- Console.WriteLine("Machine needes cleaning!");
- }
- }
- }
- }
- class Regular : iron
- {
- public Regular()
- {
- _Type = ("Regular");
- }
- }
- class Premium : iron
- {
- public Premium()
- {
- _Type = ("Premium");
- }
- }
- class Linen : iron
- {
- public Linen()
- {
- _Type = ("Linen");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement