Skip to content
Open

20th #11

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions interface/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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}"
}
]
}
15 changes: 15 additions & 0 deletions interface/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/interface.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
126 changes: 126 additions & 0 deletions interface/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;

/// <summary>
/// Using an interface called IActivity a.k.a contract so that we can use it as a type instead of a concrete class type
/// </summary>
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<IActivity> _activities;

// Properties
// n/a

// Constructor
public Workflow()
{
_activities = new List<IActivity>
{
{ 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<IActivity> 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();
}
8 changes: 8 additions & 0 deletions interface/interface.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>

</Project>
26 changes: 26 additions & 0 deletions whiteboard20th/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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}"
}
]
}
15 changes: 15 additions & 0 deletions whiteboard20th/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/whiteboard20th.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
37 changes: 37 additions & 0 deletions whiteboard20th/Program.cs
Original file line number Diff line number Diff line change
@@ -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;
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;
}
}
}
8 changes: 8 additions & 0 deletions whiteboard20th/whiteboard20th.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>

</Project>