diff --git a/AnimalClassification/.vscode/launch.json b/AnimalClassification/.vscode/launch.json
new file mode 100644
index 00000000..7bc7220c
--- /dev/null
+++ b/AnimalClassification/.vscode/launch.json
@@ -0,0 +1,28 @@
+{
+ // Use IntelliSense to find out which attributes exist for C# debugging
+ // Use hover for the description of the existing attributes
+ // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": ".NET Core Launch (console)",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ // If you have changed target frameworks, make sure to update the program path.
+ "program": "${workspaceFolder}/bin/Debug/netcoreapp2.1/AnimalClassification.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}",
+ // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
+ "console": "internalConsole",
+ "stopAtEntry": false,
+ "internalConsoleOptions": "openOnSessionStart"
+ },
+ {
+ "name": ".NET Core Attach",
+ "type": "coreclr",
+ "request": "attach",
+ "processId": "${command:pickProcess}"
+ }
+ ,]
+}
\ No newline at end of file
diff --git a/AnimalClassification/.vscode/tasks.json b/AnimalClassification/.vscode/tasks.json
new file mode 100644
index 00000000..de0b881e
--- /dev/null
+++ b/AnimalClassification/.vscode/tasks.json
@@ -0,0 +1,15 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build",
+ "${workspaceFolder}/AnimalClassification.csproj"
+ ],
+ "problemMatcher": "$msCompile"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/AnimalClassification/AnimalClassification.csproj b/AnimalClassification/AnimalClassification.csproj
new file mode 100644
index 00000000..23df6047
--- /dev/null
+++ b/AnimalClassification/AnimalClassification.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.1
+
+
+
diff --git a/AnimalClassification/Program.cs b/AnimalClassification/Program.cs
new file mode 100644
index 00000000..1234df8f
--- /dev/null
+++ b/AnimalClassification/Program.cs
@@ -0,0 +1,56 @@
+using System;
+
+namespace AnimalClassification
+{
+
+ public class Animal {
+
+ }
+
+ class Vertebrate : Animal {
+
+ }
+
+ class Invertebrate : Animal {
+
+ }
+
+ class WarmBlooded : Vertebrate {
+
+ }
+
+ class ColdBlooded : Vertebrate {
+
+ }
+
+ class WithLegs : Invertebrate {
+
+ }
+
+ class WithoutLegs : Invertebrate {
+
+ }
+
+ class Mammals : WarmBlooded {
+ bool livesOnLand;
+
+ }
+ class Birds : WarmBlooded {}
+ class Fish : ColdBlooded {}
+ class Reptiles : ColdBlooded {}
+ class Amphibians : ColdBlooded {}
+ class ThreePairsOfLegs : WithLegs {}
+ class MoreThanThreePairsOfLegs : WithLegs {}
+ class WormLike : WithoutLegs {}
+ class NotWormLike : WithoutLegs {}
+
+
+
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello World!");
+ }
+ }
+}
diff --git a/CarInheritance/.vscode/launch.json b/CarInheritance/.vscode/launch.json
new file mode 100644
index 00000000..8f5202d3
--- /dev/null
+++ b/CarInheritance/.vscode/launch.json
@@ -0,0 +1,28 @@
+{
+ // Use IntelliSense to find out which attributes exist for C# debugging
+ // Use hover for the description of the existing attributes
+ // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": ".NET Core Launch (console)",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ // If you have changed target frameworks, make sure to update the program path.
+ "program": "${workspaceFolder}/bin/Debug/netcoreapp2.1/CarInheritance.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}",
+ // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
+ "console": "internalConsole",
+ "stopAtEntry": false,
+ "internalConsoleOptions": "openOnSessionStart"
+ },
+ {
+ "name": ".NET Core Attach",
+ "type": "coreclr",
+ "request": "attach",
+ "processId": "${command:pickProcess}"
+ }
+ ,]
+}
\ No newline at end of file
diff --git a/CarInheritance/.vscode/tasks.json b/CarInheritance/.vscode/tasks.json
new file mode 100644
index 00000000..ae52861d
--- /dev/null
+++ b/CarInheritance/.vscode/tasks.json
@@ -0,0 +1,15 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build",
+ "${workspaceFolder}/CarInheritance.csproj"
+ ],
+ "problemMatcher": "$msCompile"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/CarInheritance/CarInheritance.csproj b/CarInheritance/CarInheritance.csproj
new file mode 100644
index 00000000..23df6047
--- /dev/null
+++ b/CarInheritance/CarInheritance.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.1
+
+
+
diff --git a/CarInheritance/Program.cs b/CarInheritance/Program.cs
new file mode 100644
index 00000000..a7f313d0
--- /dev/null
+++ b/CarInheritance/Program.cs
@@ -0,0 +1,91 @@
+using System;
+
+namespace CarInheritance
+{
+ class Program
+ {
+
+
+
+
+
+
+ static void Main(string[] args)
+ {
+ Van aVan = new Van(true,true,"white",4,4,true,6);
+ Truck gravedigga = new Truck(1,4,"green and black like a can of Monster",4,4,true,6);
+ Motorcycle aMotorcycle = new Motorcycle(true, true, "red", 3, 2, true, 4);
+
+
+ Console.WriteLine("Inheritance practice!");
+
+ Console.WriteLine("aTruck's color is " + aVan.color);
+ Console.WriteLine("aMotorcycle's color is " + aMotorcycle.color);
+ Console.WriteLine("Gravedigga's color is " + gravedigga.color);
+
+ Console.WriteLine("aVan honks like " + aVan.honk());
+ Console.WriteLine("Gravedigga honks like " + gravedigga.honk());
+ Console.WriteLine("aMotorcycle honks like " + aMotorcycle.honk());
+ }
+ }
+
+ public class Vehicle{
+ public string color {get;set;}
+ public int numWheels {get;set;}
+ public int numPassengers {get;set;}
+ public bool gasPowered {get;set;}
+ public int engineSize {get;set;}
+ public virtual String honk(){
+ return "honk honk";
+ }
+
+
+ public Vehicle(string color, int numWheels, int numPassengers, bool gasPowered, int engineSize){
+ this.color = color;
+ this.numWheels = numWheels;
+ this.numPassengers = numPassengers;
+ this.gasPowered = gasPowered;
+ this.engineSize = engineSize;
+ }
+ }
+
+ public class Truck : Vehicle {
+ public int cabSize {get;set;}
+ public int towingCapacity {get;set;}
+
+ public override String honk(){
+ return "B I G G H O N C C";
+ }
+
+ public Truck(int cabSize, int towingCapacity, string color, int numWheels, int numPassengers, bool gasPowered, int engineSize) : base(color, numWheels, numPassengers, gasPowered, engineSize){
+ this.numWheels = numWheels;
+ this.cabSize = cabSize;
+ this.towingCapacity = towingCapacity;
+
+ }
+ }
+
+ public class Motorcycle : Vehicle {
+ public bool isCruiser {get;set;}
+ public bool hasSidecar {get;set;}
+ public override String honk(){
+ return "beep beep";
+ }
+ public Motorcycle(bool isCruiser, bool hasSidecar, string color, int numWheels, int numPassengers, bool gasPowered, int engineSize) : base(color, numWheels, numPassengers, gasPowered, engineSize){
+ this.isCruiser = isCruiser;
+ this.hasSidecar = hasSidecar;
+ }
+ }
+
+ public class Van : Vehicle {
+ public bool hasSlidingDoor {get;set;}
+ public bool isCargoVan {get;set;}
+
+ public Van(bool hasSlidingDoor, bool isCargoVan, string color, int numWheels, int numPassengers, bool gasPowered, int engineSize) : base(color, numWheels, numPassengers, gasPowered, engineSize){
+ this.hasSlidingDoor = hasSlidingDoor;
+ this.isCargoVan = isCargoVan;
+ }
+ }
+
+
+}
diff --git a/Mastermind/.vscode/launch.json b/Mastermind/.vscode/launch.json
new file mode 100644
index 00000000..60c9449e
--- /dev/null
+++ b/Mastermind/.vscode/launch.json
@@ -0,0 +1,28 @@
+{
+ // Use IntelliSense to find out which attributes exist for C# debugging
+ // Use hover for the description of the existing attributes
+ // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": ".NET Core Launch (console)",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ // If you have changed target frameworks, make sure to update the program path.
+ "program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/Mastermind.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}",
+ // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
+ "console": "internalConsole",
+ "stopAtEntry": false,
+ "internalConsoleOptions": "openOnSessionStart"
+ },
+ {
+ "name": ".NET Core Attach",
+ "type": "coreclr",
+ "request": "attach",
+ "processId": "${command:pickProcess}"
+ }
+ ,]
+}
\ No newline at end of file
diff --git a/Mastermind/.vscode/tasks.json b/Mastermind/.vscode/tasks.json
new file mode 100644
index 00000000..ccfc68f7
--- /dev/null
+++ b/Mastermind/.vscode/tasks.json
@@ -0,0 +1,15 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build",
+ "${workspaceFolder}/Mastermind.csproj"
+ ],
+ "problemMatcher": "$msCompile"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/Mastermind/Mastermind.cs b/Mastermind/Mastermind.cs
index 365fb84c..2654112b 100644
--- a/Mastermind/Mastermind.cs
+++ b/Mastermind/Mastermind.cs
@@ -1,86 +1,132 @@
using System;
+using System.Collections.Generic;
+using System.Threading;
-namespace Mastermind
+
+namespace Mastermind
{
- class Program
+ class Program
{
- // possible letters in code
- public static char[] letters = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' };
-
- // size of code
- public static int codeSize = 4;
-
- // number of allowed attempts to crack the code
- public static int allowedAttempts = 10;
-
- // number of tried guesses
- public static int numTry = 0;
-
- // test solution
- public static char[] solution = new char[] {'a', 'b', 'c', 'd'};
-
- // game board
- public static string[][] board = new string[allowedAttempts][];
-
-
- public static void Main()
- {
- char[] guess = new char[4];
+ static void Main (string[] args) {
+
+ string[] randomLetters = new string[] {"a", "b", "c", "d", "e", "f"};
+ Random rando = new Random();
+ Game game = new Game (new string[] { randomLetters[rando.Next(0,6)], randomLetters[rando.Next(0,6)], randomLetters[rando.Next(0,6)], randomLetters[rando.Next(0,6)] }, 10);
+ // Game game = new Game (new string[] { "a", "a", "a", "a" });
+ for (int turns = game.numTries; turns > 0; turns--) {
+ Console.WriteLine($"You have {turns} tries left");
+ Console.WriteLine ("Choose four letters: ");
+ string letters = Console.ReadLine ();
+ string[] lettersArray = letters.Split("");
+ Ball[] balls = new Ball[4];
+ for (int i = 0; i < 4; i++) {
+ balls[i] = new Ball (letters[i].ToString());
+ }
+ Row row = new Row (balls);
+ game.AddRow (row);
+ Console.WriteLine (game.Rows);
+
+
+ }
+ Console.WriteLine ("Out Of Turns");
+ }
+ }
- CreateBoard();
- DrawBoard();
- Console.WriteLine("Enter Guess:");
- guess = Console.ReadLine().ToCharArray();
+ class Game {
+ private List rows = new List ();
+ private string[] answer = new string[4];
- // leave this command at the end so your program does not close automatically
- Console.ReadLine();
- }
-
- public static bool CheckSolution(char[] guess)
- {
- // Your code here
+ public int numTries {get;set;}
- return false;
- }
-
- public static string GenerateHint(char[] guess)
+ public Game (string[] answer, int numTries)
{
- // Your code here
- return " ";
+ this.answer = answer;
}
-
- public static void InsertCode(char[] guess)
+
+ public string Score (Row row) {
+ string[] answerClone = (string[]) this.answer.Clone ();
+ // red is correct letter and correct position
+ // white is correct letters minus red
+ // this.answer => ["a", "b", "c", "d"]
+ // row.balls => [{ Letter: "c" }, { Letter: "b" }, { Letter: "d" }, { Letter: "a" }]
+ int red = 0;
+ for (int i = 0; i < 4; i++)
+ {
+ if (answerClone[i] == row.balls[i].Letter)
+ {
+ red++;
+ }
+ }
+
+ int white = 0;
+ for (int i = 0; i < 4; i++)
+ {
+ int foundIndex = Array.IndexOf (answerClone, row.balls[i].Letter);
+ if (foundIndex > -1) {
+ white++;
+ answerClone[foundIndex] = null;
+ }
+ }
+ //win conditions
+ if ((white - red == 0) && (red == 4))
+ {
+ Console.WriteLine("You've won!");
+ System.Environment.Exit(1);
+ }
+
+
+ return $" {red} - {white - red}";
+
+ }
+
+ public void AddRow (Row row)
{
- // Your code here
+ this.rows.Add (row);
}
-
- public static void CreateBoard()
+
+ public string Rows
{
- for (var i = 0; i < allowedAttempts; i++)
+ get
{
- board[i] = new string[codeSize + 1];
- for (var j = 0; j < codeSize + 1; j++)
+ foreach (var row in this.rows)
{
- board[i][j] = " ";
+ Console.WriteLine (row.Balls);
+ Console.WriteLine (Score (row));
}
+ return null;
}
}
-
- public static void DrawBoard()
+ }
+
+ class Ball
+ {
+ public string Letter { get; private set; }
+
+ public Ball (string letter)
{
- for (var i = 0; i < board.Length; i++)
- {
- Console.WriteLine("|" + String.Join("|", board[i]));
- }
-
+ this.Letter = letter;
}
-
- public static void GenerateRandomCode() {
- Random rnd = new Random();
- for(var i = 0; i < codeSize; i++)
+ }
+
+ class Row
+ {
+ public Ball[] balls = new Ball[4];
+
+ public Row (Ball[] balls)
+ {
+ this.balls = balls;
+ }
+
+ public string Balls
+ {
+ get
{
- solution[i] = letters[rnd.Next(0, letters.Length)];
+ foreach (var ball in this.balls)
+ {
+ Console.Write (ball.Letter);
+ }
+ return "";
}
}
}
-}
+}
\ No newline at end of file
diff --git a/TowersOfHanoi/.vscode/launch.json b/TowersOfHanoi/.vscode/launch.json
new file mode 100644
index 00000000..4ceac24d
--- /dev/null
+++ b/TowersOfHanoi/.vscode/launch.json
@@ -0,0 +1,28 @@
+{
+ // Use IntelliSense to find out which attributes exist for C# debugging
+ // Use hover for the description of the existing attributes
+ // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": ".NET Core Launch (console)",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ // If you have changed target frameworks, make sure to update the program path.
+ "program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/TowersOfHanoi.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}",
+ // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
+ "console": "internalConsole",
+ "stopAtEntry": false,
+ "internalConsoleOptions": "openOnSessionStart"
+ },
+ {
+ "name": ".NET Core Attach",
+ "type": "coreclr",
+ "request": "attach",
+ "processId": "${command:pickProcess}"
+ }
+ ,]
+}
\ No newline at end of file
diff --git a/TowersOfHanoi/.vscode/tasks.json b/TowersOfHanoi/.vscode/tasks.json
new file mode 100644
index 00000000..bca810e7
--- /dev/null
+++ b/TowersOfHanoi/.vscode/tasks.json
@@ -0,0 +1,15 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build",
+ "${workspaceFolder}/TowersOfHanoi.csproj"
+ ],
+ "problemMatcher": "$msCompile"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/TowersOfHanoi/TowersOfHanoi.cs b/TowersOfHanoi/TowersOfHanoi.cs
index 10475b4a..5e6a60fd 100644
--- a/TowersOfHanoi/TowersOfHanoi.cs
+++ b/TowersOfHanoi/TowersOfHanoi.cs
@@ -1,12 +1,149 @@
using System;
+using System.Collections;
+using System.Collections.Generic;
namespace TowersOfHanoi
{
class Program
{
+
static void Main(string[] args)
{
- Console.WriteLine("Hello World!");
+ Console.WriteLine("Towers of Hanoi");
+ Game myGame = new Game();
+ myGame.Run();
+ }
+ }
+
+
+ public class Game{
+ Dictionary towers = new Dictionary();
+ bool hasWon = false;
+ string location = "";
+ string destination = "";
+
+ void GetPlayerInput()
+ {
+ Console.WriteLine("What stack would you like to move the block from?");
+ string userInput = Console.ReadLine();
+
+ if ((userInput == "a") ||(userInput == "A") || (userInput == "b") ||(userInput == "B") || (userInput == "c") ||(userInput == "C"))
+ {
+ location = userInput.ToUpper();
+ }
+ else
+ {
+ Console.WriteLine("Sorry, your input is invalid.");
+ userInput = null;
+ location = null;
+ destination = null;
+ GetPlayerInput();
+ }
+ Console.WriteLine("What stack would you like to move the block to?");
+ userInput = Console.ReadLine();
+ if ((userInput == "a") ||(userInput == "A") || (userInput == "b") ||(userInput == "B") || (userInput == "c") ||(userInput == "C"))
+ {
+ destination = userInput.ToUpper();
+ }
+ else
+ {
+ Console.WriteLine("Sorry, your input is invalid.");
+ userInput = null;
+ location = null;
+ destination = null;
+ GetPlayerInput();
+ }
+ }
+ void MovePiece(){
+
+ if (towers[location].blockStack.Count == 0) //checks if "from" input is empty
+ {
+ Console.WriteLine("Sorry, that move is invalid");
+ return;
+ }
+ var pieceToMove = towers[location].blockStack.Peek();
+ if (towers[destination].blockStack.Count == 0) //checks if destination is empty
+ {
+ towers[location].blockStack.Pop();
+ towers[destination].blockStack.Push(pieceToMove);
+ }
+ else if (towers[destination].blockStack.Peek().weight > pieceToMove.weight) //checks to see if block in destination is bigger
+ {
+ towers[location].blockStack.Pop();
+ towers[destination].blockStack.Push(pieceToMove);
+ }
+ else
+ {
+ Console.WriteLine("Sorry, that move is invalid"); //if user tries to put a bigger block on a smaller one
+ }
+ }
+
+ void PrintBoard(){
+ foreach (string name in towers.Keys)
+ {
+ Console.Write(name + ": ");
+ Tower tower = towers[name];
+ Stack stackOfBlocks = tower.blockStack;
+ Stack stackToPrint = new Stack();
+
+ foreach(Block b in stackOfBlocks) // this loop dumps the stack into a new stack, so it's printed out the proper way
+ {
+ stackToPrint.Push(b);
+ }
+ foreach (Block z in stackToPrint) // this loop prints out the stack in the proper order
+ {
+ Console.Write(z.weight);
+ }
+ Console.WriteLine();
+ }
+ }
+
+ void CheckForWin()
+ {
+ if (towers["C"].blockStack.Count >= 4){
+ Console.WriteLine("You Win!");
+ hasWon = true;
+ }
+ }
+ public void Run() // this is the game logic
+ {
+ while (!hasWon)
+ {
+ PrintBoard();
+ GetPlayerInput();
+ MovePiece();
+ CheckForWin();
+ }
+ }
+
+ public Game(){ //constructor for Game
+ towers["A"] = new Tower();
+ towers["B"] = new Tower();
+ towers["C"] = new Tower();
+
+ Block block1 = new Block(1);
+ Block block2 = new Block(2);
+ Block block3 = new Block(3);
+ Block block4 = new Block(4);
+
+ towers["A"].blockStack.Push(block4);
+ towers["A"].blockStack.Push(block3);
+ towers["A"].blockStack.Push(block2);
+ towers["A"].blockStack.Push(block1);
}
}
+ public class Tower{
+ public Stack blockStack {get;set;}
+ public Tower()
+ {
+ this.blockStack = new Stack();
+ }
+ }
+ public class Block{
+ public int weight {get; set;}
+ public Block(int weight) {
+ this.weight = weight;
+ }
+ }
+
}