diff --git a/CommandPatternExample/CommandPatternApp/CalculatorCommandPattern.cs b/CommandPatternExample/CommandPatternApp/CalculatorCommandPattern.cs index 3ab0bf9c108f892e919a39771e7090401766ae85..ee441ee5ad997c750b2a4d584285b2eb84a4c08a 100644 --- a/CommandPatternExample/CommandPatternApp/CalculatorCommandPattern.cs +++ b/CommandPatternExample/CommandPatternApp/CalculatorCommandPattern.cs @@ -2,7 +2,7 @@ namespace newCalc; using display; using System.Collections.Generic; -public class CalcInvoker//Shot for Calculator invoker +public class CalcInvoker// invoker { public double DisplayValue {get; private set; } public Stack<ICommand> History { get; } = new Stack<ICommand>(); @@ -11,13 +11,13 @@ public class CalcInvoker//Shot for Calculator invoker { DisplayValue = 0; } - public void executeCommand(ICommand command) + public void executeCommand(ICommand command) //tager en command og executer den og gemmer den på stacken så man kan undo den senere { DisplayValue = command.execute(DisplayValue); History.Push(command); } - public void undoCommand() + public void undoCommand() // tager den sidste command på stacken og undo'er den { if(History.Count > 0) { @@ -27,18 +27,18 @@ public class CalcInvoker//Shot for Calculator invoker } } -public abstract class ICommand +public abstract class ICommand //hoved klassen som alle vores commands arver fra { protected Calc _calculator; public ICommand(Calc calculator) { _calculator = calculator; } - public abstract double execute(double currentDisplayValue); + public abstract double execute(double currentDisplayValue); // hver command skal implementere denne + undo public abstract double undo(double currentDisplayValue); } -public class AddCommand : ICommand +public class AddCommand : ICommand // En command { private readonly double _valueToAdd; diff --git a/CommandPatternExample/CommandPatternApp/OldCalculator.cs b/CommandPatternExample/CommandPatternApp/OldCalculator.cs deleted file mode 100644 index f8caa391073d4e16472858f42aeb0cc1c7f872f9..0000000000000000000000000000000000000000 --- a/CommandPatternExample/CommandPatternApp/OldCalculator.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace oldCalc; -public class OldCalc //Shot for Calculator -{ - public double DisplayValue; - public OldCalc() - { - DisplayValue = 0; - } - - public void Add(double value) - { - DisplayValue += value; - - } - public void subtract(double value) - { - DisplayValue -= value; - } - public void Multiply(double value) - { - DisplayValue *= value; - } - public void Divide(double value) - { - DisplayValue /= value; - } -} \ No newline at end of file diff --git a/CommandPatternExample/CommandPatternApp/Program.cs b/CommandPatternExample/CommandPatternApp/Program.cs index 38b058d5c5c6247d5aa01097c6f3a5c16b7dd8aa..77b737d886d63d15c3214d8aeb1f786e19fcf41c 100644 --- a/CommandPatternExample/CommandPatternApp/Program.cs +++ b/CommandPatternExample/CommandPatternApp/Program.cs @@ -1,36 +1,14 @@ -using oldCalc; -using newCalc; +using newCalc; using display; class Program { static void Main() { - Console.WriteLine("Testing OldCalc:"); - TestOldCalc(); - Console.WriteLine("Testing NewCalc:"); TestNewCalc(); - - } - static void TestOldCalc() - { - var calculator = new OldCalc(); - Console.WriteLine($"Start Value: {calculator.DisplayValue}"); - calculator.Add(100.0); - Console.WriteLine($"Value after add 100: {calculator.DisplayValue}"); - - calculator.subtract(50.0); - Console.WriteLine($"Value after subtract 50: {calculator.DisplayValue}"); - - calculator.Multiply(10.0); - Console.WriteLine($"Value after Multiply 10: {calculator.DisplayValue}"); - - calculator.Divide(2.0); - Console.WriteLine($"Value after Divide 2: {calculator.DisplayValue}"); - } - static void TestNewCalc() + static void TestNewCalc() // test af vores calculator { var calcInvoker = new CalcInvoker(); var calculator = new Calc(); diff --git a/CommandPatternExample/CommandPatternApp/obj/CommandPatternApp.csproj.nuget.dgspec.json b/CommandPatternExample/CommandPatternApp/obj/CommandPatternApp.csproj.nuget.dgspec.json index e914d6aace1599c8cc456eb4c2f794e70770ee20..9a552b554112313d8ac305b5c59bf2a5129b5b2d 100644 --- a/CommandPatternExample/CommandPatternApp/obj/CommandPatternApp.csproj.nuget.dgspec.json +++ b/CommandPatternExample/CommandPatternApp/obj/CommandPatternApp.csproj.nuget.dgspec.json @@ -1,17 +1,17 @@ { "format": 1, "restore": { - "c:\\Users\\ptras\\OneDrive - Aarhus universitet\\Dokumenter\\UNI\\4.Semester\\SWD\\Assignment1\\swd-hand-in-1\\CommandPatternExample\\CommandPatternApp\\CommandPatternApp.csproj": {} + "C:\\Users\\ptras\\OneDrive - Aarhus universitet\\Dokumenter\\UNI\\4.Semester\\SWD\\Assignment1\\swd-hand-in-1\\CommandPatternExample\\CommandPatternApp\\CommandPatternApp.csproj": {} }, "projects": { - "c:\\Users\\ptras\\OneDrive - Aarhus universitet\\Dokumenter\\UNI\\4.Semester\\SWD\\Assignment1\\swd-hand-in-1\\CommandPatternExample\\CommandPatternApp\\CommandPatternApp.csproj": { + "C:\\Users\\ptras\\OneDrive - Aarhus universitet\\Dokumenter\\UNI\\4.Semester\\SWD\\Assignment1\\swd-hand-in-1\\CommandPatternExample\\CommandPatternApp\\CommandPatternApp.csproj": { "version": "1.0.0", "restore": { - "projectUniqueName": "c:\\Users\\ptras\\OneDrive - Aarhus universitet\\Dokumenter\\UNI\\4.Semester\\SWD\\Assignment1\\swd-hand-in-1\\CommandPatternExample\\CommandPatternApp\\CommandPatternApp.csproj", + "projectUniqueName": "C:\\Users\\ptras\\OneDrive - Aarhus universitet\\Dokumenter\\UNI\\4.Semester\\SWD\\Assignment1\\swd-hand-in-1\\CommandPatternExample\\CommandPatternApp\\CommandPatternApp.csproj", "projectName": "CommandPatternApp", - "projectPath": "c:\\Users\\ptras\\OneDrive - Aarhus universitet\\Dokumenter\\UNI\\4.Semester\\SWD\\Assignment1\\swd-hand-in-1\\CommandPatternExample\\CommandPatternApp\\CommandPatternApp.csproj", + "projectPath": "C:\\Users\\ptras\\OneDrive - Aarhus universitet\\Dokumenter\\UNI\\4.Semester\\SWD\\Assignment1\\swd-hand-in-1\\CommandPatternExample\\CommandPatternApp\\CommandPatternApp.csproj", "packagesPath": "C:\\Users\\ptras\\.nuget\\packages\\", - "outputPath": "c:\\Users\\ptras\\OneDrive - Aarhus universitet\\Dokumenter\\UNI\\4.Semester\\SWD\\Assignment1\\swd-hand-in-1\\CommandPatternExample\\CommandPatternApp\\obj\\", + "outputPath": "C:\\Users\\ptras\\OneDrive - Aarhus universitet\\Dokumenter\\UNI\\4.Semester\\SWD\\Assignment1\\swd-hand-in-1\\CommandPatternExample\\CommandPatternApp\\obj\\", "projectStyle": "PackageReference", "configFilePaths": [ "C:\\Users\\ptras\\AppData\\Roaming\\NuGet\\NuGet.Config", diff --git a/CommandPatternExample/CommandPatternApp/obj/CommandPatternApp.csproj.nuget.g.props b/CommandPatternExample/CommandPatternApp/obj/CommandPatternApp.csproj.nuget.g.props new file mode 100644 index 0000000000000000000000000000000000000000..6a9144eb0d5909641f5176453500a3ac77c29f54 --- /dev/null +++ b/CommandPatternExample/CommandPatternApp/obj/CommandPatternApp.csproj.nuget.g.props @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8" standalone="no"?> +<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' "> + <RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess> + <RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool> + <ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile> + <NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot> + <NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\ptras\.nuget\packages\</NuGetPackageFolders> + <NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle> + <NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.2</NuGetToolVersion> + </PropertyGroup> + <ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' "> + <SourceRoot Include="C:\Users\ptras\.nuget\packages\" /> + </ItemGroup> +</Project> \ No newline at end of file diff --git a/CommandPatternExample/CommandPatternApp/obj/CommandPatternApp.csproj.nuget.g.targets b/CommandPatternExample/CommandPatternApp/obj/CommandPatternApp.csproj.nuget.g.targets new file mode 100644 index 0000000000000000000000000000000000000000..3dc06ef3cc4057524bf5d2cd49936dff789cebe8 --- /dev/null +++ b/CommandPatternExample/CommandPatternApp/obj/CommandPatternApp.csproj.nuget.g.targets @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" standalone="no"?> +<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" /> \ No newline at end of file diff --git a/CommandPatternExample/CommandPatternApp/obj/Debug/net9.0/CommandPatternApp.AssemblyInfo.cs b/CommandPatternExample/CommandPatternApp/obj/Debug/net9.0/CommandPatternApp.AssemblyInfo.cs index 08bbc8df411db80392eb59265d4c28e508320153..028c98dbc50a3a794b6e0cfe521d382cba7c26b4 100644 --- a/CommandPatternExample/CommandPatternApp/obj/Debug/net9.0/CommandPatternApp.AssemblyInfo.cs +++ b/CommandPatternExample/CommandPatternApp/obj/Debug/net9.0/CommandPatternApp.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("CommandPatternApp")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1e753b1bce566c36439ed6544b1168709c9ad492")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2061c8df9d032c3d9eafdba9f3c400264045f9ba")] [assembly: System.Reflection.AssemblyProductAttribute("CommandPatternApp")] [assembly: System.Reflection.AssemblyTitleAttribute("CommandPatternApp")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/CommandPatternExample/CommandPatternApp/obj/Debug/net9.0/CommandPatternApp.AssemblyInfoInputs.cache b/CommandPatternExample/CommandPatternApp/obj/Debug/net9.0/CommandPatternApp.AssemblyInfoInputs.cache index 01f5caa9f940818ad9e42be76fb3f36ea4a1c615..e514cf9bd348471d05a9825d9d357aeb86fa4437 100644 --- a/CommandPatternExample/CommandPatternApp/obj/Debug/net9.0/CommandPatternApp.AssemblyInfoInputs.cache +++ b/CommandPatternExample/CommandPatternApp/obj/Debug/net9.0/CommandPatternApp.AssemblyInfoInputs.cache @@ -1 +1 @@ -1b7e356d89f1d78fbb76674d0ccff1c555d59733c1b987474dcb22e91e834cea +ac3a04efc198e2d800f38b6809429875b2c75033b02d49ba967dfad0afb9dc7b diff --git a/CommandPatternExample/CommandPatternApp/obj/Debug/net9.0/CommandPatternApp.assets.cache b/CommandPatternExample/CommandPatternApp/obj/Debug/net9.0/CommandPatternApp.assets.cache index 941742b48e0a66a67d2b80bd762b5ca241e9dbcd..669793546b9f08ae501791dfd910a6bc5d095389 100644 Binary files a/CommandPatternExample/CommandPatternApp/obj/Debug/net9.0/CommandPatternApp.assets.cache and b/CommandPatternExample/CommandPatternApp/obj/Debug/net9.0/CommandPatternApp.assets.cache differ diff --git a/CommandPatternExample/CommandPatternApp/obj/project.assets.json b/CommandPatternExample/CommandPatternApp/obj/project.assets.json new file mode 100644 index 0000000000000000000000000000000000000000..ee4a076ee6d67fa5e286a486632f751ac7afd8ff --- /dev/null +++ b/CommandPatternExample/CommandPatternApp/obj/project.assets.json @@ -0,0 +1,75 @@ +{ + "version": 3, + "targets": { + "net9.0": {} + }, + "libraries": {}, + "projectFileDependencyGroups": { + "net9.0": [] + }, + "packageFolders": { + "C:\\Users\\ptras\\.nuget\\packages\\": {} + }, + "project": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "C:\\Users\\ptras\\OneDrive - Aarhus universitet\\Dokumenter\\UNI\\4.Semester\\SWD\\Assignment1\\swd-hand-in-1\\CommandPatternExample\\CommandPatternApp\\CommandPatternApp.csproj", + "projectName": "CommandPatternApp", + "projectPath": "C:\\Users\\ptras\\OneDrive - Aarhus universitet\\Dokumenter\\UNI\\4.Semester\\SWD\\Assignment1\\swd-hand-in-1\\CommandPatternExample\\CommandPatternApp\\CommandPatternApp.csproj", + "packagesPath": "C:\\Users\\ptras\\.nuget\\packages\\", + "outputPath": "C:\\Users\\ptras\\OneDrive - Aarhus universitet\\Dokumenter\\UNI\\4.Semester\\SWD\\Assignment1\\swd-hand-in-1\\CommandPatternExample\\CommandPatternApp\\obj\\", + "projectStyle": "PackageReference", + "configFilePaths": [ + "C:\\Users\\ptras\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" + ], + "originalTargetFrameworks": [ + "net9.0" + ], + "sources": { + "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, + "C:\\Program Files\\dotnet\\library-packs": {}, + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net9.0": { + "targetAlias": "net9.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + }, + "restoreAuditProperties": { + "enableAudit": "true", + "auditLevel": "low", + "auditMode": "direct" + }, + "SdkAnalysisLevel": "9.0.100" + }, + "frameworks": { + "net9.0": { + "targetAlias": "net9.0", + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.102/PortableRuntimeIdentifierGraph.json" + } + } + } +} \ No newline at end of file diff --git a/CommandPatternExample/CommandPatternApp/obj/project.nuget.cache b/CommandPatternExample/CommandPatternApp/obj/project.nuget.cache index 9522da034bdcdd9cf3c38c1cb46c81634870090b..1b30cf77c37a8be49aea858e3b4097ba1398bdcb 100644 --- a/CommandPatternExample/CommandPatternApp/obj/project.nuget.cache +++ b/CommandPatternExample/CommandPatternApp/obj/project.nuget.cache @@ -1,8 +1,8 @@ { "version": 2, - "dgSpecHash": "EwqBCvISyZM=", + "dgSpecHash": "8/lmS8bhrhI=", "success": true, - "projectFilePath": "c:\\Users\\ptras\\OneDrive - Aarhus universitet\\Dokumenter\\UNI\\4.Semester\\SWD\\Assignment1\\swd-hand-in-1\\CommandPatternExample\\CommandPatternApp\\CommandPatternApp.csproj", + "projectFilePath": "C:\\Users\\ptras\\OneDrive - Aarhus universitet\\Dokumenter\\UNI\\4.Semester\\SWD\\Assignment1\\swd-hand-in-1\\CommandPatternExample\\CommandPatternApp\\CommandPatternApp.csproj", "expectedPackageFiles": [], "logs": [] } \ No newline at end of file