所以。我想知道我怎么能做到这一点
- 系统打印包含 az + å、ä 和 ö 字母的单词。(目前 å、ä 和 ö 以一种奇怪的方式打印。我很确定你知道它是什么样子的 :D)
- 用户输入一个单词并将其与第一个单词进行比较。目前,如果 ^ 上面的单词包含 ä、ö 或 å 并且我输入了那个单词.. 它不会看到这两个之间的匹配..
所以问题是:我怎样才能做到这样,如果你输入 å、ä 或 ö 来输入,它会注意到它与刚刚打印的单词中的 å、ä、ö 完全相同?我在用着
answer.equals(rightanswer)
这是我的全部代码 :D 主要是任务和答案 :)
import java.io.*;
import java.awt.*;
public class sanaopisto {
public static int quanity;
public static String rightanswer;
public static String question;
public static int right;
public static int wrong;
public static double ratio;
public static void main(String[] args) {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try{
System.out.print("Moneenko sanaan tahdot vastata? ");
quanity = Integer.parseInt(in.readLine());
for(int x=0; x<quanity; x++){
System.out.println(x+1 +". kysymys");
getquestion(quanity);
}
System.out.println("Oikeita vastauksia " +right +" ja v\u201e\u201eri\u201e " +wrong +".");
}catch(Exception e) {
System.out.println("Tapahtui virhe.");}}
public static void getquestion(int quanity) {
try{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int[] done = new int[100];//create array but everything is null
for(int i = 0; i<done.length; i++)
{
done[i] = 0;//need default values else wise it'll just be NULL!!!
}
//must be done before the do-while loop starts
boolean allDone = false;
String answer;
int ran;
if (!areAllQuestionsComplete(done)){ //Changed (!areAllQuestionsComplete(done)) thingy like this..
do{ //And made this work properly etc.
ran = (int)(Math.random() * 53 + 1);
} while (done[ran] == 1);
if(done[ran] != 1)
{
//ask random question
//if answer is correct, set done[ran] = 1
//else just let do-while loop run
if (ran == 1) { //1
question = "ruotsalainen";
rightanswer = "svensk, -t, -a";}
if (ran == 2) { //2
question = "suomalainen";
rightanswer = "finländsk, -t, -a";}
//.
//. Took some code away from here.. Because too many questions.. In real version I have all the 1-84 questions :D
//.
if (ran == 83) { //15
question = "globalisoitunut";
rightanswer = "globaliserad, -at, -ade";}
if (ran == 84) { //15
question = "maailma";
rightanswer = "en värld, -en, -ar, -arna";}
}
System.out.println(question);
System.out.print("Vastaus?: ");
answer = in.readLine();
if (answer.equals(rightanswer)){
right++;
System.out.println("Oikein!\n");
done[ran] = 1;}
else{wrong++;
System.out.println("Oikea vastaus on: " +rightanswer +"\n");}
//check if all questions are answered}
else {
System.out.println("You have answered every question!"); //I know that this is useless.. :D
}
}catch(Exception e) {
System.out.println("You made a mistake.");}
}
private static boolean areAllQuestionsComplete(int[] list)
{
for(int i = 0; i<list.length; i++)
{
if(list[i] != 1)
{
return false;//found one false, then all false
}
}
return true;//if it makes it here, then you know its all done
}
}
编辑添加了整个代码“带走了一些问题”我正在使用CMD