I asked this question in several ways, but the code is usually user-specific and I got a little lost. If I miss a simple clear and simple explanation, I'm sorry! I just need to understand this concept, and I lost the repetition that I saw. Therefore, I have simplified my own problem as much as possible in order to understand the essence of the problem.
The goal is to have a main class that I request for variables, and then these variables entered by the user are evaluated by the method in a separate class with a message return depending on the variables.
import java.io.*;
public class MainClass {
public static void main(String[] args) {
InputStreamReader input = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(input);
String A;
String B;
try {
System.out.println("Is A present?");
A = reader.readLine();
System.out.println("Is B present?");
B = reader.readLine();
Assess test = new Assess();
} catch (IOException e){
System.out.println("Error reading from user");
}
}
}
And the method I'm trying to use:
public class Assess extends MainClass {
public static void main(String[] args) {
String A = MainClass.A;
String B = MainClass.B;
if ((A.compareToIgnoreCase("yes")==0) &&
((B.compareToIgnoreCase("yes")==0) | (B.compareToIgnoreCase("maybe")==0)))
{
System.out.println("Success!");
}
else {
System.out.println ("Failure");
}
}
}
, , , , , , , . , , , . , ; , , , , , , .
, , , ( , ... ? - , ).