Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit f0a244d7 authored by First nakub's avatar First nakub
Browse files

"Calculator"

parent a162ecc5
No related branches found
No related tags found
No related merge requests found
......@@ -53,7 +53,6 @@ public class Test implements WindowListener, ActionListener {
bDot = new Button(".");
bEqual = new Button("=");
// Add listeners to buttons
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
......@@ -71,7 +70,6 @@ public class Test implements WindowListener, ActionListener {
bDiv.addActionListener(this);
bEqual.addActionListener(this);
// Add buttons to panel
p2.add(b7);
p2.add(b8);
p2.add(b9);
......@@ -125,7 +123,7 @@ public class Test implements WindowListener, ActionListener {
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
// If a number or decimal is pressed
if (cmd.equals("0") || cmd.equals("1") || cmd.equals("2") || cmd.equals("3") ||
cmd.equals("4") || cmd.equals("5") || cmd.equals("6") || cmd.equals("7") ||
cmd.equals("8") || cmd.equals("9") || cmd.equals(".")) {
......@@ -138,7 +136,7 @@ public class Test implements WindowListener, ActionListener {
operator = cmd;
numStr = "";
}
// If equal sign is pressed
else if (cmd.equals("=")) {
operand2 = numStr;
num1 = Double.parseDouble(operand1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment