30 Replies - 2396 Views - Last Post: 14 June 2013 - 03:44 AM
#17
Re: Hangman
Posted 12 June 2013 - 11:29 AM
#18
Re: Hangman
Posted 12 June 2013 - 11:30 AM
#19
Re: Hangman
Posted 12 June 2013 - 11:34 AM
Quote
I don't want to come across as rude when I say this, but we really don't care if you're a high school student. I was a high school student learning to program at one point too, as were many of our members. We know what it's like to be new to programming. We treat everyone the same way, though, and we have the same expectations of effort.
Quote
Then you need to step back for a moment and do things like read the documentation and ask questions. We're all here because we enjoy helping others. Members who make a good faith effort get a lot more out of our help than members who don't want to do any thinking. This applies to any type of learning really.
#20
Re: Hangman
Posted 12 June 2013 - 11:42 AM
Quote
ok ok. im sorry. but can you guys please just help me and then I will look on the internet and learn aboutit after. i did not mean to come across rude I just need help and I promise ill make an effort to work. just tell me in like words I would understand haha
This post has been edited by modi123_1: 12 June 2013 - 11:52 AM
Reason for edit:: fixed botched quote tags
#21
Re: Hangman
Posted 12 June 2013 - 11:44 AM
Quote
The responses you've gotten have been trying to help.
#22
Re: Hangman
Posted 12 June 2013 - 11:47 AM
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Final_Project { class FinalProject { static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Yellow; Console.SetWindowSize(80, 50); Console.WriteLine(" ___ ___"); Console.WriteLine("| | | | |"); Console.WriteLine("|__| | | |"); Console.WriteLine("| | | | |"); Console.WriteLine("| | | | |"); Console.WriteLine("__________________"); Console.WriteLine("\n\n"); Console.WriteLine("Instructions: Try and guess the word"); string[] wordBank = new string[10]; wordBank[0] = "Math"; wordBank[1] = "Computer Science"; wordBank[2] = "Programs"; wordBank[3] = "Equations"; wordBank[4] = "Mr Lynch"; wordBank[5] = "Calculator"; wordBank[6] = "Hard Work"; wordBank[7] = "Dedication"; wordBank[8] = "Knowledge"; wordBank[9] = "Mike Sperando"; Random randGen = new Random(); int generateRandomWord = randGen.Next(0, 9); int Length = wordBank[generateRandomWord].Length; string randomWord = wordBank[generateRandomWord]; char[] guess = new char[Length]; for (int p = 0; p < Length; p++) guess[p] = '*'; while (true) { Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("Please Enter a Guess"); char playerGuess = char.Parse(Console.ReadLine()); for (int m = 0; m < Length; m++) { if (wordBank[generateRandomWord].LastIndexOf(playerGuess) == playerGuess) { Console.WriteLine("You have gussed the correct letter guess again!"); } else { Console.WriteLine("WRONG guess again:)"); } } } Console.WriteLine(guess); if (playerGuess == generateRandomWord) { Console.WriteLine("You have solved the word correctly"); } else { Console.WriteLine("You are wrong thanks for playing!"); } } } }
This post has been edited by macosxnerd101: 12 June 2013 - 11:48 AM
Reason for edit:: Please start using code tags. You have been asked a few times now.
#23
Re: Hangman
Posted 12 June 2013 - 11:50 AM

As for your problem, you declare playerGuess in your while loop. Thus, it is local to your loop and cannot be accessed outside of your loop. You should declare the variable outside of your loop.
#24
Re: Hangman
Posted 12 June 2013 - 11:57 AM
Attached image(s)
#25
Re: Hangman
Posted 12 June 2013 - 12:00 PM
In the future, please post your code using code tags, rather than as an image. It makes it easier if we need to copy your code to run some tests.
#26
Re: Hangman
Posted 12 June 2013 - 12:27 PM
#27
Re: Hangman
Posted 13 June 2013 - 05:43 PM
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Final_Project { class FinalProject { static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Yellow; Console.SetWindowSize(80, 50); Console.WriteLine(" ___ ___"); Console.WriteLine("| | | | |"); Console.WriteLine("|__| | | |"); Console.WriteLine("| | | | |"); Console.WriteLine("| | | | |"); Console.WriteLine("__________________"); Console.WriteLine("\n\n"); Console.WriteLine("Instructions: Try and guess the word"); string[] wordBank = new string[10]; wordBank[0] = "math"; wordBank[1] = "computer science"; wordBank[2] = "programs"; wordBank[3] = "equations"; wordBank[4] = "mrlynch"; wordBank[5] = "calculator"; wordBank[6] = "hardwork"; wordBank[7] = "dedication"; wordBank[8] = "knowledge"; wordBank[9] = "mikesperando"; Random randGen = new Random(); int generateRandomWord = randGen.Next(0, 10); int Length = wordBank[generateRandomWord].Length; string randomWord = wordBank[generateRandomWord]; string playerGuess = "0"; double strike = 0;//number of strikes bool test, inGame = true, win = false; Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("Please Enter a Guess"); playerGuess = Console.ReadLine(); while (inGame == true) { test = wordBank[generateRandomWord].Contains(playerGuess); if (test == true) { Console.WriteLine("You have gussed the correct letter guess again!"); int numberofCorrectLetters = 0; numberofCorrectLetters++; if (numberofCorrectLetters == Length) { Console.WriteLine("you win!"); } } else { Console.WriteLine("WRONG guess again:)"); strike++; if (strike == 8) { inGame = false; win = false; } } /*if (Winning conditions) { inGame = false; win = true; }*/ playerGuess = Console.ReadLine(); } } } }
This post has been edited by macosxnerd101: 13 June 2013 - 05:45 PM
Reason for edit:: Code tags! Use them!
#28
Re: Hangman
Posted 13 June 2013 - 05:46 PM

#29
Re: Hangman
Posted 13 June 2013 - 05:48 PM
#30
Re: Hangman
Posted 13 June 2013 - 06:05 PM