I remember using your vids to make stuff in python I never cared about what you were saying and I never learned anything but now I’m coding in java all the time without needing tutorials Tysm dude
the Legend is here 🎉🎉🎉🎉🎉🎉 can you make us a flutter serious .......because any body can be software engineer with out going to college just by watching your amazing videos❤❤❤🎉🎉
5:55 what do i need to press in order for the next line to start after the arrow? mine just starts at the beginning which is why the hangman then appears wrong when i run the code.
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// JAVA HANGMAN GAME
String filePath = "words.txt"; // Put your file path here
ArrayList words = new ArrayList();
try(BufferedReader reader = new BufferedReader(new FileReader(filePath))){
String line;
while((line = reader.readLine()) != null){
words.add(line.trim());
}
}
catch(FileNotFoundException e){
System.out.println("Could not find file");
}
catch(IOException e){
System.out.println("Something went wrong");
}
Random random = new Random();
String word = words.get(random.nextInt(words.size()));
Scanner scanner = new Scanner(System.in);
ArrayList wordState = new ArrayList();
int wrongGuesses = 0;
for(int i = 0; i < word.length(); i++){
wordState.add('_');
}
System.out.println("************************");
System.out.println("Welcome to Java Hangman!");
System.out.println("************************");
while(wrongGuesses < 6){
System.out.print(getHangmanArt(wrongGuesses));
System.out.print("Word: ");
for(char c : wordState){
System.out.print(c + " ");
}
System.out.println();
System.out.print("Guess a letter: ");
char guess = scanner.next().toLowerCase().charAt(0);
if(word.indexOf(guess) >= 0){
System.out.println("Correct guess!");
for(int i = 0; i < word.length(); i++){
if(word.charAt(i) == guess){
wordState.set(i, guess);
}
}
if(!wordState.contains('_')){
System.out.print(getHangmanArt(wrongGuesses));
System.out.println("YOU WIN!");
System.out.println("The word was: " + word);
break;
}
}
else{
wrongGuesses++;
System.out.println("Wrong guess!");
}
}
if(wrongGuesses >= 6){
System.out.print(getHangmanArt(wrongGuesses));
System.out.println("GAME OVER!");
System.out.println("The word was: " + word);
}
scanner.close();
}
static String getHangmanArt(int wrongGuesses){
return switch(wrongGuesses){
case 0 -> """
""";
case 1 -> """
o
""";
case 2 -> """
o
|
""";
case 3 -> """
o
/|
""";
case 4 -> """
o
/|\\
""";
case 5 -> """
o
/|\\
/
""";
case 6 -> """
o
/|\\
/ \\
""";
default -> "";
};
}
}
not working :
A while loop is missing in this code
I remember using your vids to make stuff in python I never cared about what you were saying and I never learned anything but now I’m coding in java all the time without needing tutorials Tysm dude
Ok
Best RUclipsr out there
the Legend is here 🎉🎉🎉🎉🎉🎉 can you make us a flutter serious .......because any body can be software engineer with out going to college just by watching your amazing videos❤❤❤🎉🎉
Software engineer without going to collage may be a little far but he can definitely help anyone get any coding job whether you go to collage or not
the constant videos he is uploading for java its looking like java playlist is coming soon!!!!!!!!
Bro, when will you update the JS course?
5:55 what do i need to press in order for the next line to start after the arrow? mine just starts at the beginning which is why the hangman then appears wrong when i run the code.
please make a video explaining Dijkstra's algorithm.
Thank you bro ❤
BroCode's perfect date is a pizza dinner and the Spongebob Movie hand to god
Hello teacher can you make us a lesson about Linux terminal
👌👍
well damn this is goated
What about flutter and react native
what software are you using to code? i’m using eclipse looking for the name of this one
intellij