// 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 = new boolean[s.length()]; for(int col = 0; col < s.length(); col++) { gw.setSquareColor(row, col, WordleGWindow.MISSING_COLOR); used[col] = false; } // Assign GREEN squares for(int col = 0; col < s.length(); col++) { String letter = s.substring(col, col+1); //Does the letter match the corresponding position? if(letter.equals(theWord.substring(col, col+1))) { gw.setSquareColor(row, col, WordleGWindow.CORRECT_COLOR); used[col] = true; } } // Assign YELLOW squares for(int col = 0; col < s.length(); col++) { String letter = s.substring(col, col+1); 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); used[c] = true; break; } } } } }