package Computer;import java.awt.event.*;
import java.awt.*;
import javax.swing.*;public class Teacher implements ActionListener {
JTextField texta1, texta2, texta3;
JLabel anotation;
JLabel aprompt;
JButton abutton1,abutton2;
ComputerFrame computer;
public void setJText1(JTextField t) {
texta1 = t;
} public void setJText2(JTextField t) {
texta2 = t;
} public void setJText3(JTextField t) {
texta3 = t;
} public void setJLabel(JLabel l) {
anotation = l;
} public void setJLabelP(JLabel p) {
aprompt = p;
}
public void setJButton1(JButton b){
abutton1=b;
}
public void setJButton2(JButton b){
abutton2=b;
} public void actionPerformed(ActionEvent e) {
double num1 = Double.parseDouble(texta1.getText());
double num2 = Double.parseDouble(texta2.getText());
double num3 = Double.parseDouble(texta3.getText());
if (e.getSource() == abutton2) {
if (anotation.toString().equals("+")) {
if (num1 + num2 == num3) {
aprompt.setText("Right!");
} else
aprompt.setText("Wrong");
} else if (anotation.toString().equals("-")) {
if (num1 - num2 == num3) {
aprompt.setText("Right!");
} else
aprompt.setText("Wrong");
}
}
    if(e.getSource()==abutton1){
texta1.setText(String.valueOf((int)(Math.random()*10)));
texta2.setText(String.valueOf((int)(Math.random()*10)));

double n=(Math.random())*10;
if(n>=0&&n<=4){
anotation.setText("+");
}
if(n>=5&&n<=9){
anotation.setText("-");
}

}
}}*****************************************************************************
package Computer;
import java.awt.*;
import javax.swing.*;
public class ComputerFrame extends JFrame{
JButton button1,button2;
JLabel notation,prompt;
JTextField text1,text2,text3;
Teacher teacherListener;
ComputerFrame(){
setVisible(true);
setSize(500,300);
setLayout(new FlowLayout());
teacherListener =new Teacher();
button1=new JButton("Get");
button2=new JButton("Comfirm");
text1=new JTextField(5);
text2=new JTextField(5);
text3=new JTextField(5);
notation=new JLabel();
prompt=new JLabel();
text1.setEditable(false);
text2.setEditable(false);
teacherListener.setJButton1(button1);
teacherListener.setJButton2(button2);
teacherListener.setJText1(text1);
teacherListener.setJText2(text2);
teacherListener.setJText3(text3);
teacherListener.setJLabelP(prompt);
teacherListener.setJLabel(notation);
add(button1);
add(text1);
add(notation);
add(text2);
add(new JLabel("="));
add(button2);
add(prompt);
button1.addActionListener(teacherListener);
button2.addActionListener(teacherListener);}}***********************************************************************
package Computer;public class Main { public static void main(String[] args) {
// TODO Auto-generated method stub
new ComputerFrame();
}}