commit c66446a3363264634fbf27f4af04a681099cd931 Author: blzimme000 Date: Mon Mar 7 13:04:13 2022 -0600 Initial commit, works and randomized diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..21b4487 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Project exclude paths +/out/ \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/description.html b/.idea/description.html new file mode 100644 index 0000000..db5f129 --- /dev/null +++ b/.idea/description.html @@ -0,0 +1 @@ +Simple Java application that includes a class with main() method \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..b5b16a9 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..15b0d35 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/project-template.xml b/.idea/project-template.xml new file mode 100644 index 0000000..1f08b88 --- /dev/null +++ b/.idea/project-template.xml @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/Wordle.iml b/Wordle.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Wordle.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/company/Main.java b/src/com/company/Main.java new file mode 100644 index 0000000..a6def09 --- /dev/null +++ b/src/com/company/Main.java @@ -0,0 +1,65 @@ +package com.company; + +import java.io.*; +import java.util.ArrayList; +import java.util.Scanner; + +public class Main{ + public static void main (String str[]) throws IOException { + Scanner scan = new Scanner (System.in); + boolean gameNotOver = true; + ArrayList words = new ArrayList<>(); + try { + File wordList = new File("/home/benzimm07/IdeaProjects/Wordle Solver/src/com/company/smallWordleArray.csv"); + Scanner reader = new Scanner(wordList); + reader.useDelimiter(","); + while (reader.hasNext()){ + words.add(reader.next()); + } + } catch (FileNotFoundException e){ + System.out.println("The file was not found."); + e.printStackTrace(); + } + String answer = words.get((int) (Math.random()*2315)); + + while (gameNotOver) + { + boolean fiveLetter = true; + String guess = ""; + + while (fiveLetter){ + System.out.println("Guess the five letter word!"); + guess = scan.nextLine(); + if (guess.length() < 5) + System.out.println("Sorry, your word is not long enough!"); + else if (guess.length() > 5) + System.out.println("Sorry, your word is too long!"); + else + fiveLetter = false; + } + + String guessLower = guess.toLowerCase(); + System.out.println("Your guess is: " + guessLower); + + String[] characters = {"-", "-", "-", "-", "-"}; + + boolean match = true; + for (int i = 0; i < 5; i++) + { + if (answer.substring(i, i + 1).equals(guessLower.substring(i, i + 1))) + characters[i] = answer.substring(i, i + 1); + else if (answer.indexOf(guessLower.substring(i, i + 1)) != -1) + { + characters[i] = "(" + guessLower.substring(i, i + 1) + ")"; + match = false; + } + else + match = false; + } + + if (match == true) + gameNotOver = false; + System.out.println(characters[0] + characters[1] + characters[2] + characters[3] + characters[4]); + } + } +} \ No newline at end of file