Building a Guessing Game | Java | Tutorial 20

  Рет қаралды 72,148

Giraffe Academy

Giraffe Academy

Күн бұрын

Пікірлер: 45
@nathansmart5226
@nathansmart5226 4 жыл бұрын
Been on and off coding for years. You've literally made me understand everything i couldn't pick up as well so easily :)
@geenade5294
@geenade5294 5 жыл бұрын
BROOOOO thank you ! saved me a boat load of time on my homework assignment! Keep it up!
@user-wf4zd3yp6k
@user-wf4zd3yp6k 3 жыл бұрын
How r u now?
@angieg7257
@angieg7257 3 жыл бұрын
Good example of a beginner game to program.
@Kickflips22
@Kickflips22 4 жыл бұрын
I paused the video before you set up the "lose" condition to see if I could figure it out, it works but I came up with something different and I'd like to know if there is any practical difference. While it functions the same, is the way I have it less efficient or does it matter? Here's where it differs: while(!guess.equals(secretWord)) { if(guessCount < guessLimit) { System.out.print("Enter a Guess: "); guess = keyboardInput.nextLine(); guessCount++; }else { outOfGuesses = true; System.out.println("You lose :P"); break; } } if(guess.equals(secretWord)) { System.out.println("You Win!"); } P.S. This is my first time coding and your teaching style has made it so easy to grasp thank you!!
@milandave9735
@milandave9735 6 жыл бұрын
oh man!!! you are genius........ so easy to understand.... thanks for explanation
@thelawgameplaywithcommenta2654
@thelawgameplaywithcommenta2654 3 жыл бұрын
I did it slightly differently. I put the if statement outside and after the loop, It's looking for if the guessCount
@hakirawr964
@hakirawr964 4 жыл бұрын
THANK YOU VERY MUCH!!! my grades have hope now, because of you!
@tonydalov
@tonydalov 6 жыл бұрын
Awesome explanation! Thanks
@yohohoyo5639
@yohohoyo5639 6 жыл бұрын
Really great content, THANK YOU!
@norbertkulacin272
@norbertkulacin272 6 жыл бұрын
wow amazing example, thanks so much!!!!
@zoilavaca7015
@zoilavaca7015 6 жыл бұрын
How can I add a list of words so that the "secret word"grabs a word from that list , and how can I validate that the user only uses strings when they are guessing ? Thanks from a noob 8)
@zoilavaca7015
@zoilavaca7015 6 жыл бұрын
The list I want to add is in a .txt file - my guess is to import it? because there are too many words to make an array... Hope to hear from you soon! :)
@pritamdavis
@pritamdavis 4 жыл бұрын
@@zoilavaca7015 The game here is a very simple game... And that's the point of this tutorial. It's for explaining the concept of loop using a simple game. But if you still want to do it anyway, what you should do is: 1. Read a .TXT file and convert it into an ArrayList of words 2. Set the secretWord to a random word from the ArrayList
@Future12294
@Future12294 5 жыл бұрын
I made some minor changes to the code so that the user guesses are not cap-sensitive and I decided to not used booleans as it confused me but the user still gets 3 guesses public static void main(String[] args) { Scanner input = new Scanner(System.in); String secretWord = "cowboys"; String guess = ""; int guessCount = 0; int guessLimit = 3; while (!guess.equals(secretWord)) { if (guessCount < guessLimit) { System.out.print("Enter a guess: "); guess = input.nextLine(); guess = guess.toLowerCase(); guessCount++; if (guessCount == guessLimit) { System.out.println("Out of guesses, You lose!"); } } } System.out.println("You Win!"); } }
@halaramimido
@halaramimido Жыл бұрын
for the guess limit, could you also put the while loop inside a for loop that is = to the guess limit?
@itspossible5920
@itspossible5920 4 жыл бұрын
Simple and easy to understand. Thanks
@dishabanerjee_chair6583
@dishabanerjee_chair6583 4 жыл бұрын
The only place I look for Computer Project solutions😁😁😁😁
@joshuatruelen3908
@joshuatruelen3908 4 жыл бұрын
How could you add total score? For example you make 5 questions and it takes correct answer and it print (you got 3 out of 5) etc....
@pritamdavis
@pritamdavis 4 жыл бұрын
Make a int variable score, and each time the user gets a correct answer increase it by one... Then at last print the score
@immer2470
@immer2470 4 жыл бұрын
What if i want to create 2 options: 1.with no limited attempts 2.with limited attempts ????
@PeiqiLi-RealLove
@PeiqiLi-RealLove 4 жыл бұрын
I just heard a dog barking Lol 7:48
@varshahanji458
@varshahanji458 4 жыл бұрын
urs ears are really so sharp!!
@kishorkumar-ue9lj
@kishorkumar-ue9lj 3 жыл бұрын
Thank you so much for these exercises 💪
@SaiKrishna-qp9jn
@SaiKrishna-qp9jn 7 жыл бұрын
You are a genius
@chifuyu7902
@chifuyu7902 3 жыл бұрын
I made a different code but with same basics and here it is: import java.util.Scanner; public class game{ public static void main (String[]args){ Scanner sc = new Scanner (System.in); String SecretWord ="giraffe"; String guess=""; int count=0; while(!guess.equals(SecretWord)) { System.out.println("Enter a guess"); guess= sc.nextLine(); count++; if(guess.equals(SecretWord)){ System.out.println("You Win!!"); }else if(count==3){ System.out.println("It is an animal"); }else if(count==6) { System.out.println("This animal lives in forest"); }else if(count==8){ System.out.println("Hey loser!"); break; } } } }
@Wolflover_26
@Wolflover_26 4 жыл бұрын
Thanks a lot!!! It was so useful
@salonipatel7834
@salonipatel7834 4 жыл бұрын
how to add point for giving right answer and deduct point for wrong guess
@rusty6460
@rusty6460 3 жыл бұрын
coming from c++ basics, this is hell
@khfir6209
@khfir6209 4 жыл бұрын
Why didn’t you import random ?
@shahrzadalbertsson9779
@shahrzadalbertsson9779 5 жыл бұрын
Oh Thanks! :)
@mooncakeplaylist
@mooncakeplaylist 4 жыл бұрын
why won't it work for me?
@Yukino965
@Yukino965 4 жыл бұрын
Thank you so much
@jedcatapang4917
@jedcatapang4917 3 жыл бұрын
what application is this?
@NoNo-ud8zw
@NoNo-ud8zw 4 жыл бұрын
Thanks IDOL
@iftakerahmed4263
@iftakerahmed4263 5 жыл бұрын
How can i add hints?
@CoderLoAnt
@CoderLoAnt 2 жыл бұрын
Another guessing game here: kzbin.info/www/bejne/qZa8d6h8pNhqgLc
@freesauce7842
@freesauce7842 4 жыл бұрын
it says some are error
@flashmash7051
@flashmash7051 4 жыл бұрын
You just did my homework for me 🤧🤧❤️❤️❤️❤️thank you
@LT5Production
@LT5Production 4 жыл бұрын
great - this is my code :) import java.util.*; public class Guessing_Game { public static Scanner input=new Scanner(System.in); public static void main(String[] args) { String question="SHE HAS BROWN HAIR & CURLLY HAIR, BROWN EYES,WHO IS SHE ? "; System.out.println(question); String guess="carmit"; String SecretWord=input.nextLine(); int i=3; while(!guess.equals(SecretWord) && i>=0) { System.out.println("You have another "+i+" guesses to guess"); System.out.println("try again"); SecretWord=input.next(); i--; } if(i>=0) { System.out.println("you are right");} else System.out.println("you lose"); } }
@tanasisyanev3760
@tanasisyanev3760 6 жыл бұрын
he wrote 30line code and he said this was a lot of code in the program ? lol
@Future12294
@Future12294 5 жыл бұрын
Well this is for beginners and this vid has the most code written in it so far of all the tutorials so yeah
For Loops | Java | Tutorial 21
10:07
Giraffe Academy
Рет қаралды 24 М.
Try / Catch & Exceptions | Java | Tutorial 25
15:56
Giraffe Academy
Рет қаралды 55 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
Number Guessing Game in Java Tutorial (Beginning to End)
14:34
Coding with John
Рет қаралды 66 М.
Building a Multiple Choice Quiz | Java | Tutorial 29
14:48
Giraffe Academy
Рет қаралды 236 М.
Interface Inheritance (implements) | Java | Tutorial 35
12:32
Giraffe Academy
Рет қаралды 54 М.
Nested Loops & 2D Arrays | Java | Tutorial 23
13:15
Giraffe Academy
Рет қаралды 114 М.
Getters & Setters | Java | Tutorial 31
17:49
Giraffe Academy
Рет қаралды 112 М.
Java toString method 🎉
6:39
Bro Code
Рет қаралды 108 М.
Boolean Java Tutorial #15
13:53
Alex Lee
Рет қаралды 243 М.
The Rust Survival Guide
12:34
Let's Get Rusty
Рет қаралды 179 М.
Building a better Calculator |  Java | Tutorial 17
7:02
Giraffe Academy
Рет қаралды 22 М.
Java for Beginners: Hangman Game in Terminal
20:59
Almas Baim (AlmasB)
Рет қаралды 19 М.