diff --git a/Checkpoint1/Checkpoint1.cs b/Checkpoint1/Checkpoint1.cs index b7ed8611..e33b1e8e 100644 --- a/Checkpoint1/Checkpoint1.cs +++ b/Checkpoint1/Checkpoint1.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace Checkpoint1 { @@ -6,7 +7,29 @@ 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)); + } + } + // put all results here + int result = 0; + for (int i = 0; i < playerNumbersList.Count; i++) + { + result = result + playerNumbersList[i]; + } + Console.WriteLine(result); } } } 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); + } + } +} 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..a78fcfc3 --- /dev/null +++ b/FindBiggest/Program.cs @@ -0,0 +1,36 @@ +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 (number > highest_number) + { + highest_number = number; + } + } + catch (System.Exception) + { + + exit = true; + + } + } + + Console.WriteLine("Your Highest Number is {0}", highest_number); + } + } +} 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/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 + + + 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 + + + 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 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/GuessingGame.cs b/guessingGame/GuessingGame.cs new file mode 100644 index 00000000..bcef7fa5 --- /dev/null +++ b/guessingGame/GuessingGame.cs @@ -0,0 +1,155 @@ +using System; +using System.Threading; + +namespace guessingGame +{ + class RandomNumber + { + private int guess_me; + private bool pick_num_cheat = false; + private Random random = new Random(); + public RandomNumber(CheatController cheats) + { + 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; + + 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 game_complete = false; + bool loss = false; + int[] results = new int[4] { 0, 0, 0, 0 }; + if (lives < 0 || pick_num_cheat) + { + results[3]++; + } + + while (lives != 0 && !game_complete) + { + 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(); + // 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) + { + game_complete = true; + for (int i = 0; i < 5; i++) + { + Console.Clear(); + + if (active_cheats.added_cheat) + { + 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; + } + + 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; + } + } +} diff --git a/guessingGame/PlayController.cs b/guessingGame/PlayController.cs new file mode 100644 index 00000000..a3b22568 --- /dev/null +++ b/guessingGame/PlayController.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; + +namespace guessingGame +{ + + class ProgramController + { + private bool quit = false; + PlayerStatistics data_file; + CheatController cheats; + + + public ProgramController(PlayerStatistics user_data) + { + this.data_file = user_data; + this.cheats = new CheatController(); + } + public void Start() + { + + //run software until quit + while (!quit) + { + string choice; + do + { + Console.Clear(); + + 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") + { + 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.Clear(); + Console.WriteLine("***********************************************"); + Console.WriteLine("* Cheats *"); + Console.WriteLine("***********************************************"); + Console.WriteLine("Enter Cheat Code"); + cheats.AddCheat(Console.ReadLine()); + } + else if (choice == "s") + { + data_file.GenerateStatistics(); + } + else if (choice == "x") + { + this.quit = true; + } + } + } + } +} diff --git a/guessingGame/PlayerStats.cs b/guessingGame/PlayerStats.cs new file mode 100644 index 00000000..b99e775a --- /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 new file mode 100644 index 00000000..b7f72259 --- /dev/null +++ b/guessingGame/Program.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; + +namespace guessingGame +{ + class Program + { + static void Main(string[] args) + { + //run profile creation + string first = ""; + string last = ""; + while (first == "" || last == "") + { + 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(); + } + + } + 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(); + } + } +} 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 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 + + + 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 + + +