Skip to content

Commit 5a17a9f

Browse files
committed
Code Clean-up
A little bit of clean up to make the code look better
1 parent 3967e85 commit 5a17a9f

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

Java Calculators/src/JavaCalculators/ConsoleCalculator.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public void getNumbers()
4747
//creates a method to add the numbers from getNumbers and print the sum in the console
4848
public float doSum()
4949
{
50-
//getNumbers();
5150
float sum;
5251
sum = number1 + number2;
5352
System.out.println("The sum of your two numbers is:");
@@ -59,7 +58,6 @@ public float doSum()
5958
//creates a method to multiply the numbers from getNumbers and print the product in the console
6059
public float doProduct()
6160
{
62-
//getNumbers();
6361
float product;
6462
product = number1 * number2;
6563
System.out.println("The product of your two numbers is:");
@@ -71,7 +69,6 @@ public float doProduct()
7169
//creates a method to subtract the numbers from getNumbers and print the difference in the console
7270
public float doDifference()
7371
{
74-
//getNumbers();
7572
float difference;
7673
difference = number1 - number2;
7774
System.out.println("The difference between your two numbers is:");
@@ -83,7 +80,6 @@ public float doDifference()
8380
//create a method to divide the numbers from getNumbers and print the quotient in the console
8481
public float doQuotient()
8582
{
86-
//getNumbers();
8783
float quotient;
8884
quotient = number1 / number2;
8985
System.out.println("The quotient of your two numbers is:");

Java Calculators/src/JavaCalculators/SwingCalculator.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package JavaCalculators;
22

33
import javax.swing.*;
4-
54
import java.awt.FlowLayout;
6-
//import java.util.Scanner;
5+
76
import java.awt.event.ActionEvent;
87
import java.awt.event.ActionListener;
98

@@ -12,7 +11,7 @@
1211
public class SwingCalculator
1312
{
1413
//create a JFrame Object
15-
static JFrame calcBox;
14+
public static JFrame calcBox;
1615

1716
//create 2 text boxes for text input
1817
static final JTextField intInput1 = new JTextField("Enter Your First Integer");
@@ -28,10 +27,11 @@ public static void main(String[] args)
2827

2928
public static void setup()
3029
{
31-
// creating a frame object
30+
// creating a frame object
3231
calcBox = new JFrame();
3332
calcBox.setSize(500,500);
34-
// creating the buttons
33+
34+
// creating the buttons
3535
JButton addition = new JButton("+");
3636
JButton subtraction = new JButton("-");
3737
JButton multiplication = new JButton("×");
@@ -51,6 +51,7 @@ public static void setup()
5151
subtraction.addActionListener(subtractButton);
5252
multiplication.addActionListener(multiplyButton);
5353
division.addActionListener(divideButton);
54+
5455

5556
//connects Action Listeners to corresponding text fields
5657
intInput1.addActionListener(text1);
@@ -63,17 +64,16 @@ public static void setup()
6364
calcBox.add(subtraction);
6465
calcBox.add(multiplication);
6566
calcBox.add(division);
66-
calcBox.add(intInput2);
67-
68-
67+
calcBox.add(intInput2);
6968

7069
//sets the size of the window/GUI
7170
calcBox.setSize(300, 300);
7271

7372
//allows the window to be visible
7473
calcBox.setVisible(true);
7574
}
76-
75+
76+
7777
//private inner class to listen for button presses
7878
/** Action that will happen when enter is pressed on the TextField*/
7979
private static class TextListener1 implements ActionListener
@@ -110,7 +110,7 @@ public void actionPerformed(ActionEvent buttonPress)
110110
{
111111
//what happens when button is pressed
112112
System.out.println("Addition Selected");
113-
//calculator.doSum();
113+
114114
JLabel label = new JLabel(" = " + calculator.doSum());
115115
calcBox.add(label);
116116

0 commit comments

Comments
 (0)