From 776efa1e79d50a6a0dc85535e667f5cdef12e433 Mon Sep 17 00:00:00 2001 From: "James.Woodard" Date: Mon, 30 Jul 2018 09:22:04 -0500 Subject: [PATCH 1/9] started over on the FUCKING CHECKPOINT BECAUSE IM AN IDIOT AND OVERWROTE IT --- Checkpoint1/.vscode/launch.json | 28 ++++++++++++++++++++++ Checkpoint1/.vscode/tasks.json | 15 ++++++++++++ Checkpoint1/Checkpoint1.cs | 41 ++++++++++++++++++++++++++++++++- 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 Checkpoint1/.vscode/launch.json create mode 100644 Checkpoint1/.vscode/tasks.json diff --git a/Checkpoint1/.vscode/launch.json b/Checkpoint1/.vscode/launch.json new file mode 100644 index 00000000..bb71d335 --- /dev/null +++ b/Checkpoint1/.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/Checkpoint1.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/Checkpoint1/.vscode/tasks.json b/Checkpoint1/.vscode/tasks.json new file mode 100644 index 00000000..65947bdb --- /dev/null +++ b/Checkpoint1/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/Checkpoint1.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Checkpoint1/Checkpoint1.cs b/Checkpoint1/Checkpoint1.cs index b7ed8611..89aeaebb 100644 --- a/Checkpoint1/Checkpoint1.cs +++ b/Checkpoint1/Checkpoint1.cs @@ -1,4 +1,7 @@ using System; +using System.Linq; +using System.Collections; +using System.Collections.Generic; namespace Checkpoint1 { @@ -6,7 +9,43 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Hello World!"); + void MainMenu(){ + + + } + + + // 1- Write a program to count how many numbers between 1 and 100 are divisible by 3 with no remainder. Display the count on the console. + void Problem1(){ + + + } + + + // 2- Write a program and continuously ask the user to enter a number or "ok" to exit. Calculate the sum of all the previously entered numbers and display it on the console. + void Problem2(){ + int playerChoice = 0; + Console.WriteLine("Please enter a number, or hit OK if you are done entering numbers"); + } + + + // 3- Write a program and ask the user to enter a number. Compute the factorial of the number and print it on the console. For example, if the user enters 5, the program should calculate 5 x 4 x 3 x 2 x 1 and display it as 5! = 120. + void problem3(){ + + + } + + // 4- Write a program that picks a random number between 1 and 10. Give the user 4 chances to guess the number. If the user guesses the number, display “You won"; otherwise, display “You lost". (To make sure the program is behaving correctly, you can display the secret number on the console first.) + void problem4(){ + + + } + + // 5- Write a program and ask the user to enter a series of numbers separated by comma. Find the maximum of the numbers and display it on the console. For example, if the user enters “5, 3, 8, 1, 4", the program should display 8. + void problem5(){ + + + } } } } From 8344087f3e86c8ce75eef76665f0627373e1a3ca Mon Sep 17 00:00:00 2001 From: "James.Woodard" Date: Mon, 30 Jul 2018 11:40:32 -0500 Subject: [PATCH 2/9] completely redid checkpoint 1 cuz im a fuckin retard --- Checkpoint1/Checkpoint1.cs | 169 +++++++++++++++++++++++++++++++++++-- 1 file changed, 163 insertions(+), 6 deletions(-) diff --git a/Checkpoint1/Checkpoint1.cs b/Checkpoint1/Checkpoint1.cs index 89aeaebb..c8a7d0dd 100644 --- a/Checkpoint1/Checkpoint1.cs +++ b/Checkpoint1/Checkpoint1.cs @@ -9,14 +9,67 @@ class Program { static void Main(string[] args) { + + MainMenu(); + + int userChoice = 0; void MainMenu(){ + Console.WriteLine("Welcome to Checkpoint 1. Please select a choice:"); + Console.WriteLine("1. Divisible by 3 tool"); + Console.WriteLine("2. Addition tool"); + Console.WriteLine("3. Factorial tool"); + Console.WriteLine("4. Guess a number"); + Console.WriteLine("5. Find largest number"); + if (Int32.TryParse(Console.ReadLine(), out userChoice)) + { + if (userChoice == 1) + { + Problem1(); + } + else if (userChoice == 2) + { + Problem2(); + } + else if (userChoice == 3) + { + Problem3(); + } + else if (userChoice == 4) + { + Problem4(); + } + else if (userChoice == 5) + { + Problem5(); + } + else + { + Console.WriteLine("That was an invalid choice"); + MainMenu(); + } + } + else + { + Console.WriteLine("That was an invalid choice"); + MainMenu(); + } } // 1- Write a program to count how many numbers between 1 and 100 are divisible by 3 with no remainder. Display the count on the console. void Problem1(){ + int divisibleCount = 0; + for (int i = 1; i <= 100; i++) + { + if (i % 3 == 0) + { + divisibleCount++; + Console.WriteLine(i + " is divisible by 3. That makes " + divisibleCount + " numbers so far that are divisible by 3."); + } + } + Console.WriteLine("Counting done. There are " + divisibleCount + "numbers between 1 and 100 that are divisble by 3."); } @@ -25,24 +78,128 @@ void Problem1(){ // 2- Write a program and continuously ask the user to enter a number or "ok" to exit. Calculate the sum of all the previously entered numbers and display it on the console. void Problem2(){ int playerChoice = 0; - Console.WriteLine("Please enter a number, or hit OK if you are done entering numbers"); + List numbers = new List(); + GetNumber(); + + void GetNumber(){ + Console.WriteLine("Please enter a number, or type ok if you are done entering numbers"); + string input = Console.ReadLine(); + if (Int32.TryParse(input, out playerChoice)) + { + numbers.Add(playerChoice); + GetNumber(); + } + else if (input == "ok") + { + int sum = numbers.Sum(); + Console.WriteLine("The sum of the numbers you entered is " + sum); + MainMenu(); + } + else + { + Console.WriteLine("Your choice was invalid." ); + GetNumber(); + } + } } // 3- Write a program and ask the user to enter a number. Compute the factorial of the number and print it on the console. For example, if the user enters 5, the program should calculate 5 x 4 x 3 x 2 x 1 and display it as 5! = 120. - void problem3(){ + void Problem3(){ + int userNumber = 0; + int i = 0; + + Console.WriteLine("Enter a number: "); + // userNumber = int.Parse(Console.ReadLine()); + if (Int32.TryParse((Console.ReadLine()), out userNumber)) + { + int factorial = userNumber; + for (i = userNumber - 1; i >= 1; i--) + { + factorial = factorial * i; + } + Console.WriteLine("The factorial of " + userNumber + " is " + factorial); + Console.ReadLine(); + MainMenu(); + } + else + { + Console.WriteLine("Your choice was invalid." ); + Problem3(); + } } // 4- Write a program that picks a random number between 1 and 10. Give the user 4 chances to guess the number. If the user guesses the number, display “You won"; otherwise, display “You lost". (To make sure the program is behaving correctly, you can display the secret number on the console first.) - void problem4(){ + void Problem4(){ + int chances = 4; + int guess = 0; + Random rnd = new Random(); + int compChoice = rnd.Next(1, 10); - - } + GuessingTime(); + void GuessingTime(){ + Console.WriteLine("The computer mastermind has chosen a number between 1 and 10. Can you guess it correctly?"); + while (chances > 0) + { + Console.WriteLine("Type a number between 1 and 10 and press Enter"); + if (Int32.TryParse((Console.ReadLine()), out guess)) + { + if ((guess > 10) || (guess < 1 )) + { + Console.WriteLine("Your selection is invalid."); + Problem4(); + } + else if (guess == compChoice) + { + Console.WriteLine("You guessed right with " + chances + " chances left! You win!"); + MainMenu(); + } + else + { + chances--; + Console.WriteLine("You guessed wrong! You have " + chances + " chances left!"); + + } + + } + else + { + Console.WriteLine("Your choice was invalid." ); + Problem4(); + } + } + Console.WriteLine("You ran out of guesses! You lose! The computer mastermind's number was " + compChoice); + MainMenu(); + } + + } // 5- Write a program and ask the user to enter a series of numbers separated by comma. Find the maximum of the numbers and display it on the console. For example, if the user enters “5, 3, 8, 1, 4", the program should display 8. - void problem5(){ + void Problem5(){ + Console.WriteLine("Input a bunch of numbers separated by commas, then press enter"); + string input = Console.ReadLine(); + + string[] numbers = (input).Split(","); + int[] numbersInt = new int[numbers.Length]; + + for (int i = 0; i < numbers.Length; i++) + { + if (Int32.TryParse(numbers[i], out numbersInt[i])) + { + + } + else + { + Console.WriteLine("One of your inputs was invalid, please try again"); + Problem5(); + } + + } + Console.WriteLine("The largest number you entered is " + numbersInt.Max()); + MainMenu(); + } From ce05ec110619c49094669188517ec2dee92560c4 Mon Sep 17 00:00:00 2001 From: "James.Woodard" Date: Mon, 30 Jul 2018 21:13:53 -0500 Subject: [PATCH 3/9] working on dictionaries project --- Checkpoint1/Checkpoint1.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Checkpoint1/Checkpoint1.cs b/Checkpoint1/Checkpoint1.cs index c8a7d0dd..97abf6b7 100644 --- a/Checkpoint1/Checkpoint1.cs +++ b/Checkpoint1/Checkpoint1.cs @@ -106,20 +106,19 @@ void GetNumber(){ // 3- Write a program and ask the user to enter a number. Compute the factorial of the number and print it on the console. For example, if the user enters 5, the program should calculate 5 x 4 x 3 x 2 x 1 and display it as 5! = 120. void Problem3(){ - int userNumber = 0; - int i = 0; + long userNumber = 0; + long i = 0; Console.WriteLine("Enter a number: "); // userNumber = int.Parse(Console.ReadLine()); - if (Int32.TryParse((Console.ReadLine()), out userNumber)) + if (long.TryParse((Console.ReadLine()), out userNumber)) { - int factorial = userNumber; + long factorial = userNumber; for (i = userNumber - 1; i >= 1; i--) { factorial = factorial * i; } Console.WriteLine("The factorial of " + userNumber + " is " + factorial); - Console.ReadLine(); MainMenu(); } else From 3823dea71f2164838b5bb1413cf31b77a1ade9fb Mon Sep 17 00:00:00 2001 From: "James.Woodard" Date: Mon, 6 Aug 2018 18:21:51 -0500 Subject: [PATCH 4/9] uploading rockpaperscissors2 --- RockPaperScissors2/.vscode/launch.json | 28 ++++ RockPaperScissors2/.vscode/tasks.json | 15 ++ RockPaperScissors2/Program.cs | 161 +++++++++++++++++++ RockPaperScissors2/RockPaperScissors2.csproj | 8 + 4 files changed, 212 insertions(+) create mode 100644 RockPaperScissors2/.vscode/launch.json create mode 100644 RockPaperScissors2/.vscode/tasks.json create mode 100644 RockPaperScissors2/Program.cs create mode 100644 RockPaperScissors2/RockPaperScissors2.csproj diff --git a/RockPaperScissors2/.vscode/launch.json b/RockPaperScissors2/.vscode/launch.json new file mode 100644 index 00000000..0cea9c31 --- /dev/null +++ b/RockPaperScissors2/.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/RockPaperScissors2.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/RockPaperScissors2/.vscode/tasks.json b/RockPaperScissors2/.vscode/tasks.json new file mode 100644 index 00000000..9b868cd2 --- /dev/null +++ b/RockPaperScissors2/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/RockPaperScissors2.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/RockPaperScissors2/Program.cs b/RockPaperScissors2/Program.cs new file mode 100644 index 00000000..fbeec07b --- /dev/null +++ b/RockPaperScissors2/Program.cs @@ -0,0 +1,161 @@ +using System; + +namespace RockPaperScissors +{ + class Program + { + public static void Main() + { + string player1Hand = null; + int player1Score = 0; + string comHand = ""; + int comScore = 0; + int ties = 0; + string[] rps = new string[] {"rock", "paper", "scissors"}; + + while(player1Hand == null) + { + try + { + player1Hand = PlayerTurn(); + break; + } + catch(Exception) + { + Console.WriteLine("Your choice is invalid. Choose again."); + } + finally + { + Console.WriteLine("Returning. Have a wonderful day."); + } + + } + + ComTurn(); + WinCheck(); + Scoreboard(); + PlayAgain(); + + String PlayerTurn(){ + Console.WriteLine("Please type 1 for Rock, 2 for Paper, or 3 for Scissors and press the Enter key: "); + String player1Choice = Console.ReadLine().Trim(); + System.Threading.Thread.Sleep(500); + + if (player1Choice == "alakazam") + { + player1Score++; + Console.WriteLine("You automatically won with the secret code mofo. Good job cheater."); + Scoreboard(); + PlayAgain(); + + } + else if ((player1Choice != "1") && (player1Choice != "2") && (player1Choice != "3")) + { + throw new Exception(); + } + else + { + player1Hand = rps[Convert.ToInt32(player1Choice) - 1]; + Console.WriteLine("You chose " + player1Hand +"."); + System.Threading.Thread.Sleep(500); + } + return player1Hand; + } + + void ComTurn(){ + Random rnd = new Random(); + int roll = rnd.Next(0, 3); + comHand = rps[roll]; + Console.WriteLine("The Computer Mastermind chose " + comHand + "."); + System.Threading.Thread.Sleep(500); + } + + void WinCheck(){ + + if (player1Hand == comHand){ + Console.WriteLine("That's a tie!"); + ties ++; + System.Threading.Thread.Sleep(500); + } + else if (player1Hand == "rock" && comHand == "paper"){ + Console.WriteLine("Paper beats rock! You lose!"); + comScore ++; + System.Threading.Thread.Sleep(500); + } + else if (player1Hand == "rock" && comHand == "scissors"){ + Console.WriteLine("Rock beats scissors! You win!"); + player1Score ++; + System.Threading.Thread.Sleep(500); + } + else if (player1Hand == "scissors" && comHand == "paper"){ + Console.WriteLine("Scissors beats paper! You win!"); + player1Score ++; + System.Threading.Thread.Sleep(500); + } + else if (player1Hand == "scissors" && comHand == "rock"){ + Console.WriteLine("Rock beats scissors! You lose!"); + comScore ++; + System.Threading.Thread.Sleep(500); + } + else if (player1Hand == "paper" && comHand == "rock"){ + Console.WriteLine("Paper beats rock! You win!"); + player1Score ++; + System.Threading.Thread.Sleep(500); + } + else if (player1Hand == "paper" && comHand == "scissors"){ + Console.WriteLine("Scissors beats paper! You lose!"); + comScore ++; + System.Threading.Thread.Sleep(500); + } + } + void Scoreboard(){ + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + Console.WriteLine(" CURRENT SCORE: "); + Console.WriteLine(" PLAYER 1: " + player1Score); + Console.WriteLine(" COMPUTER MASTERMIND: " + comScore); + Console.WriteLine(" TIES: " + ties); + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + System.Threading.Thread.Sleep(500); + } + + void PlayAgain() { + string[] yes = { Convert.ToString('y'), Convert.ToString('Y'), "yes", "Yes", "YES"}; + Console.WriteLine("Do you want to try again? [y/n]"); + for (int i = 0; i < yes.Length; i++) + { + string choice = Console.ReadLine(); + if (choice == yes[i]) + { + Console.Clear(); + player1Hand = null; + while(player1Hand == null) + { + try + { + player1Hand = PlayerTurn(); + } + catch(Exception) + { + Console.WriteLine("Your choice is invalid. Choose again."); + } + finally + { + Console.WriteLine("Returning. Have a wonderful day."); + } + + } + ComTurn(); + WinCheck(); + Scoreboard(); + PlayAgain(); + } + else + { + Console.WriteLine("Bye! Thanks for playing!"); + Environment.Exit(0); + } + } + } + } + } +} diff --git a/RockPaperScissors2/RockPaperScissors2.csproj b/RockPaperScissors2/RockPaperScissors2.csproj new file mode 100644 index 00000000..23df6047 --- /dev/null +++ b/RockPaperScissors2/RockPaperScissors2.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + From a10b5c5b614822b97a8bd22e1efd6bfe56814a91 Mon Sep 17 00:00:00 2001 From: "James.Woodard" Date: Wed, 8 Aug 2018 18:50:03 -0500 Subject: [PATCH 5/9] uploading a partly-finished star wars --- garage/.vscode/launch.json | 28 ++++++ garage/.vscode/tasks.json | 15 +++ garage/Program.cs | 12 +++ garage/garage.csproj | 8 ++ starwars/.vscode/launch.json | 28 ++++++ starwars/.vscode/tasks.json | 15 +++ starwars/Program.cs | 182 +++++++++++++++++++++++++++++++++++ starwars/starwars.csproj | 8 ++ 8 files changed, 296 insertions(+) create mode 100644 garage/.vscode/launch.json create mode 100644 garage/.vscode/tasks.json create mode 100644 garage/Program.cs create mode 100644 garage/garage.csproj create mode 100644 starwars/.vscode/launch.json create mode 100644 starwars/.vscode/tasks.json create mode 100644 starwars/Program.cs create mode 100644 starwars/starwars.csproj diff --git a/garage/.vscode/launch.json b/garage/.vscode/launch.json new file mode 100644 index 00000000..46abeaf3 --- /dev/null +++ b/garage/.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/garage.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/garage/.vscode/tasks.json b/garage/.vscode/tasks.json new file mode 100644 index 00000000..f9ade612 --- /dev/null +++ b/garage/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/garage.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/garage/Program.cs b/garage/Program.cs new file mode 100644 index 00000000..8e584861 --- /dev/null +++ b/garage/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace garage +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/garage/garage.csproj b/garage/garage.csproj new file mode 100644 index 00000000..23df6047 --- /dev/null +++ b/garage/garage.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + diff --git a/starwars/.vscode/launch.json b/starwars/.vscode/launch.json new file mode 100644 index 00000000..4e63eca1 --- /dev/null +++ b/starwars/.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/starwars.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/starwars/.vscode/tasks.json b/starwars/.vscode/tasks.json new file mode 100644 index 00000000..31f0cc94 --- /dev/null +++ b/starwars/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/starwars.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/starwars/Program.cs b/starwars/Program.cs new file mode 100644 index 00000000..f63eba03 --- /dev/null +++ b/starwars/Program.cs @@ -0,0 +1,182 @@ +using System; +using System.Collections.Generic; + +namespace starwars +{ + class Program + { + + static void Main(string[] args) + { + Person luke = new Person("Luke", "Skywalker", "Rebel"); + Person leia = new Person("Leia", "Organa", "Rebel"); + Person han = new Person("Han", "Solo", "Rebel"); + Person chewie = new Person("Chew", "Bacca", "Rebel"); + Person darth = new Person("Darth", "Vader", "Imperial"); + Person palpatine = new Person("Emperor", "Palpatine", "Imperial"); + Ship milleniumFalcon = new Ship("Millenium Falcon", "Rebel", 3); + Ship starDestroyer = new Ship("Star Destroyer", "Imperial", 10); + Station rebelBase = new Station("Rebel Base", "Rebel"); + Station deathStar = new Station("Death Star", "Imperial"); + + //putting haters in ships + try + { + milleniumFalcon.EnterShip(luke); + Console.WriteLine("Luke has entered the ship"); + } + catch(Exception) + { + Console.WriteLine("Luke couldn't enter the ship"); + } + try + { + milleniumFalcon.EnterShip(leia); + Console.WriteLine("Leia has entered the ship"); + } + catch(Exception) + { + Console.WriteLine("Leia couldn't enter the ship"); + } + try + { + milleniumFalcon.EnterShip(han); + Console.WriteLine("Han has entered the ship"); + } + catch(Exception) + { + Console.WriteLine("Han couldn't enter the ship"); + } + try + { + milleniumFalcon.EnterShip(chewie); + Console.WriteLine("Chewie has entered the ship"); + // milleniumFalcon.passengers.firstName.ForEach(Console.WriteLine); + } + catch(Exception) + { + Console.WriteLine("Chewie couldn't fit. You racist against Wookiees or something?"); + + } + + //docking a ship at a station + try + { + rebelBase.DockAtStation(milleniumFalcon); + Console.WriteLine("Ship docking at Rebel Station"); + } + catch(Exception) + { + Console.WriteLine("The ship couldn't dock."); + } + + try + { + deathStar.DockAtStation(starDestroyer); + Console.WriteLine("Ship docking at the Death Star"); + } + catch(Exception) + { + Console.WriteLine("The ship couldn't dock."); + } + try + { + rebelBase.EmbarkOnVoyage(milleniumFalcon); + Console.WriteLine("The Millenium Falcon has embarked on its voyage"); + } + catch(Exception) + { + Console.WriteLine("The ship couldn't embark."); + } + + + } + + public class Ship + { + //attributes of the ship class + public List passengers; + public string type {get;set;} + public string alliance {get;set;} + public int capacity {get;set;} + + //constructor for Ship + public Ship(string type, string alliance, int capacity){ + passengers = new List(); + this.capacity = capacity; + } + public bool hasFreeSeats() + { + if(this.capacity > passengers.Count){ + return true; + } else { + return false; + } + } + public void EnterShip(Person personToEnter) + { + if (this.hasFreeSeats()) + { + this.passengers.Add(personToEnter); + } + else + { + throw new Exception("Sorry pal, all full."); + } + } + + public void ExitShip(Person personToExit) + { + bool reallyExited = this.passengers.Remove(personToExit); + if(!reallyExited) + { + throw new Exception("This person was not on the ship"); + } + } + } + + public class Person + { + public String firstName {get;set;} + public String lastName {get;set;} + public String alliance {get;set;} + + //this is the constructor + public Person(String firstName, String lastName, String alliance) + { + this.firstName = firstName; + this.lastName = lastName; + this.alliance = alliance; + } + } + + + public class Station + { + public string stationName {get;set;} + public string stationAlliance {get;set;} + public List dockedShips; + + //constructor for Station + public Station(string stationName, string stationAlliance) + { + this.stationName = stationName; + this.stationAlliance = stationAlliance; + dockedShips = new List(); + + } + + public void DockAtStation(Ship shipToDock) + { + this.dockedShips.Add(shipToDock); + } + public void EmbarkOnVoyage(Ship shipToEmbark){ + bool reallyRemoved = this.dockedShips.Remove(shipToEmbark); + if(!reallyRemoved) + { + throw new Exception("The ship could not be found at the station"); + } + } + } + } +} diff --git a/starwars/starwars.csproj b/starwars/starwars.csproj new file mode 100644 index 00000000..23df6047 --- /dev/null +++ b/starwars/starwars.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + From fbd984727af07e14e84dd5e0df8184bb1093ebfd Mon Sep 17 00:00:00 2001 From: "James.Woodard" Date: Sun, 12 Aug 2018 08:53:44 -0500 Subject: [PATCH 6/9] added more to starwars --- garage/Program.cs | 113 +++++++++++++++++++++++++-- idcardpractice/.vscode/launch.json | 28 +++++++ idcardpractice/.vscode/tasks.json | 15 ++++ idcardpractice/Program.cs | 57 ++++++++++++++ idcardpractice/idcardpractice.csproj | 8 ++ starwars/Program.cs | 9 ++- 6 files changed, 222 insertions(+), 8 deletions(-) create mode 100644 idcardpractice/.vscode/launch.json create mode 100644 idcardpractice/.vscode/tasks.json create mode 100644 idcardpractice/Program.cs create mode 100644 idcardpractice/idcardpractice.csproj diff --git a/garage/Program.cs b/garage/Program.cs index 8e584861..c33a0699 100644 --- a/garage/Program.cs +++ b/garage/Program.cs @@ -1,12 +1,111 @@ using System; +using System.Collections.Generic; -namespace garage -{ - class Program - { - static void Main(string[] args) - { - Console.WriteLine("Hello World!"); +namespace Practice { + class Program { + + // ignore this not part of the car "class" + static void Main(string[] args) { + Car myCar = new Car("blue", "mazda", "3s"); + myCar.passengerCapacity = 5; + myCar.engineSize = 2.3; + + Car jasonsCar = new Car("white", "volvo", "xc90"); + jasonsCar.passengerCapacity = 5; + jasonsCar.engineSize = 3.2; + + Car robertsCar = new Car("white", "ford", "fiesta"); + + ParkingGarage p1 = new ParkingGarage(2); + p1.name = "Yellow Submarine"; + + try{ + p1.parkCar(myCar); + Console.WriteLine("Car parked"); + } catch(Exception){ + Console.WriteLine("Could not park the car"); + } + try{ + p1.parkCar(jasonsCar); + Console.WriteLine("Car parked"); + } catch(Exception){ + Console.WriteLine("Could not park the car"); + } + try{ + p1.parkCar(robertsCar); + Console.WriteLine("Car parked"); + } catch(Exception){ + Console.WriteLine("Could not park the car"); + } } } + + class ParkingGarage { + public String name {get; set;} + public int capacity {get; private set;} + + // list of cars currently parked + private List currentlyParked; + + public ParkingGarage(int initialCapacity){ + currentlyParked = new List(); + this.capacity = initialCapacity; + } + + public bool hasFreeSpots(){ + if(this.capacity > currentlyParked.Count){ + return true; + } else { + return false; + } + } + + public void parkCar(Car carToPark){ + if(this.hasFreeSpots()){ + this.currentlyParked.Add(carToPark); + } else { + throw new Exception("No Capacity to park a car"); + } + } + + public void vacate(Car carToVacate){ + bool reallyRemoved = this.currentlyParked.Remove(carToVacate); + if(!reallyRemoved){ + throw new Exception("The car was not in the garage ..."); + } + } + + } + + class Car { + public String color {get; set;} + public String make {get; private set;} + public String model {get; private set;} + + // this is really the number of legally allowed passengers + // based on number of seatbelts + public int passengerCapacity {get;set;} + + public int numCylinders {get; set;} + + // enginesize is in cubic liters + public double engineSize{get;set;} + + /** + initialColor: the initial color of the car + theMake: the make of the car + theModel: the model of thecar + */ + public Car(String initialColor, String theMake, String theModel){ + this.color = initialColor; + this.make = theMake; + this.model = theModel; + } + + public double engineSizeInCubicInches(){ + double answer = this.engineSize * 61.0237; + return answer; + } + + } } diff --git a/idcardpractice/.vscode/launch.json b/idcardpractice/.vscode/launch.json new file mode 100644 index 00000000..b2c1a779 --- /dev/null +++ b/idcardpractice/.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/idcardpractice.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/idcardpractice/.vscode/tasks.json b/idcardpractice/.vscode/tasks.json new file mode 100644 index 00000000..2b87f7c7 --- /dev/null +++ b/idcardpractice/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/idcardpractice.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/idcardpractice/Program.cs b/idcardpractice/Program.cs new file mode 100644 index 00000000..1f91e682 --- /dev/null +++ b/idcardpractice/Program.cs @@ -0,0 +1,57 @@ +using System; + +namespace idcardpractice +{ + class Program + { + public static void Main(String[] args) + { + + IdCard JamesId = new IdCard("James","Woodard", 75, "green", "brown", Convert.ToChar("m"), new DateTime(1984,5,11), "tx", true, "95793947576"); + + Console.WriteLine("{0} is {1} inches tall", JamesId.firstName, JamesId.height); + Console.WriteLine("{0} is {1} feet tall", JamesId.firstName, JamesId.heightInFeet()); + } + } + + + + + + class IdCard + { + public String firstName {get;set;} + public String lastName {get;set;} + public int height {get;set;} + public string eyeColor {get; private set;} + public string hairColor {get;set;} + public char gender {get;set;} + public DateTime dob {get; private set;} + public String state {get;private set;} + public bool donor {get;set;} + public String dlNumber {get;set;} + + public IdCard(String firstName, String lastName, int height, string eyeColor, string hairColor, char gender, DateTime dob, String state, bool donor, string dlNumber) + { + this.firstName = firstName; + this.lastName = lastName; + this.height = height; + this.eyeColor = eyeColor; + this.hairColor = hairColor; + this.gender = gender; + this.dob = dob; + this.state = state; + this.donor = donor; + this.dlNumber = dlNumber; + } + public double heightInFeet() + { + double feet = this.height/12.0; + return feet; + } + } + + + + +} diff --git a/idcardpractice/idcardpractice.csproj b/idcardpractice/idcardpractice.csproj new file mode 100644 index 00000000..23df6047 --- /dev/null +++ b/idcardpractice/idcardpractice.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + diff --git a/starwars/Program.cs b/starwars/Program.cs index f63eba03..2255ab88 100644 --- a/starwars/Program.cs +++ b/starwars/Program.cs @@ -51,11 +51,16 @@ static void Main(string[] args) { milleniumFalcon.EnterShip(chewie); Console.WriteLine("Chewie has entered the ship"); - // milleniumFalcon.passengers.firstName.ForEach(Console.WriteLine); + } catch(Exception) { Console.WriteLine("Chewie couldn't fit. You racist against Wookiees or something?"); + // lists passengers of millenium falcon + foreach (Person p in milleniumFalcon.passengers) + { + Console.WriteLine(p.firstName); + } } @@ -90,6 +95,8 @@ static void Main(string[] args) } + + } public class Ship From 954d08678977696f39f63852297bc088d5b7c814 Mon Sep 17 00:00:00 2001 From: "James.Woodard" Date: Sun, 12 Aug 2018 10:50:29 -0500 Subject: [PATCH 7/9] finished rainforest project --- Rainforest/.vscode/launch.json | 28 ++++++++ Rainforest/.vscode/tasks.json | 15 ++++ Rainforest/Rainforest.cs | 128 ++++++++++++++++++++++++++++++++- 3 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 Rainforest/.vscode/launch.json create mode 100644 Rainforest/.vscode/tasks.json diff --git a/Rainforest/.vscode/launch.json b/Rainforest/.vscode/launch.json new file mode 100644 index 00000000..2406855c --- /dev/null +++ b/Rainforest/.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/Rainforest.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/Rainforest/.vscode/tasks.json b/Rainforest/.vscode/tasks.json new file mode 100644 index 00000000..4ddba36b --- /dev/null +++ b/Rainforest/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/Rainforest.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Rainforest/Rainforest.cs b/Rainforest/Rainforest.cs index cf853def..6eef513e 100644 --- a/Rainforest/Rainforest.cs +++ b/Rainforest/Rainforest.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace Rainforest { @@ -6,7 +7,132 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Hello World!"); + Console.WriteLine("Let's build a bootleg Amazon!"); + + Company rainforest = new Company("Rainforest"); + + Warehouse sanAntonio = new Warehouse("San Antonio", 10); + Warehouse austin = new Warehouse("Austin", 10); + Warehouse houston = new Warehouse("Houston", 10); + Warehouse shitCity = new Warehouse("Shit City", 10); + + Container sanAntonio_1 = new Container("SanAntonio-1", 6); + Container sanAntonio_2 = new Container("SanAntonio-2", 6); + Container austin_1 = new Container("Austin-1", 6); + Container houston_1 = new Container("Houston-1", 6); + Container shitCity_1 = new Container("ShitCity-1", 6); + + Item bananas = new Item("Bananas", 1.99m); + Item cockfightingDVDs = new Item("Cockfighting DVDs", 19.99m); + Item bootlegAdidas = new Item("Bootleg Adidas", 14.99m); + Item gallonOfChamoy = new Item("Gallon of Chamoy", 9.99m); + Item goldTeeth = new Item ("Gold Teeth", 499.99m); + Item brickOfCocaine = new Item("Brick of Cocaine", 999.99m); + Item cannibalCorpseCD = new Item ("Cannibal Corpse - Greatest Hits", 14.99m); + + //building the warehouses, spec 3 + rainforest.BuildWarehouse(sanAntonio); + rainforest.BuildWarehouse(austin); + rainforest.BuildWarehouse(houston); + rainforest.BuildWarehouse(shitCity); + //building the containers, spec 4 + sanAntonio.BuildContainer(sanAntonio_1); + sanAntonio.BuildContainer(sanAntonio_2); + austin.BuildContainer(austin_1); + houston.BuildContainer(houston_1); + shitCity.BuildContainer(shitCity_1); + //adding items, spec 5 + sanAntonio_1.AddItems(bananas); + sanAntonio_2.AddItems(cockfightingDVDs); + sanAntonio_2.AddItems(bootlegAdidas); + austin_1.AddItems(gallonOfChamoy); + houston_1.AddItems(goldTeeth); + shitCity_1.AddItems(brickOfCocaine); + shitCity_1.AddItems(cannibalCorpseCD); + //attempting to create the index + Dictionary index = new Dictionary(); + + //printing out the contents of each thing, spec 6 + foreach (Warehouse w in rainforest.warehouses) + { + Console.WriteLine(w.location); + foreach (Container c in w.containers) + { + Console.WriteLine(" " + c.id); + foreach (Item i in c.items) + { + index.Add(i.name, c.id); //this line creates the index, spec 7 + Console.WriteLine(" " + i.name + " - $" + i.price); + } + } + } + + //printing out contents of index + + foreach (var item in index) + { + Console.WriteLine(item); + } + + + + } + + public class Company { + public String name {get;set;} + public List warehouses; + + public Company(String name){ + warehouses = new List(); + } + + public void BuildWarehouse(Warehouse newWarehouse){ + this.warehouses.Add(newWarehouse); // this adds warehouse to the warehoses list + } + } + + public class Warehouse { + public String location {get;set;} + public int size {get;set;} + public List containers; + + //constructor for Warehouse + public Warehouse(string location, int size){ + this.location = location; + this.size = size; + containers = new List(); + } + + public void BuildContainer(Container newContainer){ + this.containers.Add(newContainer); // adds container to the containers list + } + + + } + + public class Container{ + public int size {get;set;} + public String id {get;set;} + public List items; + public Container(String id, int size){ + this.id = id; + this.size = size; + items = new List(); + } + + public void AddItems(Item newItem){ + this.items.Add(newItem); + } + + } + + public class Item { + public String name {get;set;} + public decimal price {get;set;} + public Item(string name, decimal price){ + this.name = name; + this.price = price; + } } } } From cbb6db3c67d470a741c15602a641c1ea22bfcbf1 Mon Sep 17 00:00:00 2001 From: "James.Woodard" Date: Sun, 12 Aug 2018 11:09:23 -0500 Subject: [PATCH 8/9] cleaned up code a bit --- Rainforest/Rainforest.cs | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/Rainforest/Rainforest.cs b/Rainforest/Rainforest.cs index 6eef513e..5c0be163 100644 --- a/Rainforest/Rainforest.cs +++ b/Rainforest/Rainforest.cs @@ -10,18 +10,15 @@ static void Main(string[] args) Console.WriteLine("Let's build a bootleg Amazon!"); Company rainforest = new Company("Rainforest"); - Warehouse sanAntonio = new Warehouse("San Antonio", 10); Warehouse austin = new Warehouse("Austin", 10); Warehouse houston = new Warehouse("Houston", 10); Warehouse shitCity = new Warehouse("Shit City", 10); - Container sanAntonio_1 = new Container("SanAntonio-1", 6); Container sanAntonio_2 = new Container("SanAntonio-2", 6); Container austin_1 = new Container("Austin-1", 6); Container houston_1 = new Container("Houston-1", 6); Container shitCity_1 = new Container("ShitCity-1", 6); - Item bananas = new Item("Bananas", 1.99m); Item cockfightingDVDs = new Item("Cockfighting DVDs", 19.99m); Item bootlegAdidas = new Item("Bootleg Adidas", 14.99m); @@ -66,48 +63,35 @@ static void Main(string[] args) } } } - //printing out contents of index - foreach (var item in index) { Console.WriteLine(item); } - - - } - public class Company { public String name {get;set;} public List warehouses; - public Company(String name){ warehouses = new List(); } - public void BuildWarehouse(Warehouse newWarehouse){ - this.warehouses.Add(newWarehouse); // this adds warehouse to the warehoses list + this.warehouses.Add(newWarehouse); // this adds warehouse to the warehouses list } } - public class Warehouse { public String location {get;set;} public int size {get;set;} public List containers; - //constructor for Warehouse public Warehouse(string location, int size){ this.location = location; this.size = size; containers = new List(); } - public void BuildContainer(Container newContainer){ this.containers.Add(newContainer); // adds container to the containers list } - - } public class Container{ @@ -119,13 +103,10 @@ public Container(String id, int size){ this.size = size; items = new List(); } - public void AddItems(Item newItem){ this.items.Add(newItem); } - } - public class Item { public String name {get;set;} public decimal price {get;set;} From c29a24d67aa54137a10811417d191f126cccd3e0 Mon Sep 17 00:00:00 2001 From: "James.Woodard" Date: Mon, 13 Aug 2018 20:57:25 -0500 Subject: [PATCH 9/9] added roster to starwars --- starwars/Program.cs | 87 ++++++++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 32 deletions(-) diff --git a/starwars/Program.cs b/starwars/Program.cs index 2255ab88..dbe89ad3 100644 --- a/starwars/Program.cs +++ b/starwars/Program.cs @@ -19,6 +19,9 @@ static void Main(string[] args) Station rebelBase = new Station("Rebel Base", "Rebel"); Station deathStar = new Station("Death Star", "Imperial"); + // Dictionary roster = new Dictionary(); + List roster = new List(); + //putting haters in ships try { @@ -57,10 +60,10 @@ static void Main(string[] args) { Console.WriteLine("Chewie couldn't fit. You racist against Wookiees or something?"); // lists passengers of millenium falcon - foreach (Person p in milleniumFalcon.passengers) - { - Console.WriteLine(p.firstName); - } + // foreach (Person p in milleniumFalcon.passengers) + // { + // Console.WriteLine(p.firstName); + // } } @@ -77,13 +80,15 @@ static void Main(string[] args) try { - deathStar.DockAtStation(starDestroyer); + rebelBase.DockAtStation(starDestroyer); Console.WriteLine("Ship docking at the Death Star"); } catch(Exception) { Console.WriteLine("The ship couldn't dock."); } + + MakeRoster(); try { rebelBase.EmbarkOnVoyage(milleniumFalcon); @@ -94,11 +99,55 @@ static void Main(string[] args) Console.WriteLine("The ship couldn't embark."); } - + void MakeRoster(){ + foreach (Ship s in rebelBase.dockedShips) + { + foreach (Person p in s.passengers) + { + roster.Add(p.firstName); //this line adds the people to the roster + } + } + //printing out contents of roster + foreach (var item in roster) + { + Console.WriteLine(item); + } + } + } + + + + public class Station + { + public string stationName {get;set;} + public string stationAlliance {get;set;} + public List dockedShips; + + //constructor for Station + public Station(string stationName, string stationAlliance) + { + this.stationName = stationName; + this.stationAlliance = stationAlliance; + dockedShips = new List(); + + } + + public void DockAtStation(Ship shipToDock) + { + this.dockedShips.Add(shipToDock); + } + public void EmbarkOnVoyage(Ship shipToEmbark){ + bool reallyRemoved = this.dockedShips.Remove(shipToEmbark); + if(!reallyRemoved) + { + throw new Exception("The ship could not be found at the station"); + } + } + } public class Ship { //attributes of the ship class @@ -158,32 +207,6 @@ public Person(String firstName, String lastName, String alliance) } - public class Station - { - public string stationName {get;set;} - public string stationAlliance {get;set;} - public List dockedShips; - //constructor for Station - public Station(string stationName, string stationAlliance) - { - this.stationName = stationName; - this.stationAlliance = stationAlliance; - dockedShips = new List(); - - } - - public void DockAtStation(Ship shipToDock) - { - this.dockedShips.Add(shipToDock); - } - public void EmbarkOnVoyage(Ship shipToEmbark){ - bool reallyRemoved = this.dockedShips.Remove(shipToEmbark); - if(!reallyRemoved) - { - throw new Exception("The ship could not be found at the station"); - } - } - } } }