Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace HW07_185221IABB
- {
- class Program
- {
- static void Main(string[] args)
- {
- RegularIron regular = new RegularIron();
- regular.TurnOn();
- regular.DoIroning();
- regular.UseSteam();
- regular.DoIroning();
- regular.DoIroning();
- regular.DoIroning();
- regular.DoIroning();
- regular.Descale();
- regular.DoIroning(10);
- regular.DoIroning("linen");
- Console.WriteLine();
- PremiumIron premium = new PremiumIron();
- premium.TurnOn();
- premium.DoIroning();
- premium.DoIroning();
- premium.DoIroning();
- premium.DoIroning();
- Console.WriteLine();
- LinenIron linen = new LinenIron();
- linen.TurnOn();
- linen.UseSteam();
- linen.DoIroning();
- linen.DoIroning(210);
- linen.DoIroning(10);
- linen.UseSteam();
- linen.DoIroning("linen");
- linen.DoIroning("sportswear");
- }
- }
- class RegularIron : IIron
- {
- internal bool _isOn;
- internal int _uses;
- internal bool _steamIsOn;
- internal int _minTemp;
- internal int _maxTemp;
- internal List<string> programs = new List<string>
- {
- "synthetics", "silk", "cotton"
- };
- public RegularIron()
- {
- _isOn = false;
- _uses = 0;
- _steamIsOn = false;
- _minTemp = 90;
- _maxTemp = 199;
- }
- public void Descale()
- {
- if (_isOn)
- {
- Console.WriteLine("Cleaned the machine!");
- _uses = 0;
- }
- }
- public void TurnOn()
- {
- if (_isOn == false)
- {
- _isOn = true;
- }
- else
- {
- Console.WriteLine("Machine is already on!");
- }
- }
- public void TurnOff()
- {
- if (_isOn)
- {
- _isOn = false;
- }
- else
- {
- Console.WriteLine("Machine is already off!");
- }
- }
- public virtual void UseSteam()
- {
- if (_steamIsOn == false)
- {
- _steamIsOn = true;
- }
- else
- {
- Console.WriteLine("Steam is already on");
- }
- }
- public virtual void DoIroning()
- {
- if (_uses <= 3)
- {
- if (_isOn)
- {
- if (_steamIsOn)
- {
- Console.WriteLine("Ironing (with steam)");
- _steamIsOn = false;
- }
- else
- {
- Console.WriteLine("Ironing...");
- }
- _uses++;
- }
- else
- {
- Console.WriteLine("You have to turn on the iron before you can use it");
- }
- }
- else
- {
- Console.WriteLine("Machine has been used 3 times and needs cleaning");
- }
- }
- public virtual void DoIroning(string program)
- {
- if (_isOn)
- {
- if (_uses <= 3)
- {
- if (programs.Contains(program))
- {
- if (program == ("cotton"))
- {
- Console.WriteLine("Ironing with 164 degrees");
- }
- else if (program == ("silk"))
- {
- Console.WriteLine("Ironing with 124 degrees");
- }
- else if (program == ("synthetics"))
- {
- Console.WriteLine("Ironing with 101 degrees");
- }
- _uses++;
- }
- else
- {
- Console.WriteLine("We don't have a program for ironing " + program);
- }
- }
- else
- {
- Console.WriteLine("Machine has been used 3 times and needs cleaning");
- }
- }
- else
- {
- Console.WriteLine("You have to turn on the iron before you can use it");
- }
- }
- public virtual void DoIroning(int temperature)
- {
- if (_isOn)
- {
- if (_uses <= 3)
- {
- if (temperature > _minTemp && temperature < _maxTemp)
- {
- if (temperature > 90 && temperature < 119)
- {
- Console.WriteLine("Ironing with synthectics program");
- }
- 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 (_steamIsOn && temperature < 120 && temperature > 199)
- {
- Console.Write(" (ironing with steam)");
- _steamIsOn = false;
- }
- _uses++;
- }
- else
- {
- Console.WriteLine("Invalid temperature range for ironing");
- }
- }
- else
- {
- Console.WriteLine("Machine has been used 3 times and needs cleaning");
- }
- }
- else
- {
- Console.WriteLine("You have to turn on the iron before you can use it");
- }
- }
- }
- class PremiumIron : RegularIron
- {
- private bool _lightIsOn;
- private int _steamUsed;
- public PremiumIron()
- {
- _lightIsOn = false;
- _steamUsed = 0;
- }
- public override void DoIroning()
- {
- base.DoIroning();
- if (_uses == 3)
- {
- Descale();
- }
- }
- public override void DoIroning(int temperature)
- {
- base.DoIroning(temperature);
- if (_uses == 3)
- {
- Descale();
- }
- }
- public override void DoIroning(string program)
- {
- base.DoIroning(program);
- if (_uses == 3)
- {
- Descale();
- }
- }
- public override void UseSteam()
- {
- base.UseSteam();
- _steamUsed++;
- if (_steamUsed == 2)
- {
- _lightIsOn = true;
- Console.WriteLine("LIGHT IS ON!");
- }
- }
- }
- class LinenIron : RegularIron
- {
- public LinenIron()
- {
- _maxTemp = 230;
- }
- public override void DoIroning(int temperature)
- {
- base.DoIroning(temperature);
- if (temperature > 200 && temperature < 230)
- {
- _steamIsOn = true;
- Console.WriteLine("Ironing with linen program");
- }
- }
- public override void DoIroning(string program)
- {
- programs.Add("linen");
- base.DoIroning(program);
- if (program == ("linen"))
- {
- _steamIsOn = true;
- Console.WriteLine("Ironing with 221 degrees");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement