I have two classes. I want to use english
and french
from the first class in the second class (class Question). Please help me to fix that code because it shows me an error.
Code Blocks :
package josephtraduire;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class FileParser implements IParser{
@Override
public void parseFile () throws IOException{
String french="";
String english="";
try( BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\User\\Desktop\\text.txt"))){
String line;
while ((line = br.readLine())!=null){
String[] pair = line.split(";");
french=(pair[0]);
english=(pair[1]);
}
}
}
}
and
package josephtraduire;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Date;
import java.util.Scanner;
public class Question extends FileParser {
String mot ;
String reponse ;
String name;
int nb;
int nbquest ;
String traduction;
Question (String name , int nb){
this.name=name;
this.nb=nb;
}
Question() throws IOException{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(isr);
{
System.out.println("Entrer votre nom ");
String nom = in.readLine();
name=nom;
}
do {
System.out.println("Rentrez le nombre de question : ( max 20 )");
Scanner nombrequest = new Scanner(System.in);
nbquest = nombrequest.nextInt();
nb=nbquest;
} while ( nbquest>20 ||nbquest<=0);
}
public void Play () throws IOException{
int i=0;
boolean bool=true;
int score=0;
String continuer;
Date maDate = new Date();
String a = maDate.toString() ;
while (i<nbquest && bool) {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(isr);
System.out.println("donner la traduction de "+french);
String reponseee = in.readLine();
traduction=reponseee;
if(bool=true ){
if(traduction.equals(english)){
score++;
System.out.println("Bravo! Bonne reponse");
}else{
System.out.println("Mauvaise reponse");
}
}