From 06aaa40f26e266c4f730a500ade69f495388bf83 Mon Sep 17 00:00:00 2001 From: MartinGamesCZ Date: Tue, 9 Dec 2025 15:21:29 +0100 Subject: [PATCH] Make it workie --- .gitignore | Bin 50 -> 83 bytes ConsoleApp1.sln | 6 ++++++ ConsoleApp1/ConsoleApp1.csproj | 1 + ConsoleApp1/ISystem.cs | 8 +++++-- ConsoleApp1/Program.cs | 35 +++++++++++++++++++++++++++++-- ConsoleApp1/System.cs | 37 ++++++++++++++++++++++++++++++++- 6 files changed, 82 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 6329e43050d5266679356f8123a68de44417e20c..a2435daa316626bc56614dedea0a86dbef66a347 100644 GIT binary patch delta 38 tcmXpCo?xWN%cbv}pI4lplj>MdV5pyznWyiPnpB#upO;!net8.0 enable enable + AnyCPU;ARM32 diff --git a/ConsoleApp1/ISystem.cs b/ConsoleApp1/ISystem.cs index 7f6aece..5b7dc0e 100644 --- a/ConsoleApp1/ISystem.cs +++ b/ConsoleApp1/ISystem.cs @@ -6,10 +6,14 @@ using System.Threading.Tasks; namespace ConsoleApp1 { - internal interface ISystem + public interface ISystem { + string Name { get; } + string Version { get; } + string SN { get; } + bool Start(); void Restart(); - void Quit(); + bool Quit(); } } diff --git a/ConsoleApp1/Program.cs b/ConsoleApp1/Program.cs index 3751555..619ff76 100644 --- a/ConsoleApp1/Program.cs +++ b/ConsoleApp1/Program.cs @@ -1,2 +1,33 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +using ConsoleApp1; + +internal class Program +{ + private static void Main(string[] args) + { + ISystem system1 = new ConsoleApp1.System("YouLikeToBreakYourSystemDontYa? Linux", "v1.0.0", "SN123"); + + Program.SystemTest(system1); + } + + static void SystemTest(ISystem sys) + { + Program.Advertise(sys); + + if (sys.Start()) + { + Console.WriteLine("[TEST] System running!"); + } + + sys.Restart(); + + if (sys.Quit()) + { + Console.WriteLine("[TEST] System quit!"); + } + } + + static void Advertise(ISystem sys) + { + Console.WriteLine($"Behold! The '{sys.Name}' is coming!"); + } +} \ No newline at end of file diff --git a/ConsoleApp1/System.cs b/ConsoleApp1/System.cs index a8ff22a..c426159 100644 --- a/ConsoleApp1/System.cs +++ b/ConsoleApp1/System.cs @@ -11,6 +11,7 @@ namespace ConsoleApp1 private string name; private string version; private string sn; + private bool isOn = false; public System(string name, string version, string sn) { @@ -25,7 +26,41 @@ namespace ConsoleApp1 public override string ToString() { - return $"Name: {this.name}\nVersion: {this.version}"; + return $" - Name: {this.name}\n - Version: {this.version}"; + } + + public bool Start() + { + if (this.isOn) return false; + + Console.WriteLine($"System starting..."); + this.isOn = true; + + return true; + } + + public void Restart() + { + Console.WriteLine("System restarting in:"); + + for (int i = 3; i > 0; i--) + { + Console.WriteLine(i); + Thread.Sleep(1000); + } + + this.Quit(); + this.Start(); + } + + public bool Quit() + { + if (!this.isOn) return false; + + Console.WriteLine($"System quiting..."); + this.isOn = false; + + return true; } } }