Building a Guessing Game | C# | Tutorial 19

  Рет қаралды 35,310

Giraffe Academy

Giraffe Academy

Күн бұрын

Пікірлер: 36
@janaewelsh8056
@janaewelsh8056 5 жыл бұрын
I've been watching an rewatching this series to get a better grasp on the basics of C# and just wanted to say that you're course has been a huge, huge help. I'd have to say it's the best course on C# for beginners that I've found on KZbin, Skillshare, Udemy or any other site. Thanks so much for putting these videos up! :)
@upcom1ng116
@upcom1ng116 3 жыл бұрын
I was so willing to pay for the basic course and look through entire list of Udemy and couldn't really find anything decent and funny enough I found his channel and it's FREE!
@pulcifyfn2919
@pulcifyfn2919 5 жыл бұрын
literally love you, helped me finish my game when i was stuck
@jasonatkinson2549
@jasonatkinson2549 5 жыл бұрын
Hey Mike! I'm loving the tutorials, thank you! I took your idea from this tutorial and played with it a little bit. I figure you're too busy to check it out but I just wanted to say thanks for the hard work... you're definitely making a difference.
@scottisitt
@scottisitt 4 жыл бұрын
Great video! Easy to follow. Thanks, Mike!
@joyride9353
@joyride9353 5 жыл бұрын
Hello Mike. I noticed a difference in the code for this video and what is on your website. while(!guess == secretWord && !outOfGuesses) Is what the website shows, but brings back an error. while(guess != secretWord && !outOfGuesses) works correctly and is what is shown in the video. Thank you for your tutorials. I am a beginner and these videos are extremely helpful.
@saadalsabagh4862
@saadalsabagh4862 3 жыл бұрын
Thank you so much Alex for pointing out this errors. I spent a lot of time to figure this out. Thank you Mike for this great tutorial!
@AnimeRPG1
@AnimeRPG1 3 жыл бұрын
Added an array ( 03:11 ) to account for lower and uppercase (1st letter only): static void Main(string[] args) { //LESSON 17 Console.WriteLine("LESSON 17"); Console.WriteLine(""); string[] secretWord = new string [2]; secretWord[0] = "Author"; secretWord[1] = "author"; string guessWord = ""; { } while (guessWord != secretWord[0] && guessWord != secretWord[1]) { Console.Write("Enter a guess for the secret word: "); guessWord = Console.ReadLine(); } Console.WriteLine("You Win!"); Console.ReadLine(); }
@ShadesGameSource
@ShadesGameSource 4 жыл бұрын
I managed to write the code below using a do while loop. I'm also reading a textbook on C# as I go through your videos, so I was able to incorporate a couple of things that haven't been mentioned in your videos (so far). =) string answer = "giraffe"; string guess = ""; int guessCounter = 5; do { Console.WriteLine("You have {0} guesses left.", guessCounter); Console.WriteLine("What is the most powerful animal in the universe?"); guess = Console.ReadLine(); Console.Write(" "); //noob line break implementation! guessCounter -= 1; } while (guess != answer && guessCounter > 0); if (guess == answer) { Console.WriteLine(" You won!~"); } else { Console.WriteLine(" You died!"); } Console.ReadLine();
@jaykhamankar8782
@jaykhamankar8782 3 жыл бұрын
Can u tell me the name of book??
@AnimeRPG1
@AnimeRPG1 3 жыл бұрын
12:36 Final product using an Array: static void Main(string[] args) { //LESSON 17 Console.WriteLine("LESSON 17"); Console.WriteLine(""); string[] secretWord = new string [2]; //Use an array to account for Author or author being typed. secretWord[0] = "Author"; secretWord[1] = "author"; string guessWord = ""; int guessCount = 0; int guessLimit = 3; bool outOfGuesses = false; { } while (guessWord != secretWord[0] && guessWord != secretWord[1] && !outOfGuesses) { if (guessCount < guessLimit) { Console.Write("Enter a guess for the secret word: "); guessWord = Console.ReadLine(); guessCount++; } else { outOfGuesses = true; } } if (outOfGuesses) { Console.WriteLine("You lose! You ran out of guesses."); } else { Console.WriteLine("You Win!"); } Console.ReadLine(); }
@azorailke6057
@azorailke6057 2 жыл бұрын
I went ahead and added a counter like this : int guessRemaining = guessLimit - guessCount; Console.Write("You have " + guessRemaining + " guess(es) remaining. Guess the secret word: "); guess = Console.ReadLine(); guessCount++; It worked out well! 😺 I even let the user input how many guesses they wanted and did not let them specify a negative number or over 10. The code for that part looks messy though.
@DelphicRachel
@DelphicRachel 2 жыл бұрын
I benefitted a lot from this course, but there's just one thing I was wondering; how do you create a guessing game where the program selects a random string variable from an array, and then sets that as the word that you have to guess? Thanks so much for this amazing tutorial :)
@flourishajiboye706
@flourishajiboye706 2 жыл бұрын
I have a little question In the code, your put the guessLimit at 3 meaning that you only want the user to answer 3 times. But under the while loop in the if statement you put the condition as (guessCount < guessLimit). guessCount keeps incrementing it self, and well I don't know how to say this but I'll try, i expected that the comdition would be (guessCount
@simplyjemelah8276
@simplyjemelah8276 3 жыл бұрын
hi do you have a word guessing game with ArrayList and StringBuilder example?
@thecatch4648
@thecatch4648 Жыл бұрын
To make the user input case-insensitive you can use '.ToLower()' Like this "guess = Console.ReadLine().ToLower();"
@MyMrdouchebag
@MyMrdouchebag 4 жыл бұрын
how do you make it where from the console player 1 enters a random word then player 2 guesses what it is?
@Matstarx25
@Matstarx25 4 жыл бұрын
Theres a problem with the game though. It's lacking an if-statement before the loop begins. Because if you get the word correct in 1st try, you are still prompted to guess again untill you hit 3/3 guesses.
@AnimeRPG1
@AnimeRPG1 3 жыл бұрын
Didn't do that for me: static void Main(string[] args) { //LESSON 17 Console.WriteLine("LESSON 17"); Console.WriteLine(""); string[] secretWord = new string [2]; //Use an array to acount for Author or author being typed. secretWord[0] = "Author"; secretWord[1] = "author"; string guessWord = ""; int guessCount = 0; int guessLimit = 3; bool outOfGuesses = false; { } while (guessWord != secretWord[0] && guessWord != secretWord[1] && !outOfGuesses) { if (guessCount < guessLimit) { Console.Write("Enter a guess for the secret word: "); guessWord = Console.ReadLine(); guessCount++; } else { outOfGuesses = true; } } if (outOfGuesses) { Console.WriteLine("You lose! You ran out of guesses."); } else { Console.WriteLine("You Win!"); } Console.ReadLine(); }
@gn26422458
@gn26422458 6 жыл бұрын
Just a beginner, isn't this code cleaner? // MY CODE using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Giraffe1 { class Program { static void Main(string[] args){ int count = 0; do { string secretWord = "apple"; Console.WriteLine("Yo what should be the secret word?"); string answer = Console.ReadLine(); count++; if (secretWord == answer) { Console.WriteLine("you're right!"); break; } } while (count < 3); Console.ReadLine(); } } } // MY CODE
@ROYALGAMERJAMES
@ROYALGAMERJAMES 5 жыл бұрын
yeah but this video is not about just making the game its about to leaning to coding by these commands etc........
@axyegaming6128
@axyegaming6128 4 жыл бұрын
Your code is cleaner even mine is the cleanest but he is trying to summarize previous lessons in one video
@johndoe-z6p
@johndoe-z6p 6 ай бұрын
bool is used
@tehminashehryar7802
@tehminashehryar7802 2 жыл бұрын
You can watch a very simple tutorial to develop puzzle game in C# for beginners at kzbin.info/aero/PLHGJljNavL-PZ6P7w1IhZAZhZPp-9f_2L
@AITakesYourJob
@AITakesYourJob 3 жыл бұрын
Tried to do "do" loop. I'm newbie, but it kinda worked. string secretword = "ass"; string guess = ""; int tries = 0; bool outoftries = false; do { if (tries < 3) { Console.WriteLine("Your guess: "); guess = Console.ReadLine(); tries++; } else { outoftries = true; } } while (guess != secretword && !outoftries); if (outoftries) { Console.WriteLine("You failed"); } if (guess == secretword) { Console.WriteLine("You won!"); }
@AITakesYourJob
@AITakesYourJob 3 жыл бұрын
here from next tutorial, also tried to create this game using "for" loop, but i have no idea if i did it right, it just works. string secretword = "ass"; string guess = ""; int tries; for (tries = 0; tries < 3; tries++) { Console.WriteLine("Your guess: "); guess = Console.ReadLine(); if (secretword == guess) { Console.WriteLine("You won"); break; } } if (tries == 3) { Console.WriteLine("You failed"); }
@W711-t7x
@W711-t7x 4 жыл бұрын
Can't you just use a simple break; instead of !outOfGuesses?
@upcom1ng116
@upcom1ng116 3 жыл бұрын
You can use break; with if and else condition but not in parameter. Nature of while condition is Boolean only.
@darthvader44
@darthvader44 4 жыл бұрын
Hello sir i created this game with do wile loop string word = "adi"; string ans=""; int guess= 0; int trial =1; bool outofguess = false ; Console.WriteLine("Press enter to start"); Console.ReadLine(); do { if (guess
@mambafamkdmambamkdfa1077
@mambafamkdmambamkdfa1077 10 ай бұрын
static void Main() { string secretWord = "apple"; string guess = " "; int guessCount = 0; int guessLimit = 3; bool outOfGuesses = false; do { if (guessCount < guessLimit) { Console.WriteLine("Etner your guess"); guess = Console.ReadLine(); guessCount++; } else { outOfGuesses = true; } } while (guess != secretWord && !outOfGuesses); if (outOfGuesses) { Console.WriteLine("You Lose!!"); } else Console.WriteLine("You WIN!!!!");
@MadBunnyRabbit
@MadBunnyRabbit 5 жыл бұрын
I would argue that having a game you can't exit from within is a worse design decision than the player having infinite guesses :]
@garylake9317
@garylake9317 Жыл бұрын
Sorry, but nobody would ever win that game.
For Loops | C# | Tutorial 20
10:16
Giraffe Academy
Рет қаралды 37 М.
Classes & Objects | C# | Tutorial 25
13:25
Giraffe Academy
Рет қаралды 178 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
Building a Better Calculator | C# | Tutorial 16
7:20
Giraffe Academy
Рет қаралды 18 М.
Inheritance | C# | Tutorial 31
10:29
Giraffe Academy
Рет қаралды 59 М.
Building a Mad Lib | C# | Tutorial 10
6:09
Giraffe Academy
Рет қаралды 19 М.
Variables | C# | Tutorial 4
13:03
Giraffe Academy
Рет қаралды 28 М.
Dart Programming in 4 hours | Full beginners tutorial
3:53:46
Giraffe Academy
Рет қаралды 364 М.
Methods | C# | Tutorial 12
11:00
Giraffe Academy
Рет қаралды 57 М.
Working With Strings | C# | Tutorial 6
12:38
Giraffe Academy
Рет қаралды 45 М.
The Dome Paradox: A Loophole in Newton's Laws
22:59
Up and Atom
Рет қаралды 773 М.
While Loops | C# | Tutorial 18
9:10
Giraffe Academy
Рет қаралды 46 М.
Constructors | C# | Tutorial 26
10:29
Giraffe Academy
Рет қаралды 88 М.