// Milestone #3 Program code // Insert this into your Wordle.java, replacing the current // assignColors method public void assignColors(String s) { int row = gw.getCurrentRow(); boolean [] used = {false, false, false, false, false}; for(int col = 0; col < s.length(); col++) { gw.setSquareColor(row, col, WordleGWindow.MISSING_COLOR); } // Assign GREEN Squares for(int col = 0; col < s.length(); col++) { String letter = s.substring(col, col+1); // Does the letter match in the corresponding positions if(letter.equals(theWord.substring(col, col+1))){ gw.setSquareColor(row, col, WordleGWindow.CORRECT_COLOR); // Make that position off limits for future coloring used[col] = true; } } // Assign YELLOW squares for(int col = 0; col < s.length(); col++) { // Get letter from player's guess String letter = s.substring(col, col+1); // If not already colored GREEN, search the mystery word for that letter if(!gw.getSquareColor(row, col).equals(WordleGWindow.CORRECT_COLOR)) { for(int c = 0; c < theWord.length(); c++) { if(letter.equals(theWord.substring(c, c+1)) && used[c] == false) { gw.setSquareColor(row, col, WordleGWindow.PRESENT_COLOR); // Make that position in mystery word off limits for future coloring used[c] = true; break; } } } } }