Daniel 2 Posted October 27, 2013 Sooo just learning c# and made this for fun heres the source code and download for the console app using System;using System.Collections.Generic;using System.Text; namespace RockPaperScissors{ class Program { static void Main(string[] args) { Console.Title = "Rock Paper Scissors"; string userChoice = "**&&**"; int computerChoice, loseCount = 0, tieCount = 0; bool QUIT = false; double winPercent = 100.0, gameCount = 0.0, winCount = 0.0; Random computer = new Random(); Console.Clear(); Console.WriteLine("ROCK PAPER SCISSORS"); do { Console.Write("Enter choice, or enter QUIT to quit: "); userChoice = Convert.ToString(Console.ReadLine()); ++gameCount; if (userChoice.ToUpper() == "QUIT") { break; } computerChoice = computer.Next(1, 4); // 1 is Rock, 2 is Paper, 3 is Scissors switch (userChoice.ToUpper()) { case "ROCK": if (computerChoice == 1) { Console.WriteLine("You chose {0} and the computer chose Rock. It was a tie!", userChoice); ++tieCount; } else if (computerChoice == 2) { Console.WriteLine("You chose {0} and the computer chose Paper. You win!", userChoice); ++winCount; } else if (computerChoice == 3) { Console.WriteLine("You chose {0} and the computer chose Scissors. You lose!", userChoice); ++loseCount; } break; case "PAPER": if (computerChoice == 1) { Console.WriteLine("You chose {0} and the computer chose Rock. You win!", userChoice); ++winCount; } else if (computerChoice == 2) { Console.WriteLine("You chose {0} and the computer chose Paper. It was a tie!", userChoice); ++tieCount; } else { Console.WriteLine("You chose {0} and the computer chose Scissors. You lose!", userChoice); ++loseCount; } break; case "SCISSORS": if (computerChoice == 1) { Console.WriteLine("You chose {0} and the computer chose Rock. You lose!", userChoice); ++loseCount; } else if (computerChoice == 2) { Console.WriteLine("You chose {0} and the computer chose Paper. You win!", userChoice); ++winCount; } else { Console.WriteLine("You chose {0} and the computer chose Scissors. It was a tie!", userChoice); ++tieCount; } break; default: { break; } } } while (QUIT == false); if (gameCount > 1) { Console.Clear(); Console.WriteLine("Giving up?"); Console.WriteLine("{0} game(s) played. You won {1} game(s). You lost {2} game(s). {3} game(s) were a tie.", gameCount, winCount, loseCount, tieCount); winPercent = (winCount / gameCount) * 100; Console.WriteLine("You won {0:f2}% of the games you played.", winPercent); Console.WriteLine("Thanks for playing!"); Console.ReadKey(); } } }} Just copy and past it into whatever builder you use and it should format it correctly so dw about the lines being split in two... heres the download for the already bult console app https://mega.co.nz/#!epRVRYSL!ePibxiFjrjiIQxS97F3ZbhG0xicxKXvmzwQLvODXvDo What do you guys think? Quote Share this post Link to post Share on other sites
gangrel_1313 23 Posted October 27, 2013 Sooo just learning c# and made this for fun heres the source code and download for the console app using System;using System.Collections.Generic;using System.Text; namespace RockPaperScissors{ class Program { static void Main(string[] args) { Console.Title = "Rock Paper Scissors"; string userChoice = "**&&**"; int computerChoice, loseCount = 0, tieCount = 0; bool QUIT = false; double winPercent = 100.0, gameCount = 0.0, winCount = 0.0; Random computer = new Random(); Console.Clear(); Console.WriteLine("ROCK PAPER SCISSORS"); do { Console.Write("Enter choice, or enter QUIT to quit: "); userChoice = Convert.ToString(Console.ReadLine()); ++gameCount; if (userChoice.ToUpper() == "QUIT") { break; } computerChoice = computer.Next(1, 4); // 1 is Rock, 2 is Paper, 3 is Scissors switch (userChoice.ToUpper()) { case "ROCK": if (computerChoice == 1) { Console.WriteLine("You chose {0} and the computer chose Rock. It was a tie!", userChoice); ++tieCount; } else if (computerChoice == 2) { Console.WriteLine("You chose {0} and the computer chose Paper. You win!", userChoice); ++winCount; } else if (computerChoice == 3) { Console.WriteLine("You chose {0} and the computer chose Scissors. You lose!", userChoice); ++loseCount; } break; case "PAPER": if (computerChoice == 1) { Console.WriteLine("You chose {0} and the computer chose Rock. You win!", userChoice); ++winCount; } else if (computerChoice == 2) { Console.WriteLine("You chose {0} and the computer chose Paper. It was a tie!", userChoice); ++tieCount; } else { Console.WriteLine("You chose {0} and the computer chose Scissors. You lose!", userChoice); ++loseCount; } break; case "SCISSORS": if (computerChoice == 1) { Console.WriteLine("You chose {0} and the computer chose Rock. You lose!", userChoice); ++loseCount; } else if (computerChoice == 2) { Console.WriteLine("You chose {0} and the computer chose Paper. You win!", userChoice); ++winCount; } else { Console.WriteLine("You chose {0} and the computer chose Scissors. It was a tie!", userChoice); ++tieCount; } break; default: { break; } } } while (QUIT == false); if (gameCount > 1) { Console.Clear(); Console.WriteLine("Giving up?"); Console.WriteLine("{0} game(s) played. You won {1} game(s). You lost {2} game(s). {3} game(s) were a tie.", gameCount, winCount, loseCount, tieCount); winPercent = (winCount / gameCount) * 100; Console.WriteLine("You won {0:f2}% of the games you played.", winPercent); Console.WriteLine("Thanks for playing!"); Console.ReadKey(); } } }} Just copy and past it into whatever builder you use and it should format it correctly so dw about the lines being split in two... heres the download for the already bult console app https://mega.co.nz/#!epRVRYSL!ePibxiFjrjiIQxS97F3ZbhG0xicxKXvmzwQLvODXvDo What do you guys think? Can you upload to another host? That site is being stubborn.. , I'd like to test it out. Quote Share this post Link to post Share on other sites
Swizzy 2083 Posted October 27, 2013 (edited) Convert.ToString(Console.ReadLine());^ the above code is useless... when you do Console.ReadLine() the return value is already a string, converting a string to a string is pointless don't you think? ** edit: ** http://www.sendspace.com/file/adf77n <--- for anyone that wants to try it out, here's a compilation to exe (which you can run directly with no install) and some updated/cleaned up source code [including the entire project] Edited October 27, 2013 by Swizzy Quote Share this post Link to post Share on other sites
gangrel_1313 23 Posted October 28, 2013 (edited) Thanks Swizzy. @Daniel, I was playing this and was thinking this could be fun if it kept track of wins, ties and losses, and had a set goal of wins before the game ends (similar to Super Mario War), also some graphics would be cool. EDIT: A Tic Tac Toe game would be great too, simple homebrew games that people could play with their friends, even add highscores and what-not Edited October 28, 2013 by gangrel_1313 Quote Share this post Link to post Share on other sites
Daniel 2 Posted October 28, 2013 @swizzy thanks for the feedback really appreciate it Quote Share this post Link to post Share on other sites
Daniel 2 Posted October 28, 2013 Thanks Swizzy. @Daniel, I was playing this and was thinking this could be fun if it kept track of wins, ties and losses, and had a set goal of wins before the game ends (similar to Super Mario War), also some graphics would be cool. EDIT: A Tic Tac Toe game would be great too, simple homebrew games that people could play with their friends, even add highscores and what-notI could potentially make it open animations of scissors paper rock with not to much trouble, and I think I have a few people who could help with animating or atleast making a template or something. Blender isn't to hard when younger used to it also tic tac toe sound cool, a bit harder though.. Also to have highscores online would be really annoying but maybe just stored on the computer could be coolSent from my iPhone using Tapatalk Quote Share this post Link to post Share on other sites
gangrel_1313 23 Posted October 28, 2013 I could potentially make it open animations of scissors paper rock with not to much trouble, and I think I have a few people who could help with animating or atleast making a template or something. Blender isn't to hard when younger used to it also tic tac toe sound cool, a bit harder though.. Also to have highscores online would be really annoying but maybe just stored on the computer could be coolSent from my iPhone using Tapatalk I wasn't necessarily talking about online play at all, I was talking about on one console, however having Link incorporated into the game for online play would be neat, but disable hi-scores for online Quote Share this post Link to post Share on other sites
Swizzy 2083 Posted October 28, 2013 I wasn't necessarily talking about online play at all, I was talking about on one console, however having Link incorporated into the game for online play would be neat, but disable hi-scores for onlineYou do realize this is a PC based application/game right? the "console" is well CMD... Quote Share this post Link to post Share on other sites
gangrel_1313 23 Posted October 28, 2013 You do realize this is a PC based application/game right? the "console" is well CMD... I guess I misinterpreted his use of the word "console", I do realize that now, I was a little confused as to why it was an EXE now I know.. Quote Share this post Link to post Share on other sites