Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Kodutöö6
- {
- interface IIron
- {
- void Descale();
- void DoIroning(string f);
- void DoIroning(int n);
- void UseSteam();
- void TurnOn();
- void TurnOff();
- }
- class RegularIron : IIron
- {
- public int temp;
- public string programName;
- public string ironType;
- public int used = 0;
- bool steam = false;
- bool on;
- public bool lin;
- public RegularIron()
- {
- ironType = "Regular Machiene";
- lin = false;
- }
- public virtual void Descale()
- {
- used = 0;
- Console.WriteLine("The machiene is cleaned");
- }
- public virtual void DoIroning(int _temp)
- {
- temp = _temp;
- if (used < 3 && on)
- {
- if (temp >= 90 && temp <= 119)
- {
- programName = "Synthetics program";
- }
- else if (temp >= 120 && temp <= 149)
- {
- programName = "Silk program";
- }
- else if (temp >= 150 && temp <= 199)
- {
- programName = "Cotton program";
- }
- else if (temp >= 200 && temp <= 230 && lin)
- {
- programName = "Linen program";
- UseSteam();
- }
- else
- {
- Console.WriteLine("Invalid temperature");
- }
- if (!steam)
- {
- Console.WriteLine(ironType + " is ironing with " + programName);
- }
- else
- {
- Console.WriteLine(ironType + " is ironing with " + programName + " with steam");
- steam = false;
- }
- used++;
- }
- else
- {
- Console.WriteLine("The machiene needs cleaning, please descale");
- }
- }
- public virtual void DoIroning(string programName)
- {
- Random rnd = new Random();
- if (used < 3 && on)
- {
- if (programName == "Synthetics program")
- {
- temp = rnd.Next(90, 119);
- }
- else if (programName == "Silk program")
- {
- temp = rnd.Next(120, 149);
- }
- else if (programName == "Cotton program")
- {
- temp = rnd.Next(150, 199);
- }
- else if (programName == "Linen program" && lin)
- {
- temp = rnd.Next(200, 230);
- UseSteam();
- }
- else
- {
- Console.WriteLine("Invalid program! Use one of the four: Linen program, Cotton program, Silk program, Synthetics program");
- }
- if (!steam)
- {
- Console.WriteLine(ironType + " is ironing with " + temp + "C");
- }
- else
- {
- Console.WriteLine(ironType + " is ironing with " + temp + "C" + " with steam");
- steam = false;
- }
- used++;
- }
- else
- {
- Console.WriteLine("The machiene needs cleaning, please descale");
- }
- }
- public virtual void UseSteam()
- {
- if (!steam && temp >= 120)
- {
- steam = true;
- }
- else if (steam)
- {
- Console.WriteLine("Steam is already on");
- }
- else
- {
- Console.WriteLine("Not High enough temperature ");
- steam = false;
- }
- }
- public void TurnOn()
- {
- on = true;
- Console.WriteLine("The iron is turned on!");
- }
- public void TurnOff()
- {
- on = false;
- Console.WriteLine("The console is turned off.");
- }
- }
- class PremiumIron : RegularIron
- {
- private bool light = false;
- private int usedSteam;
- public PremiumIron()
- {
- ironType = ("Premium machiene");
- lin = false;
- }
- public override void UseSteam()
- {
- base.UseSteam();
- usedSteam++;
- if(usedSteam == 2)
- {
- light = true;
- Console.WriteLine("Water low!");
- }
- }
- public override void DoIroning(int _temp)
- {
- base.DoIroning(_temp);
- if (used == 3)
- {
- Descale();
- }
- }
- public override void DoIroning(string programName)
- {
- base.DoIroning(programName);
- if(used == 3)
- {
- Descale();
- }
- }
- }
- class LinenIron : RegularIron
- {
- internal LinenIron()
- {
- ironType = "Linen machiene";
- lin = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement