diff --git a/src/main/java/ic/doc/RpnCalculatorGui.java b/src/main/java/ic/doc/RpnCalculatorGui.java index 3ab32b6..f13e8d2 100644 --- a/src/main/java/ic/doc/RpnCalculatorGui.java +++ b/src/main/java/ic/doc/RpnCalculatorGui.java @@ -4,6 +4,7 @@ import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.JButton; +import java.util.Map; import java.util.stream.IntStream; public class RpnCalculatorGui { @@ -16,6 +17,13 @@ public class RpnCalculatorGui { private static final int MIN_INPUT_NUMBER = 0; private static final int MAX_INPUT_NUMBER = 9; + private static final Map operators = Map.of( + "+", new Object(), + "-", new Object(), + "*", new Object(), + "/", new Object() + ); + public static RpnCalculatorGui withDimensions(int defaultWidth, int defaultHeight) { return new RpnCalculatorGui(defaultWidth, defaultHeight); } @@ -37,9 +45,18 @@ public class RpnCalculatorGui { panel.add(button); }); + // Add buttons for each operator + operators.forEach((key, value) -> { + JButton button = new JButton(key); + panel.add(button); + }); + JTextField resultField = new JTextField(RESULT_FIELD_WIDTH); panel.add(resultField); + JButton evaluateButton = new JButton("⏎"); + panel.add(evaluateButton); + frame.add(panel); frame.setVisible(true); }