-
Notifications
You must be signed in to change notification settings - Fork 0
/
basicValues.java
55 lines (44 loc) · 1.13 KB
/
basicValues.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import javax.swing.JButton;
import javax.swing.JTextField;
abstract class basicValues { //Super class
static protected JTextField textField;
static double firstNum;
static double secondNum;
static double result;
static String operator;
static JButton op;
//constants
final double pi;
final double exponent;
protected basicValues() {
firstNum=0;
secondNum=0;
result=0;
operator=null;
op=null;
this.pi=Math.PI;
this.exponent=Math.E;
}
static protected double getNum() {
double num=0;
String text="";
if (textField.getText().equals(""))
num=0;
else {
try {
num=Double.parseDouble(textField.getText());
}
catch(NumberFormatException e){
text="Enter only numeric value";
}
}
textField.setText(text);
return num;
}
static protected void setNumber(JButton name) {
String number=textField.getText()+name.getText();
textField.setText(number);
}
abstract void doOperation(String operator);
abstract void doOperation(JButton operator);
}