1. Design data structure: variable
1) char [] chs; // random character array
2) char [] input; // character array input by the user
3)
/ * int positionRight; // position data is correct
int letterRight; // The number of characters is correct
* /
int [] result; // Comparison result
4) int score; // Score
2. Design program structure: Method
1) Main method:
public static void main (String [] args) {
}
2) Generate random character array:
public static char [] generate () {// Data can be written without adding
char [] chs = new char [5];
// ...
return chs;
}
3) Comparison: random character array and user input character array
public static int [] check (char [] chs, char [] input) {
int [] result = new int [2];
// ...
return result;
}
3. Calculation algorithm: Method body
3.1) Main method:
public static void main (String [] args) {
}
3.2) Generate random character array
3.3) Comparison: random character array and user input character array