From 7051e0905a4c5183cce4d66ee65b37b1a46c17de Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Feb 2019 20:19:30 -0600 Subject: [PATCH 1/3] check unique --- whiteboard20th/.vscode/launch.json | 26 +++++++++++++++++++ whiteboard20th/.vscode/tasks.json | 15 +++++++++++ whiteboard20th/Program.cs | 37 ++++++++++++++++++++++++++++ whiteboard20th/whiteboard20th.csproj | 8 ++++++ 4 files changed, 86 insertions(+) create mode 100644 whiteboard20th/.vscode/launch.json create mode 100644 whiteboard20th/.vscode/tasks.json create mode 100644 whiteboard20th/Program.cs create mode 100644 whiteboard20th/whiteboard20th.csproj diff --git a/whiteboard20th/.vscode/launch.json b/whiteboard20th/.vscode/launch.json new file mode 100644 index 00000000..a2796bee --- /dev/null +++ b/whiteboard20th/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/whiteboard20th.dll", + "args": [], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/whiteboard20th/.vscode/tasks.json b/whiteboard20th/.vscode/tasks.json new file mode 100644 index 00000000..65b474fa --- /dev/null +++ b/whiteboard20th/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/whiteboard20th.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/whiteboard20th/Program.cs b/whiteboard20th/Program.cs new file mode 100644 index 00000000..5af5aa9c --- /dev/null +++ b/whiteboard20th/Program.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; + + +namespace whiteboard20th +{ + class Program + { + static void Main(string[] args) + { + string input = ""; + while (input == "") + { + input = Console.ReadLine(); + } + Console.WriteLine(UniqueChar.IsUnique(input) ? "All letters are unique" : "there are duplicate letters in that string"); + } + } + public class UniqueChar + { + public static bool IsUnique(string word) + { + bool returnMe = false; + foreach (var letter in word) + { + char temp = letter; + bool result = false; + foreach (var item in word) + { + result = temp == item ? true : false; + } + if (result) { returnMe = true; } + } + return returnMe; + } + } +} diff --git a/whiteboard20th/whiteboard20th.csproj b/whiteboard20th/whiteboard20th.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/whiteboard20th/whiteboard20th.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + From 2481e7d09ce7ab09503202a85d3c772eab118890 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Feb 2019 20:19:36 -0600 Subject: [PATCH 2/3] check unique --- whiteboard20th/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whiteboard20th/Program.cs b/whiteboard20th/Program.cs index 5af5aa9c..fa5a3422 100644 --- a/whiteboard20th/Program.cs +++ b/whiteboard20th/Program.cs @@ -20,7 +20,7 @@ public class UniqueChar { public static bool IsUnique(string word) { - bool returnMe = false; + bool returnMe; foreach (var letter in word) { char temp = letter; From 93e1c3e26b16c1c756b3e7f35a6d03d685f50547 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Feb 2019 21:05:30 -0600 Subject: [PATCH 3/3] finished abstract class --- interface/.vscode/launch.json | 26 +++++++ interface/.vscode/tasks.json | 15 ++++ interface/Program.cs | 126 ++++++++++++++++++++++++++++++++++ interface/interface.csproj | 8 +++ 4 files changed, 175 insertions(+) create mode 100644 interface/.vscode/launch.json create mode 100644 interface/.vscode/tasks.json create mode 100644 interface/Program.cs create mode 100644 interface/interface.csproj diff --git a/interface/.vscode/launch.json b/interface/.vscode/launch.json new file mode 100644 index 00000000..003bd295 --- /dev/null +++ b/interface/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/interface.dll", + "args": [], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/interface/.vscode/tasks.json b/interface/.vscode/tasks.json new file mode 100644 index 00000000..5588cc6c --- /dev/null +++ b/interface/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/interface.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/interface/Program.cs b/interface/Program.cs new file mode 100644 index 00000000..209647ed --- /dev/null +++ b/interface/Program.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; + +/// +/// Using an interface called IActivity a.k.a contract so that we can use it as a type instead of a concrete class type +/// +public class Program +{ + // Fields + static Engine _engine; + static Workflow _workflow; + + // Properties + // n/a + + // Constructor(s) + static Program() + { + _engine = new Engine(); + _workflow = new Workflow(); + } + + // Methods + public static void Main() + { + _engine.Run(_workflow); + } +} + +public class Engine +{ + // Fields + // n/a + + // Properties + // n/a + + // Constructor(s) + public Engine() + { + // not used + } + + // Methods + public void Run(Workflow workflow) + { + foreach (var activity in workflow.GetActivities()) + { + activity.Execute(); + } + } +} + +public class Workflow +{ + // Fields + List _activities; + + // Properties + // n/a + + // Constructor + public Workflow() + { + _activities = new List + { + { new SportActivity{Message = "Running..." } }, + { new SportActivity{Message = "Batting..." } }, + { new SportActivity{Message = "Kicking..." } }, + { new SportActivity{Message = "Dribbling..." } }, + { new OutdoorActivity{Message = "Fishing..." } }, + { new OutdoorActivity{Message = "Camping..." } }, + { new OutdoorActivity{Message = "Grilling..." } }, + { new IndoorActivity{Message = "Gaming..." } }, + { new IndoorActivity{Message = "Coding.." } }, + { new IndoorActivity{Message = "knitting..." } }, + }; + } + + // Methods + public List GetActivities() + { + return _activities; + } +} +public class IndoorActivity : Activity +{ + public override void Execute() + { + Console.WriteLine("Performing Indoor Activity: {0}", Message); + } +} + +public class SportActivity : Activity +{ + public override void Execute() + { + Console.WriteLine("Performing Sport Activity: {0}", Message); + } +} + +public class OutdoorActivity : Activity +{ + public override void Execute() + { + Console.WriteLine("Performing Outdoor Activity: {0}", Message); + } +} + + +//Here is an example of an interface +public interface IActivity +{ + // Properties + string Message { get; set; } + + // Methods + void Execute(); +} + +public abstract class Activity : IActivity +{ + public string Message { get; set; } + + public abstract void Execute(); +} \ No newline at end of file diff --git a/interface/interface.csproj b/interface/interface.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/interface/interface.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + +