From 751e7e4b7730fc1680d96064bf92fe362b5c99b2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Jan 2019 17:08:01 -0600 Subject: [PATCH 01/23] finished user number counting --- Checkpoint1/Checkpoint1.cs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Checkpoint1/Checkpoint1.cs b/Checkpoint1/Checkpoint1.cs index b7ed8611..04b6d2ab 100644 --- a/Checkpoint1/Checkpoint1.cs +++ b/Checkpoint1/Checkpoint1.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace Checkpoint1 { @@ -6,7 +7,28 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Hello World!"); + //continue to ask for numbers and add them together + bool exit = false; + List playerNumbersList = new List { }; + while (!exit) + { + Console.WriteLine("Enter number or ok to exit"); + string userResponse = Console.ReadLine(); + if (userResponse == "ok") + { + exit = true; + } + else + { + playerNumbersList.Add(Convert.ToInt32(userResponse)); + } + } + int result = 0; + for (int i = 0; i < playerNumbersList.Count; i++) + { + result = result + playerNumbersList[i]; + } + Console.WriteLine(result); } } } From 8c4548441b0b2873d6458b0fdfb7d293b209bdeb Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Jan 2019 17:09:42 -0600 Subject: [PATCH 02/23] finished --- Checkpoint1/Checkpoint1.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Checkpoint1/Checkpoint1.cs b/Checkpoint1/Checkpoint1.cs index 04b6d2ab..e33b1e8e 100644 --- a/Checkpoint1/Checkpoint1.cs +++ b/Checkpoint1/Checkpoint1.cs @@ -23,6 +23,7 @@ static void Main(string[] args) playerNumbersList.Add(Convert.ToInt32(userResponse)); } } + // put all results here int result = 0; for (int i = 0; i < playerNumbersList.Count; i++) { From 2a2365ab9dde55f1cdec9b6a066dfb522729951e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Jan 2019 18:20:19 -0600 Subject: [PATCH 03/23] finished factorial --- checkpoint1Factorial/.vscode/launch.json | 26 +++++++++++++++++++ checkpoint1Factorial/.vscode/tasks.json | 15 +++++++++++ checkpoint1Factorial/Program.cs | 19 ++++++++++++++ .../checkpoint1Factorial.csproj | 8 ++++++ 4 files changed, 68 insertions(+) create mode 100644 checkpoint1Factorial/.vscode/launch.json create mode 100644 checkpoint1Factorial/.vscode/tasks.json create mode 100644 checkpoint1Factorial/Program.cs create mode 100644 checkpoint1Factorial/checkpoint1Factorial.csproj diff --git a/checkpoint1Factorial/.vscode/launch.json b/checkpoint1Factorial/.vscode/launch.json new file mode 100644 index 00000000..fa9914d4 --- /dev/null +++ b/checkpoint1Factorial/.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/checkpoint1Factorial.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/checkpoint1Factorial/.vscode/tasks.json b/checkpoint1Factorial/.vscode/tasks.json new file mode 100644 index 00000000..19a03f3d --- /dev/null +++ b/checkpoint1Factorial/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/checkpoint1Factorial.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/checkpoint1Factorial/Program.cs b/checkpoint1Factorial/Program.cs new file mode 100644 index 00000000..3679bba2 --- /dev/null +++ b/checkpoint1Factorial/Program.cs @@ -0,0 +1,19 @@ +using System; + +namespace checkpoint1Factorial +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("enter a number for factorial"); + int userNumber = Convert.ToInt32(Console.ReadLine()); + for (int i = userNumber - 1; i > 0; i--) + { + userNumber = userNumber * i; + } + Console.WriteLine("the factorial is {0}", userNumber); + + } + } +} diff --git a/checkpoint1Factorial/checkpoint1Factorial.csproj b/checkpoint1Factorial/checkpoint1Factorial.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/checkpoint1Factorial/checkpoint1Factorial.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + From bdda32b00cb851a557b37cda3f7daa18166417a3 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Jan 2019 23:47:43 -0600 Subject: [PATCH 04/23] candles --- candles/.vscode/launch.json | 26 ++++++++++++++++++++++++++ candles/.vscode/tasks.json | 15 +++++++++++++++ candles/Program.cs | 27 +++++++++++++++++++++++++++ candles/candles.csproj | 8 ++++++++ 4 files changed, 76 insertions(+) create mode 100644 candles/.vscode/launch.json create mode 100644 candles/.vscode/tasks.json create mode 100644 candles/Program.cs create mode 100644 candles/candles.csproj diff --git a/candles/.vscode/launch.json b/candles/.vscode/launch.json new file mode 100644 index 00000000..f21ac0e4 --- /dev/null +++ b/candles/.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/candles.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/candles/.vscode/tasks.json b/candles/.vscode/tasks.json new file mode 100644 index 00000000..632ae459 --- /dev/null +++ b/candles/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/candles.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/candles/Program.cs b/candles/Program.cs new file mode 100644 index 00000000..48f78897 --- /dev/null +++ b/candles/Program.cs @@ -0,0 +1,27 @@ +using System; + +namespace candles +{ + class Program + { + static void Main(string[] args) + { + int[] numberOfCandles = { 1, 3, 2, 6, 7, 9, 9, 8, 7, 3, 9, }; + int largest = 0; + int howManyCandles = 1; + foreach (var num in numberOfCandles) + { + if (num > largest) + { + largest = num; + howManyCandles = 1; + } + else if (num == largest) + { + howManyCandles++; + } + } + Console.WriteLine("they can blow out {0} candles", howManyCandles); + } + } +} diff --git a/candles/candles.csproj b/candles/candles.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/candles/candles.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + From 268aa6a27da3ee1c029900f7d5e46023ba620640 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 Jan 2019 00:23:36 -0600 Subject: [PATCH 05/23] basic idea mapped --- guessingGame/Program.cs | 18 ++++++++++++++++++ guessingGame/guessingGame.csproj | 8 ++++++++ 2 files changed, 26 insertions(+) create mode 100644 guessingGame/Program.cs create mode 100644 guessingGame/guessingGame.csproj diff --git a/guessingGame/Program.cs b/guessingGame/Program.cs new file mode 100644 index 00000000..99be274f --- /dev/null +++ b/guessingGame/Program.cs @@ -0,0 +1,18 @@ +using System; + +namespace guessingGame +{ + class Program + { + static void Main(string[] args) + { + //find a random # between 1/10 + + //take in 4 guesses and match against the number + Console.WriteLine("Hello World!"); + } + } + /*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.) */ +} diff --git a/guessingGame/guessingGame.csproj b/guessingGame/guessingGame.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/guessingGame/guessingGame.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + From e2f3269ace70d0e25b082e2d920aae7e1d980b22 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Feb 2019 00:43:56 -0600 Subject: [PATCH 06/23] got the number and cheating done --- guessingGame/Program.cs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/guessingGame/Program.cs b/guessingGame/Program.cs index 99be274f..388908e0 100644 --- a/guessingGame/Program.cs +++ b/guessingGame/Program.cs @@ -6,12 +6,33 @@ class Program { static void Main(string[] args) { - //find a random # between 1/10 - + RandomNumber guess_me = new RandomNumber(); + guess_me.Cheat(3); //take in 4 guesses and match against the number - Console.WriteLine("Hello World!"); + Console.WriteLine("{0}", guess_me.guess_this); + } + } + class RandomNumber + { + private Random rnd = new Random(); + + public RandomNumber() + { + guess_this = rnd.Next(1, 10); + } + public void Cheat(int selected_number) + { + this.guess_this = selected_number; } + public int guess_this { get; private set; } } + + class PlayGame + { + + + } + /*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.) */ From bc6bf025637366ca5b62e9a4cb6be7b13e843a24 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Feb 2019 18:47:52 -0600 Subject: [PATCH 07/23] finished random number and cheating --- guessingGame/Program.cs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/guessingGame/Program.cs b/guessingGame/Program.cs index 388908e0..8ef6f3ea 100644 --- a/guessingGame/Program.cs +++ b/guessingGame/Program.cs @@ -7,22 +7,36 @@ class Program static void Main(string[] args) { RandomNumber guess_me = new RandomNumber(); - guess_me.Cheat(3); + Console.WriteLine("cheat code?"); + guess_me.Cheat(Console.ReadLine()); + //take in 4 guesses and match against the number Console.WriteLine("{0}", guess_me.guess_this); } } class RandomNumber { + private bool cheat = false; private Random rnd = new Random(); public RandomNumber() { guess_this = rnd.Next(1, 10); } - public void Cheat(int selected_number) + public void Cheat(string selected_number) { - this.guess_this = selected_number; + try + { + this.guess_this = Convert.ToInt32(selected_number); + cheat = true; + } + catch (System.FormatException) + { + Console.WriteLine("incorrect CheatCode"); + Console.WriteLine("A random # has been generated"); + Console.ReadLine(); + } + } public int guess_this { get; private set; } } @@ -30,7 +44,6 @@ public void Cheat(int selected_number) class PlayGame { - } /*Write a program that picks a random number between 1 and 10. Give the user 4 chances to guess the number. From 18a45953ff2566134f9696844c98d773aa7eefb4 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Feb 2019 20:48:05 -0600 Subject: [PATCH 08/23] finished a bit ran into issues going to study session tomorrow --- guessingGame/Program.cs | 115 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 108 insertions(+), 7 deletions(-) diff --git a/guessingGame/Program.cs b/guessingGame/Program.cs index 8ef6f3ea..86569d5a 100644 --- a/guessingGame/Program.cs +++ b/guessingGame/Program.cs @@ -7,8 +7,16 @@ class Program static void Main(string[] args) { RandomNumber guess_me = new RandomNumber(); + Console.WriteLine("What is your name?"); + string name = Console.ReadLine(); + Console.WriteLine("What is your age?"); + int age = Convert.ToInt32(Console.ReadLine()); + PlayerStatistics player = new PlayerStatistics(name, age); Console.WriteLine("cheat code?"); guess_me.Cheat(Console.ReadLine()); + PlayGame start = new PlayGame(player, guess_me); + bool winner = start.guess_loop(start.number, player); + //take in 4 guesses and match against the number Console.WriteLine("{0}", guess_me.guess_this); @@ -18,17 +26,18 @@ class RandomNumber { private bool cheat = false; private Random rnd = new Random(); - + private int guess_it; public RandomNumber() { guess_this = rnd.Next(1, 10); + guess_it = guess_this; } public void Cheat(string selected_number) { try { - this.guess_this = Convert.ToInt32(selected_number); - cheat = true; + this.guess_it = Convert.ToInt32(selected_number); + this.cheat = true; } catch (System.FormatException) { @@ -38,15 +47,107 @@ public void Cheat(string selected_number) } } + public int RequestNumber() + { + return guess_it; + } public int guess_this { get; private set; } } - class PlayGame + class PlayerStatistics { + private int lives = 4; + private bool cheat = false; + + public PlayerStatistics(string player_name, int player_age) + { + this.name = player_name; + this.age = player_age; + } + + public string name { get; private set; } + public int age { get; private set; } + + public int CheckLives() + { + return this.lives; + } + + public void Cheat(int selected_number) + { + try + { + this.lives = Convert.ToInt32(selected_number); + cheat = true; + } + catch (System.FormatException) + { + Console.WriteLine("incorrect CheatCode"); + Console.WriteLine("Good Try, press enter to exit."); + Console.ReadLine(); + } + + } } - /*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.) */ + class PlayGame + { + private bool cheat = false; + private int lives; + public PlayGame(PlayerStatistics player, RandomNumber guess_me) + { + PlayerStatistics player_data = player; + number = guess_me.RequestNumber(); + lives = player.CheckLives(); + int num_to_guess = number; + guess_loop(num_to_guess, player_data); + } + + public bool guess_loop(int num_to_guess, PlayerStatistics player_data) + { + bool number_guessed = false; + bool winner = false; + int guess_this = number; + while (lives < 0 && !number_guessed) + { + Console.WriteLine("Guess the number"); + int player_guess = Convert.ToInt32(Console.ReadLine()); + try + { + if (player_guess == guess_this) + { + Console.WriteLine("you have Won"); + number_guessed = true; + winner = true; + } + else if (lives > 0) + { + Console.WriteLine("Try Again! you have {0} lives left", lives); + } + else + { + Console.WriteLine("You have {0} lives left, Game Over", lives); + Console.WriteLine("Cheat?"); + player_data.Cheat(Convert.ToInt32(Console.ReadLine())); + } + + + + } + catch (System.Exception) + { + Console.WriteLine("Good Game"); + Console.ReadLine(); + } + } + return winner; + } + + public object player_data { get; private set; } + public int number { get; private set; } + /*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.) */ + } } From 456e3fcda7d3e2905c0700ac284d84b38d20dd20 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 2 Feb 2019 17:13:35 -0600 Subject: [PATCH 09/23] stuff from tutor --- guessingGame/Program.cs | 13 ++---- jukebox/.vscode/launch.json | 26 ++++++++++++ jukebox/.vscode/tasks.json | 15 +++++++ jukebox/Program.cs | 80 +++++++++++++++++++++++++++++++++++++ jukebox/jukebox.csproj | 8 ++++ 5 files changed, 133 insertions(+), 9 deletions(-) create mode 100644 jukebox/.vscode/launch.json create mode 100644 jukebox/.vscode/tasks.json create mode 100644 jukebox/Program.cs create mode 100644 jukebox/jukebox.csproj diff --git a/guessingGame/Program.cs b/guessingGame/Program.cs index 86569d5a..2b94d493 100644 --- a/guessingGame/Program.cs +++ b/guessingGame/Program.cs @@ -15,8 +15,7 @@ static void Main(string[] args) Console.WriteLine("cheat code?"); guess_me.Cheat(Console.ReadLine()); PlayGame start = new PlayGame(player, guess_me); - bool winner = start.guess_loop(start.number, player); - + start.guess_loop(start.number, player); //take in 4 guesses and match against the number Console.WriteLine("{0}", guess_me.guess_this); @@ -95,19 +94,19 @@ class PlayGame { private bool cheat = false; private int lives; + private bool winner; public PlayGame(PlayerStatistics player, RandomNumber guess_me) { PlayerStatistics player_data = player; number = guess_me.RequestNumber(); lives = player.CheckLives(); int num_to_guess = number; - guess_loop(num_to_guess, player_data); } - public bool guess_loop(int num_to_guess, PlayerStatistics player_data) + public void guess_loop(int num_to_guess, PlayerStatistics player_data) { bool number_guessed = false; - bool winner = false; + //bool winner = false; int guess_this = number; while (lives < 0 && !number_guessed) { @@ -131,9 +130,6 @@ public bool guess_loop(int num_to_guess, PlayerStatistics player_data) Console.WriteLine("Cheat?"); player_data.Cheat(Convert.ToInt32(Console.ReadLine())); } - - - } catch (System.Exception) { @@ -141,7 +137,6 @@ public bool guess_loop(int num_to_guess, PlayerStatistics player_data) Console.ReadLine(); } } - return winner; } public object player_data { get; private set; } diff --git a/jukebox/.vscode/launch.json b/jukebox/.vscode/launch.json new file mode 100644 index 00000000..25cabcd4 --- /dev/null +++ b/jukebox/.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/jukebox.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/jukebox/.vscode/tasks.json b/jukebox/.vscode/tasks.json new file mode 100644 index 00000000..bdf53bd0 --- /dev/null +++ b/jukebox/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/jukebox.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/jukebox/Program.cs b/jukebox/Program.cs new file mode 100644 index 00000000..bf04af94 --- /dev/null +++ b/jukebox/Program.cs @@ -0,0 +1,80 @@ +using System; +using System.Threading; + +namespace jukebox +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Which song would you like to hear! or exit to exit"); + Console.WriteLine("1: Fur Elise"); + Console.WriteLine("2: Mission Impossible Theme"); + Console.WriteLine("3: Tetris - song: b"); + Console.WriteLine("more to come...."); + try + { + int select = Convert.ToInt32(Console.ReadLine()); ; + Play start = new Play(select); + } + catch (System.Exception) + { + + Console.WriteLine("Invalid selection"); + } + } + class Play + { + public Play(int song_selection) + { + Library song = new Library(song_selection); + int[] freq = song.frequency; + int[] dur = song.duration; + PlaySong(freq, dur); + + } + public void PlaySong(int[] freq, int[] dur) + { + + for (int i = 0; i < freq.Length; i++) + { + if (freq[i] == 0) + { + Thread.Sleep(dur[i]); + } + else + { + Console.Beep(freq[i], dur[i]); + } + } + } + } + class Library + { + + public Library(int song_selection) + { + switch (song_selection) + { + case 1: + frequency = new int[] { 420, 400, 420, 400, 420, 315, 370, 335, 282, 180, 215, 282, 315, 213, 262, 315, 335, 213, 420, 400, 420, 400, 420, 315, 370, 335, 282, 180, 215, 282, 315, 213, 330, 315, 282 }; + duration = new int[] { 200, 200, 200, 200, 200, 200, 200, 200, 600, 200, 200, 200, 600, 200, 200, 200, 600, 200, 200, 200, 200, 200, 200, 200, 200, 200, 600, 200, 200, 200, 600, 200, 200, 200, 600 }; + break; + case 2: + frequency = new int[] { 0, 784, 0, 784, 0, 784, 0, 932, 0, 1047, 0, 784, 0, 784, 0, 699, 0, 740, 0, 784, 0, 784, 0, 932, 784, 587, 0, 932, 784, 554, 0, 932, 784, 523, 0, 466, 523 }; + duration = new int[] { 300, 150, 300, 150, 150, 150, 150, 150, 300, 150, 300, 150, 150, 150, 150, 150, 300, 150, 300, 150, 150, 150, 150, 150, 150, 1200, 75, 150, 150, 1200, 75, 150, 150, 1200, 150, 150, 150 }; + break; + case 3: + frequency = new int[] { 658, 1320, 990, 1056, 1188, 1320, 1188, 1056, 990, 880, 880, 1056, 1320, 1188, 1056, 990, 1056, 1188, 1320, 1056, 880, 880, 0, 1188, 1408, 1760, 1584, 1408, 1320, 1056, 1320, 1188, 1056, 990, 990, 1056, 1188, 1320, 1056, 880, 880, 0, 1320, 990, 1056, 1188, 1320, 1188, 1056, 990, 880, 880, 1056, 1320, 1188, 1056, 990, 1056, 1188, 1320, 1056, 880, 880, 0, 1188, 1408, 1760, 1584, 1408, 1320, 1056, 1320, 1188, 1056, 990, 990, 1056, 1188, 1320, 1056, 880, 880, 0, 660, 528, 594, 495, 528, 440, 419, 495, 660, 528, 594, 495, 528, 660, 880, 838, 660, 528, 594, 495, 528, 440, 419, 495, 660, 528, 594, 495, 528, 660, 880, 838 }; + duration = new int[] { 125, 500, 250, 250, 250, 125, 125, 250, 250, 500, 250, 250, 500, 250, 250, 750, 250, 500, 500, 500, 500, 500, 250, 500, 250, 500, 250, 250, 750, 250, 500, 250, 250, 500, 250, 250, 500, 500, 500, 500, 500, 500, 500, 250, 250, 250, 125, 125, 250, 250, 500, 250, 250, 500, 250, 250, 750, 250, 500, 500, 500, 500, 500, 250, 500, 250, 500, 250, 250, 750, 250, 500, 250, 250, 500, 250, 250, 500, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 1000, 2000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 1000, 2000 }; + break; + default: + Console.WriteLine("Default case"); + break; + } + } + public int[] frequency { get; private set; } + public int[] duration { get; private set; } + } + } +} diff --git a/jukebox/jukebox.csproj b/jukebox/jukebox.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/jukebox/jukebox.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + From 96c65278ce422500597f5df6e803ed99602bfc95 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 3 Feb 2019 01:47:24 -0600 Subject: [PATCH 10/23] ruff outline on new version of guessing game up --- guessingGame/Program.cs | 158 +++++++++++----------------------------- 1 file changed, 43 insertions(+), 115 deletions(-) diff --git a/guessingGame/Program.cs b/guessingGame/Program.cs index 2b94d493..b022e206 100644 --- a/guessingGame/Program.cs +++ b/guessingGame/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace guessingGame { @@ -6,143 +7,70 @@ class Program { static void Main(string[] args) { - RandomNumber guess_me = new RandomNumber(); - Console.WriteLine("What is your name?"); - string name = Console.ReadLine(); - Console.WriteLine("What is your age?"); - int age = Convert.ToInt32(Console.ReadLine()); - PlayerStatistics player = new PlayerStatistics(name, age); - Console.WriteLine("cheat code?"); - guess_me.Cheat(Console.ReadLine()); - PlayGame start = new PlayGame(player, guess_me); - start.guess_loop(start.number, player); - - //take in 4 guesses and match against the number - Console.WriteLine("{0}", guess_me.guess_this); + //run game controller } } - class RandomNumber - { - private bool cheat = false; - private Random rnd = new Random(); - private int guess_it; - public RandomNumber() - { - guess_this = rnd.Next(1, 10); - guess_it = guess_this; - } - public void Cheat(string selected_number) - { - try - { - this.guess_it = Convert.ToInt32(selected_number); - this.cheat = true; - } - catch (System.FormatException) - { - Console.WriteLine("incorrect CheatCode"); - Console.WriteLine("A random # has been generated"); - Console.ReadLine(); - } - - } - public int RequestNumber() - { - return guess_it; - } - public int guess_this { get; private set; } - } + // keep track of player data games played cheating lives in each game class PlayerStatistics { + private string player_first; + private string player_last; + private int[] guessing_game = new int[] { 0, 0, 0, 0 }; private int lives = 4; - private bool cheat = false; - - public PlayerStatistics(string player_name, int player_age) + public PlayerStatistics(string first, string last) { - this.name = player_name; - this.age = player_age; - } - - public string name { get; private set; } - public int age { get; private set; } - public int CheckLives() - { - return this.lives; + player_first = first; + player_last = last; } - public void Cheat(int selected_number) + //statistics generator + public void GenerateStatistics() { - try + List game_list = new List() { "* Guessing Game *" }; + //List stats_list = new List(){}; + // for times sake will have to adapt this to add games to a list and loop through + //if i have time i will make it generate spacing based off word length + Console.Clear(); + string top_bot = "***********************************************"; + Console.WriteLine("* Name: {1}, {0} *", player_first, player_last); + for (int i = 0; i == game_list.Count; i++) { - this.lives = Convert.ToInt32(selected_number); - cheat = true; + Console.WriteLine(top_bot); + Console.WriteLine("* *");//45 + Console.WriteLine(game_list[i]); + Console.WriteLine("*Played: {0} *", "00" + guessing_game[i]);//make sure all numbers come out to XXX ie 001, 002, 201, 999 max + Console.WriteLine("*Won: {0} Lost: {1}*", "00" + guessing_game[i + 1], "00" + guessing_game[i + 2]); + Console.WriteLine("*Cheated: {0} *", "00" + guessing_game[i + 3]); } - catch (System.FormatException) - { - Console.WriteLine("incorrect CheatCode"); - Console.WriteLine("Good Try, press enter to exit."); - Console.ReadLine(); - } - + Console.WriteLine(top_bot); } - } - class PlayGame + //Game controller + class ProgramController { - private bool cheat = false; - private int lives; - private bool winner; - public PlayGame(PlayerStatistics player, RandomNumber guess_me) - { - PlayerStatistics player_data = player; - number = guess_me.RequestNumber(); - lives = player.CheckLives(); - int num_to_guess = number; - } + //run software until quit + private bool quit = false; - public void guess_loop(int num_to_guess, PlayerStatistics player_data) + public ProgramController() { - bool number_guessed = false; - //bool winner = false; - int guess_this = number; - while (lives < 0 && !number_guessed) + //run software until quit + while (quit) { - Console.WriteLine("Guess the number"); - int player_guess = Convert.ToInt32(Console.ReadLine()); - try - { - if (player_guess == guess_this) - { - Console.WriteLine("you have Won"); - number_guessed = true; - winner = true; - } - else if (lives > 0) - { - Console.WriteLine("Try Again! you have {0} lives left", lives); - } - else - { - Console.WriteLine("You have {0} lives left, Game Over", lives); - Console.WriteLine("Cheat?"); - player_data.Cheat(Convert.ToInt32(Console.ReadLine())); - } - } - catch (System.Exception) - { - Console.WriteLine("Good Game"); - Console.ReadLine(); - } + } } - public object player_data { get; private set; } - public int number { get; private set; } - /*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.) */ + //number guess game + } + + //Cheat controller + class CheatController + { + private bool is_cheating = false; + } + //number guess game } From 317fde32af9179aac17d07adfb5764b032fec580 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 3 Feb 2019 14:22:52 -0600 Subject: [PATCH 11/23] structure done starting play controller --- guessingGame/Program.cs | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/guessingGame/Program.cs b/guessingGame/Program.cs index b022e206..3f5a281f 100644 --- a/guessingGame/Program.cs +++ b/guessingGame/Program.cs @@ -18,6 +18,7 @@ class PlayerStatistics private string player_last; private int[] guessing_game = new int[] { 0, 0, 0, 0 }; private int lives = 4; + public PlayerStatistics(string first, string last) { @@ -47,30 +48,4 @@ public void GenerateStatistics() Console.WriteLine(top_bot); } } - - //Game controller - class ProgramController - { - //run software until quit - private bool quit = false; - - public ProgramController() - { - //run software until quit - while (quit) - { - - } - } - - //number guess game - } - - //Cheat controller - class CheatController - { - private bool is_cheating = false; - - } - //number guess game } From 8d09a4dc78774d37f99713a1060ba14fb7b1900b Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 3 Feb 2019 14:23:53 -0600 Subject: [PATCH 12/23] structure done starting play controller --- guessingGame/PlayController.cs | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 guessingGame/PlayController.cs diff --git a/guessingGame/PlayController.cs b/guessingGame/PlayController.cs new file mode 100644 index 00000000..abbc7ca5 --- /dev/null +++ b/guessingGame/PlayController.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; + +namespace guessingGame +{ + + class ProgramController + { + private bool quit = false; + + public ProgramController(PlayerStatistics user_data) + { + PlayerStatistics data_file = user_data; + CheatController cheats = new CheatController(); + + //run software until quit + + while (quit) + { + // build menu + //take in a choice + //play game of choosing + //capture the data back contained in userdata + // pass same userdata into as many games as needed and + } + } + + //number guess game + } + + //Cheat controller + class CheatController + { + private bool inf_lives = false; + private bool not_random = false; + } + //number guess game +} From d41faf6c11f4c7ee64781e05534deb9f79f817d7 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 3 Feb 2019 14:24:35 -0600 Subject: [PATCH 13/23] structure done starting play controller --- guessingGame/GuessingGame.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 guessingGame/GuessingGame.cs diff --git a/guessingGame/GuessingGame.cs b/guessingGame/GuessingGame.cs new file mode 100644 index 00000000..61b074bc --- /dev/null +++ b/guessingGame/GuessingGame.cs @@ -0,0 +1,25 @@ +using System; + +namespace guessingGame +{ + class RandomNumber + { + //get a random number and store the properties of the random + public RandomNumber(CheatController cheat) + { + CheatController check = cheat; + + //if = 1337 + + } + + + /*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.) */ + } + class PlayGame + { + + } +} \ No newline at end of file From db4933a27675415d50231269ad7bb3a86a7a3cf8 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Feb 2019 00:03:58 -0600 Subject: [PATCH 14/23] got it working 100% --- guessingGame/GuessingGame.cs | 152 ++++++++++++++++++++++++++++++--- guessingGame/PlayController.cs | 98 ++++++++++++++++++--- guessingGame/Program.cs | 60 +++++-------- 3 files changed, 251 insertions(+), 59 deletions(-) diff --git a/guessingGame/GuessingGame.cs b/guessingGame/GuessingGame.cs index 61b074bc..40d142aa 100644 --- a/guessingGame/GuessingGame.cs +++ b/guessingGame/GuessingGame.cs @@ -1,25 +1,155 @@ using System; +using System.Threading; namespace guessingGame { class RandomNumber { - //get a random number and store the properties of the random - public RandomNumber(CheatController cheat) + private int guess_me; + private bool pick_num_cheat = false; + private Random random = new Random(); + public RandomNumber(CheatController cheats) { - CheatController check = cheat; + bool[] is_cheating = cheats.RetriveCheats(); + if (is_cheating[0]) + { + pick_num_cheat = true; + } + } + public int GetNumber() + { + if (pick_num_cheat) + { + Console.WriteLine("pick a number"); + guess_me = Convert.ToInt32(Console.ReadLine()); + } + else + { + guess_me = random.Next(1, 10); + } + return guess_me; + } + } + class PlayGuessingGame + { + private int lives; + private bool pick_num_cheat = false; + private int guess_this; + private PlayerStatistics player_data; + private CheatController active_cheats; - //if = 1337 + public PlayGuessingGame(PlayerStatistics user_data, CheatController cheats) + { + this.player_data = user_data; + this.active_cheats = cheats; + this.lives = user_data.lives; + RandomNumber get_number = new RandomNumber(this.active_cheats); + guess_this = get_number.GetNumber(); + bool[] is_cheating = active_cheats.RetriveCheats(); + if (is_cheating[0]) + { + this.pick_num_cheat = true; + } + if (is_cheating[1]) + { + this.lives = -1; + this.player_data.CheckCheating(is_cheating[1]); + } } + public bool CheckWin(int user_guess) + { + if (user_guess == guess_this) + { + return true; + } + else + { + return false; + } + } + public int[] PlayGame() + { + Console.Clear(); + Console.WriteLine("***********************************************"); + Console.WriteLine("* Guessing Game *"); + Console.WriteLine("***********************************************"); + int user_guess = 0; + bool win = false; + bool loss = false; + int[] results = new int[4] { 0, 0, 0, 0 }; + if (lives < 0 || pick_num_cheat) + { + results[3]++; + } + while ((lives > 0 || lives < 0) && !win) + { + Console.WriteLine("enter guess"); + try + { + user_guess = Convert.ToInt32(Console.ReadLine()); + } + catch (System.Exception) + { + Console.WriteLine("Invalid Guess!"); + } + bool guess_correct = CheckWin(user_guess); + bool[] is_cheating = active_cheats.RetriveCheats(); + if (guess_correct) + { + win = true; + for (int i = 0; i < 5; i++) + { + Console.Clear(); + if (is_cheating[0] || is_cheating[1]) + { + Thread.Sleep(250); + Console.WriteLine("You have WON!!! ;)"); + Thread.Sleep(250); + } + else + { + Thread.Sleep(250); + Console.WriteLine("You have WON!!!"); + Thread.Sleep(250); + } + } + } + else + { + lives--; + } + } + if (lives == 0) + { + loss = true; + } - /*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.) */ + if (loss) + { + for (int i = 0; i < 5; i++) + { + Console.Clear(); + Thread.Sleep(250); + Console.WriteLine("You have LOST!!!"); + Thread.Sleep(250); + } + } + results[0]++; + if (loss) + { + results[2]++; + } + else + { + results[1]++; + } + return results; + } } - class PlayGame - { +} - } -} \ No newline at end of file +/*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.)*/ diff --git a/guessingGame/PlayController.cs b/guessingGame/PlayController.cs index abbc7ca5..bb4c4c84 100644 --- a/guessingGame/PlayController.cs +++ b/guessingGame/PlayController.cs @@ -7,32 +7,108 @@ namespace guessingGame class ProgramController { private bool quit = false; + PlayerStatistics data_file; + CheatController cheats; + public ProgramController(PlayerStatistics user_data) { - PlayerStatistics data_file = user_data; - CheatController cheats = new CheatController(); + this.data_file = user_data; + this.cheats = new CheatController(); + } + public void Start() + { //run software until quit - - while (quit) + while (!quit) { + Console.Clear(); // build menu - //take in a choice - //play game of choosing - //capture the data back contained in userdata - // pass same userdata into as many games as needed and + Console.WriteLine("***********************************************"); + Console.WriteLine("* Play Guessing Game : press g *"); + Console.WriteLine("* Cheat: press c *"); + Console.WriteLine("* Exit: press x *"); + Console.WriteLine("* Current Stats: press s *"); + Console.WriteLine("***********************************************"); + string choice = "void"; + while (choice == "void") + { + try + { + choice = Console.ReadLine(); + + } + catch (System.Exception) + { + Console.WriteLine("Invalid Selection. Please try again."); + } + } + + if (choice == "g") + { + int[] results; + PlayGuessingGame play = new PlayGuessingGame(data_file, cheats); + results = play.PlayGame(); + int i = 0; + foreach (var item in results) + { + data_file.guessing_game[i] = data_file.guessing_game[i] + item; + i++; + } + } + else if (choice == "c") + { + Console.WriteLine("Enter Cheat Code"); + try + { + cheats.AddCheat(Console.ReadLine()); + } + catch (System.Exception) + { + Console.WriteLine("Invalid Entry!"); + } + } + else if (choice == "s") + { + data_file.GenerateStatistics(); + } + else if (choice == "x") + { + this.quit = true; + } } } - - //number guess game } //Cheat controller class CheatController { - private bool inf_lives = false; private bool not_random = false; + private bool inf_lives = false; + private bool added_cheat = false; + public void AddCheat(string password) + { + if (password == "ch0053#" && !not_random) + { + this.not_random = true; + this.added_cheat = true; + } + if (password == "und131ng" && !inf_lives) + { + this.inf_lives = true; + this.added_cheat = true; + } + if (!this.added_cheat) + { + Console.WriteLine("Invalid Cheat Code or that cheat is already enabled!"); + } + } + public bool[] RetriveCheats() + { + bool[] cheats = new bool[] { this.not_random, this.inf_lives }; + return cheats; + } + } //number guess game } diff --git a/guessingGame/Program.cs b/guessingGame/Program.cs index 3f5a281f..eadab64d 100644 --- a/guessingGame/Program.cs +++ b/guessingGame/Program.cs @@ -7,45 +7,31 @@ class Program { static void Main(string[] args) { - //run game controller - } - } - - // keep track of player data games played cheating lives in each game - class PlayerStatistics - { - private string player_first; - private string player_last; - private int[] guessing_game = new int[] { 0, 0, 0, 0 }; - private int lives = 4; - - public PlayerStatistics(string first, string last) - { - - player_first = first; - player_last = last; - } - - //statistics generator - public void GenerateStatistics() - { - List game_list = new List() { "* Guessing Game *" }; - //List stats_list = new List(){}; - // for times sake will have to adapt this to add games to a list and loop through - //if i have time i will make it generate spacing based off word length - Console.Clear(); - string top_bot = "***********************************************"; - Console.WriteLine("* Name: {1}, {0} *", player_first, player_last); - for (int i = 0; i == game_list.Count; i++) + //run profile creation + string first = ""; + string last = ""; + while (first == "" || last == "") { - Console.WriteLine(top_bot); - Console.WriteLine("* *");//45 - Console.WriteLine(game_list[i]); - Console.WriteLine("*Played: {0} *", "00" + guessing_game[i]);//make sure all numbers come out to XXX ie 001, 002, 201, 999 max - Console.WriteLine("*Won: {0} Lost: {1}*", "00" + guessing_game[i + 1], "00" + guessing_game[i + 2]); - Console.WriteLine("*Cheated: {0} *", "00" + guessing_game[i + 3]); + if (first == "") + { + Console.Clear(); + Console.Write("Enter first name: "); + first = Console.ReadLine(); + } + else if (last == "") + { + Console.Clear(); + Console.Write("Enter last name: "); + last = Console.ReadLine(); + } + } - Console.WriteLine(top_bot); + PlayerStatistics new_player = new PlayerStatistics(first, last); + ProgramController start_playing = new ProgramController(new_player); + + start_playing.Start(); + Console.WriteLine("Thanks for playing. Press enter to exit."); + Console.ReadLine(); } } } From c44da5ce9cd99147c06b63721f1528848a3d627e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Feb 2019 10:40:15 -0600 Subject: [PATCH 15/23] finished --- guessingGame/PlayerStats.cs | 55 +++++++++++++++++++++++++++++++++++++ guessingGame/Program.cs | 1 + 2 files changed, 56 insertions(+) create mode 100644 guessingGame/PlayerStats.cs diff --git a/guessingGame/PlayerStats.cs b/guessingGame/PlayerStats.cs new file mode 100644 index 00000000..0d30805e --- /dev/null +++ b/guessingGame/PlayerStats.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; + +namespace guessingGame +{ + class PlayerStatistics + { + private string player_first; + private string player_last; + public int[] guessing_game { get; set; } + public int lives { get; set; } + private bool lives_cheat { get; set; } + + public void CheckCheating(bool is_cheating) + { + if (is_cheating) + { + this.lives_cheat = true; + } + else + { + + } + } + public PlayerStatistics(string first, string last) + { + this.player_first = first; + this.player_last = last; + this.guessing_game = new int[] { 0, 0, 0, 0 }; + this.lives = 4; + } + + //statistics generator + public void GenerateStatistics() + { + List game_list = new List() { "* Guessing Game *" }; + //List stats_list = new List(){}; + // for times sake will have to adapt this to add games to a list and loop through + //if i have time i will make it generate spacing based off word length + Console.Clear(); + string top_bot = "***********************************************"; + Console.WriteLine("* Name: {1}, {0} *", player_first, player_last); + Console.WriteLine(top_bot); + Console.WriteLine("* *");//45 + Console.WriteLine(game_list[0]); + Console.WriteLine("*Played: {0} *", "00" + guessing_game[0]); + Console.WriteLine("*Won: {0} Lost: {1}*", "00" + guessing_game[1], "00" + guessing_game[2]); + Console.WriteLine("*Cheated: {0} *", "00" + guessing_game[3]); + Console.WriteLine(top_bot); + Console.WriteLine("Press enter to continue..."); + Console.ReadLine(); + Console.Clear(); + } + } +} \ No newline at end of file diff --git a/guessingGame/Program.cs b/guessingGame/Program.cs index eadab64d..b7f72259 100644 --- a/guessingGame/Program.cs +++ b/guessingGame/Program.cs @@ -14,6 +14,7 @@ static void Main(string[] args) { if (first == "") { + Console.Clear(); Console.Write("Enter first name: "); first = Console.ReadLine(); From 94e93c11b5f3b1fd620e3690231d76b87835d755 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Feb 2019 10:56:18 -0600 Subject: [PATCH 16/23] added find biggest from fiddle --- FindBiggest/FindBiggest.csproj | 8 +++++++ FindBiggest/Program.cs | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 FindBiggest/FindBiggest.csproj create mode 100644 FindBiggest/Program.cs diff --git a/FindBiggest/FindBiggest.csproj b/FindBiggest/FindBiggest.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/FindBiggest/FindBiggest.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + diff --git a/FindBiggest/Program.cs b/FindBiggest/Program.cs new file mode 100644 index 00000000..cc1e69d9 --- /dev/null +++ b/FindBiggest/Program.cs @@ -0,0 +1,38 @@ +using System; + +namespace FindBiggest +{ + class Program + { + static void Main(string[] args) + { + //continue to ask for numbers and return the highest + int highest_number = 0; + string current_number; + bool exit = false; + while (!exit) + { + Console.WriteLine("enter a number or e for exit"); + try + { + current_number = Console.ReadLine(); + int number = Convert.ToInt32(current_number); + if (current_number == "e") + { + exit = true; + } + else if (number > highest_number) + { + highest_number = number; + } + } + catch (System.Exception) + { + Console.WriteLine("Invalid Selection. Please try again."); + } + } + + Console.WriteLine("Your Highest Number is {0}"); + } + } +} From 2b5b358403feb546ab328ddc62294e84a531a340 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Feb 2019 10:58:11 -0600 Subject: [PATCH 17/23] finished --- guessingGame/.vscode/launch.json | 26 ++++++++++++++++++++++++++ guessingGame/.vscode/tasks.json | 15 +++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 guessingGame/.vscode/launch.json create mode 100644 guessingGame/.vscode/tasks.json diff --git a/guessingGame/.vscode/launch.json b/guessingGame/.vscode/launch.json new file mode 100644 index 00000000..1369ab24 --- /dev/null +++ b/guessingGame/.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/guessingGame.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/guessingGame/.vscode/tasks.json b/guessingGame/.vscode/tasks.json new file mode 100644 index 00000000..360a95d7 --- /dev/null +++ b/guessingGame/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/guessingGame.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file From cd539a0af3c3cbf55e7bb85fa0d43a794d098a92 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Feb 2019 11:23:02 -0600 Subject: [PATCH 18/23] finished finding div by 3 no remainder --- DivByThree/.vscode/launch.json | 26 ++++++++++++++++++++++++++ DivByThree/.vscode/tasks.json | 15 +++++++++++++++ DivByThree/DivByThree.csproj | 8 ++++++++ DivByThree/Program.cs | 22 ++++++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 DivByThree/.vscode/launch.json create mode 100644 DivByThree/.vscode/tasks.json create mode 100644 DivByThree/DivByThree.csproj create mode 100644 DivByThree/Program.cs diff --git a/DivByThree/.vscode/launch.json b/DivByThree/.vscode/launch.json new file mode 100644 index 00000000..1a58cb47 --- /dev/null +++ b/DivByThree/.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/DivByThree.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/DivByThree/.vscode/tasks.json b/DivByThree/.vscode/tasks.json new file mode 100644 index 00000000..153d9537 --- /dev/null +++ b/DivByThree/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/DivByThree.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/DivByThree/DivByThree.csproj b/DivByThree/DivByThree.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/DivByThree/DivByThree.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + diff --git a/DivByThree/Program.cs b/DivByThree/Program.cs new file mode 100644 index 00000000..babbf5f2 --- /dev/null +++ b/DivByThree/Program.cs @@ -0,0 +1,22 @@ +using System; + +namespace DivByThree +{ + class Program + { + static void Main(string[] args) + { + int how_many = 0; + + for (int i = 1; i <= 100; i++) + { + if (i % 3 == 0) + { + how_many++; + } + } + + Console.WriteLine(how_many); + } + } +} From 16e48ee833968fa98bc9a343285bc11baf547c9d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Feb 2019 18:27:17 -0600 Subject: [PATCH 19/23] finished div by 3 --- RockPaperScissors/RockPaperScissors.cs | 20 ++++++++++++++++++-- guessingGame/GuessingGame.cs | 8 ++++---- guessingGame/PlayController.cs | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/RockPaperScissors/RockPaperScissors.cs b/RockPaperScissors/RockPaperScissors.cs index dc58b15b..340f4124 100644 --- a/RockPaperScissors/RockPaperScissors.cs +++ b/RockPaperScissors/RockPaperScissors.cs @@ -14,11 +14,27 @@ public static void Main() { while (playAgain == true) { + string hand1 = null; + string hand2 = ""; Console.Clear(); Console.WriteLine("Enter hand 1:"); - string hand1 = Console.ReadLine().ToLower(); + try + { + hand1 = Console.ReadLine().ToLower(); + } + catch (System.Exception) + { + Console.WriteLine("invalid selection"); + } Console.WriteLine("Enter hand 2 or c for a computer player"); - string hand2 = Console.ReadLine().ToLower(); + try + { + hand2 = Console.ReadLine().ToLower(); + } + catch (System.Exception) + { + Console.WriteLine("invalid selection"); + } string showWinner = (CompareHands(hand1, hand2)); string[] splitResults = showWinner.Split('*'); string winnerText = splitResults[0]; diff --git a/guessingGame/GuessingGame.cs b/guessingGame/GuessingGame.cs index 40d142aa..af54dc31 100644 --- a/guessingGame/GuessingGame.cs +++ b/guessingGame/GuessingGame.cs @@ -96,12 +96,16 @@ public int[] PlayGame() } bool guess_correct = CheckWin(user_guess); bool[] is_cheating = active_cheats.RetriveCheats(); + // better way to do this is get/private set for + // expandability or use public var to get the private values. + // More than a couple of these in the array would get confusing. if (guess_correct) { win = true; for (int i = 0; i < 5; i++) { Console.Clear(); + if (is_cheating[0] || is_cheating[1]) { Thread.Sleep(250); @@ -149,7 +153,3 @@ public int[] PlayGame() } } } - -/*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.)*/ diff --git a/guessingGame/PlayController.cs b/guessingGame/PlayController.cs index bb4c4c84..09b058a3 100644 --- a/guessingGame/PlayController.cs +++ b/guessingGame/PlayController.cs @@ -84,7 +84,7 @@ public void Start() class CheatController { private bool not_random = false; - private bool inf_lives = false; + public bool inf_lives { get; private set; } = false; private bool added_cheat = false; public void AddCheat(string password) { From 4d45cf50115c8e3fb81d3ffcd4363f271bf46412 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Feb 2019 18:53:49 -0600 Subject: [PATCH 20/23] fixed spaceing in statistics print out --- guessingGame/PlayerStats.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/guessingGame/PlayerStats.cs b/guessingGame/PlayerStats.cs index 0d30805e..b99e775a 100644 --- a/guessingGame/PlayerStats.cs +++ b/guessingGame/PlayerStats.cs @@ -43,9 +43,9 @@ public void GenerateStatistics() Console.WriteLine(top_bot); Console.WriteLine("* *");//45 Console.WriteLine(game_list[0]); - Console.WriteLine("*Played: {0} *", "00" + guessing_game[0]); - Console.WriteLine("*Won: {0} Lost: {1}*", "00" + guessing_game[1], "00" + guessing_game[2]); - Console.WriteLine("*Cheated: {0} *", "00" + guessing_game[3]); + Console.WriteLine("* Played: {0} *", "00" + guessing_game[0]); + Console.WriteLine("* Won: {0} Lost: {1} *", "00" + guessing_game[1], "00" + guessing_game[2]); + Console.WriteLine("* Cheated: {0} *", "00" + guessing_game[3]); Console.WriteLine(top_bot); Console.WriteLine("Press enter to continue..."); Console.ReadLine(); From 5761fb220f23edb0a132278820bd9759bc937b9d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 5 Feb 2019 23:54:34 -0600 Subject: [PATCH 21/23] fixed some validation issues working on using string builder to build the display stuff --- guessingGame/GuessingGame.cs | 8 ++-- guessingGame/PlayController.cs | 75 ++++++++-------------------------- 2 files changed, 20 insertions(+), 63 deletions(-) diff --git a/guessingGame/GuessingGame.cs b/guessingGame/GuessingGame.cs index af54dc31..bcef7fa5 100644 --- a/guessingGame/GuessingGame.cs +++ b/guessingGame/GuessingGame.cs @@ -75,7 +75,7 @@ public int[] PlayGame() Console.WriteLine("* Guessing Game *"); Console.WriteLine("***********************************************"); int user_guess = 0; - bool win = false; + bool game_complete = false; bool loss = false; int[] results = new int[4] { 0, 0, 0, 0 }; if (lives < 0 || pick_num_cheat) @@ -83,7 +83,7 @@ public int[] PlayGame() results[3]++; } - while ((lives > 0 || lives < 0) && !win) + while (lives != 0 && !game_complete) { Console.WriteLine("enter guess"); try @@ -101,12 +101,12 @@ public int[] PlayGame() // More than a couple of these in the array would get confusing. if (guess_correct) { - win = true; + game_complete = true; for (int i = 0; i < 5; i++) { Console.Clear(); - if (is_cheating[0] || is_cheating[1]) + if (active_cheats.added_cheat) { Thread.Sleep(250); Console.WriteLine("You have WON!!! ;)"); diff --git a/guessingGame/PlayController.cs b/guessingGame/PlayController.cs index 09b058a3..a3b22568 100644 --- a/guessingGame/PlayController.cs +++ b/guessingGame/PlayController.cs @@ -22,27 +22,19 @@ public void Start() //run software until quit while (!quit) { - Console.Clear(); - // build menu - Console.WriteLine("***********************************************"); - Console.WriteLine("* Play Guessing Game : press g *"); - Console.WriteLine("* Cheat: press c *"); - Console.WriteLine("* Exit: press x *"); - Console.WriteLine("* Current Stats: press s *"); - Console.WriteLine("***********************************************"); - string choice = "void"; - while (choice == "void") + string choice; + do { - try - { - choice = Console.ReadLine(); + Console.Clear(); - } - catch (System.Exception) - { - Console.WriteLine("Invalid Selection. Please try again."); - } - } + Console.WriteLine("***********************************************"); + Console.WriteLine("* Play Guessing Game : press g *"); + Console.WriteLine("* Cheat: press c *"); + Console.WriteLine("* Exit: press x *"); + Console.WriteLine("* Current Stats: press s *"); + Console.WriteLine("***********************************************"); + choice = Console.ReadLine(); + } while (choice != "g" && choice != "c" && choice != "x" && choice != "s"); if (choice == "g") { @@ -58,15 +50,12 @@ public void Start() } else if (choice == "c") { + Console.Clear(); + Console.WriteLine("***********************************************"); + Console.WriteLine("* Cheats *"); + Console.WriteLine("***********************************************"); Console.WriteLine("Enter Cheat Code"); - try - { - cheats.AddCheat(Console.ReadLine()); - } - catch (System.Exception) - { - Console.WriteLine("Invalid Entry!"); - } + cheats.AddCheat(Console.ReadLine()); } else if (choice == "s") { @@ -79,36 +68,4 @@ public void Start() } } } - - //Cheat controller - class CheatController - { - private bool not_random = false; - public bool inf_lives { get; private set; } = false; - private bool added_cheat = false; - public void AddCheat(string password) - { - if (password == "ch0053#" && !not_random) - { - this.not_random = true; - this.added_cheat = true; - } - if (password == "und131ng" && !inf_lives) - { - this.inf_lives = true; - this.added_cheat = true; - } - if (!this.added_cheat) - { - Console.WriteLine("Invalid Cheat Code or that cheat is already enabled!"); - } - } - public bool[] RetriveCheats() - { - bool[] cheats = new bool[] { this.not_random, this.inf_lives }; - return cheats; - } - - } - //number guess game } From 3f2c82d0480f5e568261cfe3c3f9ec61b8c99c29 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Feb 2019 21:10:38 -0600 Subject: [PATCH 22/23] i forgot to add some files to git --- guessingGame/CheatController.cs | 35 +++++++++++++++++++++++++++++++++ guessingGame/DisplayBuilder.cs | 24 ++++++++++++++++++++++ guessingGame/bash.exe.stackdump | 16 +++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 guessingGame/CheatController.cs create mode 100644 guessingGame/DisplayBuilder.cs create mode 100644 guessingGame/bash.exe.stackdump diff --git a/guessingGame/CheatController.cs b/guessingGame/CheatController.cs new file mode 100644 index 00000000..a8e76ac8 --- /dev/null +++ b/guessingGame/CheatController.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; + +namespace guessingGame +{ + class CheatController + { + private bool not_random = false; + private bool inf_lives = false; + public bool added_cheat { get; private set; } = false; + public void AddCheat(string password) + { + if (password == "ch0053#" && !not_random) + { + this.not_random = true; + this.added_cheat = true; + } + if (password == "und131ng" && !inf_lives) + { + this.inf_lives = true; + this.added_cheat = true; + } + if (!this.added_cheat) + { + Console.WriteLine("Invalid Cheat Code or that cheat is already enabled!"); + } + } + public bool[] RetriveCheats() + { + bool[] cheats = new bool[] { this.not_random, this.inf_lives }; + return cheats; + } + + } +} \ No newline at end of file diff --git a/guessingGame/DisplayBuilder.cs b/guessingGame/DisplayBuilder.cs new file mode 100644 index 00000000..d0fcf67b --- /dev/null +++ b/guessingGame/DisplayBuilder.cs @@ -0,0 +1,24 @@ + + + + + + + + + + + +// Console.Clear(); +// Console.WriteLine("***********************************************"); +// Console.WriteLine("* Guessing Game *"); +// Console.WriteLine("***********************************************"); + + + +// Console.WriteLine("***********************************************"); +// Console.WriteLine("* Play Guessing Game : press g *"); +// Console.WriteLine("* Cheat: press c *"); +// Console.WriteLine("* Exit: press x *"); +// Console.WriteLine("* Current Stats: press s *"); +// Console.WriteLine("***********************************************"); \ No newline at end of file diff --git a/guessingGame/bash.exe.stackdump b/guessingGame/bash.exe.stackdump new file mode 100644 index 00000000..4bc86685 --- /dev/null +++ b/guessingGame/bash.exe.stackdump @@ -0,0 +1,16 @@ +Stack trace: +Frame Function Args +00180328AF0 0018006021E (00180247D00, 001802340B9, 00000000058, 000FFFFB740) +00180328AF0 00180048859 (00180236765, 00100000000, 00000000000, 00000000001) +00180328AF0 00180048892 (00000000000, 00000000000, 00000000058, 00180328950) +00180328AF0 0018006C179 (0000000000A, 00000000000, 0000000000A, 00000000000) +00180328AF0 0018006C342 (00000000003, 00000000000, 00180044EEF, 000FFFFCB30) +00000000000 0018006D3A8 (0000000000D, 000FFFFC920, 001800E4CF6, 000FFFFC920) +00000000000 00180058816 (000FFFF0000, 00000000000, 00000000000, 006FFFFFFFF) +00000000000 001800590A9 (000FFFFCAF0, 00600040000, 00000000000, 000FFFFCB80) +00180325CF8 001800595BA (001800C0322, 00000000000, 00000000000, 00000000000) +000FFFFCCD0 00180059937 (000FFFFCDF0, 000FFFFCCD0, FFFFFFFFFFFFFFD1, 00000000000) +000FFFFCCD0 00180048FE1 (00000000000, 00000000000, 00000000000, 00000000000) +00000000000 00180047963 (00000000000, 00000000000, 00000000000, 00000000000) +000FFFFFFF0 00180047A14 (00000000000, 00000000000, 00000000000, 00000000000) +End of stack trace From 218e93df3c300682257147f9f0ae5b9c5e9c60d0 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Feb 2019 21:17:17 -0600 Subject: [PATCH 23/23] fixed --- FindBiggest/Program.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/FindBiggest/Program.cs b/FindBiggest/Program.cs index cc1e69d9..a78fcfc3 100644 --- a/FindBiggest/Program.cs +++ b/FindBiggest/Program.cs @@ -17,22 +17,20 @@ static void Main(string[] args) { current_number = Console.ReadLine(); int number = Convert.ToInt32(current_number); - if (current_number == "e") - { - exit = true; - } - else if (number > highest_number) + if (number > highest_number) { highest_number = number; } } catch (System.Exception) { - Console.WriteLine("Invalid Selection. Please try again."); + + exit = true; + } } - Console.WriteLine("Your Highest Number is {0}"); + Console.WriteLine("Your Highest Number is {0}", highest_number); } } }