Wordle
This project is about the game wordle.
This is a somewhat advanced game, and was made quite some time ago.

Wordle is a game where you get 5 guesses to guess a word, if you get a letter in the right place, it will appear green, if you get it in the wrong place it will appear yellow, and if it isnt in the word it will turn gray. This program implements some advanced topics like GUI, however is not optimized. I don't see the need to optimize it, because it is plenty fast in its task. See results below

// Made by Kearnan Bishop on Friday, March 11th, 2022.
package stuf;
import java.io.*;
import java.util.Scanner;
public class Wordle {
static String word = "";
static CharSequence c;
static int repeater = 0;
static String inputWord = "";
public static void main(String[] args) throws IOException {
// Create random number 0 - 99
double randNumber = Math.random();
double d = randNumber * 100;
// Type cast double to int
int randomInt = (int) d;
BufferedReader reader = new BufferedReader(new FileReader("words"));
String line;
int lineindex = 0;
while ((line = reader.readLine()) != null) {
if (lineindex == randomInt) {
word = line;
}
lineindex++;
}
reader.close();
System.out.println("? means you havent discovered the letter, # means the letter is in the word.");
inputWords();
}
static void inputWords() {
Scanner scan = new Scanner(System.in);
int i = 0;
while (repeater == 0) {
System.out.println("Enter word: ");
inputWord = scan.nextLine();
if (inputWord.equals(word)) {
repeater = 1;
System.out.println("Correct, the word was " + word);
}
if (!inputWord.equals(word)) {
System.out.println("Wrong");
correctLetters();
}
if (i>3) {
repeater = 1;
System.out.println("the correct word was: " + word);
}
i++;
}
scan.close();
}
static void correctLetters() {
char[] letters = new char[5];
//char word1 = word;
char[] word1 = new char[5];
char[] newWord = new char[5];
for (int i = 0; i < 5; i++) {
letters[i] = inputWord.charAt(i);
}
for (int i = 0; i < 5; i++) {
word1[i] = word.charAt(i);
}
for (int i = 0; i < 5; i++) {
if (letters[i] == word1[i]) {
newWord[i] = word1[i];
}
if (letters[i] != word1[i]) {
newWord[i] = '?';
String s = Character.toString(letters[i]);
if (word.contains(s)) {
int place = word.indexOf(s);
newWord[place] = '#';
//System.out.println("letters in the wrong place: " + s);
}
}
}
String str = String.valueOf(newWord);
System.out.println(str);
//if ()
}
}