Procházet zdrojové kódy

fixed how input works

NedRedmond před 6 roky
rodič
revize
cf1d611019
4 změnil soubory, kde provedl 51 přidání a 47 odebrání
  1. 2
    2
      Console.java
  2. 5
    3
      opSwitch.java
  3. 15
    15
      package.bluej
  4. 29
    27
      simpleOp.java

+ 2
- 2
Console.java Zobrazit soubor

@@ -50,7 +50,7 @@ public class Console {
50 50
             quit(numberString);
51 51
         try{
52 52
             int number1 = Integer.parseInt(numberString);
53
-            System.out.println(number1);
53
+            //System.out.println(number1);
54 54
             return number1;
55 55
         }catch(Exception e){
56 56
             return getInput(numberString);
@@ -75,7 +75,7 @@ public class Console {
75 75
             quit(numberString);
76 76
         try{
77 77
             int number2 = Integer.parseInt(numberString);
78
-            System.out.println(number2);
78
+            //System.out.println(number2);
79 79
             return number2;
80 80
         }catch(Exception e){
81 81
             return getNumber(numberString);

+ 5
- 3
opSwitch.java Zobrazit soubor

@@ -8,6 +8,8 @@
8 8
 public class opSwitch
9 9
 {
10 10
     public static void choose(String opInput){
11
+        simpleOp op = new simpleOp();
12
+        
11 13
         String x;
12 14
         String y;
13 15
         // switchboard for operations
@@ -26,9 +28,9 @@ public class opSwitch
26 28
                 +"clear"+"\n");
27 29
                 break;
28 30
             case "+": 
29
-                x = Console.getStringInput("Please enter first number.");
30
-                y = Console.getStringInput("Please enter second number.");
31
-                simpleOp.add(Console.getNumber(x), Console.getNumber(y));
31
+                //x = Console.getStringInput("Please enter first number.");
32
+                y = Console.getStringInput("Please enter number.");
33
+                simpleOp.add(op.currentNumber, Console.getNumber(y));
32 34
                 break;
33 35
             case "-": 
34 36
                 x = Console.getStringInput("Please enter first number.");

+ 15
- 15
package.bluej Zobrazit soubor

@@ -16,16 +16,16 @@ dependency5.to=simpleOp
16 16
 dependency5.type=UsesDependency
17 17
 editor.fx.0.height=711
18 18
 editor.fx.0.width=811
19
-editor.fx.0.x=469
20
-editor.fx.0.y=23
19
+editor.fx.0.x=585
20
+editor.fx.0.y=114
21 21
 objectbench.height=199
22 22
 objectbench.width=444
23 23
 package.divider.horizontal=0.6
24 24
 package.divider.vertical=0.6845329249617151
25 25
 package.editor.height=440
26 26
 package.editor.width=342
27
-package.editor.x=0
28
-package.editor.y=23
27
+package.editor.x=35
28
+package.editor.y=81
29 29
 package.frame.height=711
30 30
 package.frame.width=468
31 31
 package.numDependencies=5
@@ -45,21 +45,21 @@ target1.type=ClassTarget
45 45
 target1.width=80
46 46
 target1.x=130
47 47
 target1.y=220
48
-target2.association=ConsoleTest
49 48
 target2.height=50
50
-target2.name=Console
49
+target2.name=opSwitch
51 50
 target2.showInterface=false
52 51
 target2.type=ClassTarget
53 52
 target2.width=80
54
-target2.x=130
55
-target2.y=100
53
+target2.x=40
54
+target2.y=160
55
+target3.association=ConsoleTest
56 56
 target3.height=50
57
-target3.name=opSwitch
57
+target3.name=Console
58 58
 target3.showInterface=false
59 59
 target3.type=ClassTarget
60 60
 target3.width=80
61
-target3.x=40
62
-target3.y=160
61
+target3.x=130
62
+target3.y=100
63 63
 target4.height=50
64 64
 target4.name=ConsoleTest
65 65
 target4.showInterface=false
@@ -67,10 +67,10 @@ target4.type=UnitTestTargetJunit4
67 67
 target4.width=80
68 68
 target4.x=160
69 69
 target4.y=70
70
-target5.height=50
70
+target5.height=40
71 71
 target5.name=MainApplication
72 72
 target5.showInterface=false
73 73
 target5.type=ClassTarget
74
-target5.width=120
75
-target5.x=120
76
-target5.y=10
74
+target5.width=60
75
+target5.x=80
76
+target5.y=30

+ 29
- 27
simpleOp.java Zobrazit soubor

@@ -8,71 +8,73 @@
8 8
 import java.util.*;
9 9
 public class simpleOp
10 10
 {
11
+    public static int currentNumber = 0;
12
+    
11 13
     public static int add(int x, int y){
12 14
         //CALULATES THE SUM OF TWO NUMBERS
13
-        int z = x + y;
14
-        System.out.println(x + " + " + y + " = " + z);
15
-        return z;
15
+        currentNumber = x + y;
16
+        System.out.println(currentNumber);
17
+        return currentNumber;
16 18
     }
17 19
     
18 20
     public static int sub(int x, int y){
19 21
         //CALULATES THE DIFFERENCE OF TWO NUMBERS
20
-        int z = x - y;
21
-        System.out.println(x + " - " + y + " = " + z);
22
-        return z;
22
+        int currentNumber = x - y;
23
+        System.out.println(x + " - " + y + " = " + currentNumber);
24
+        return currentNumber;
23 25
     }
24 26
     
25 27
     public static int mul(int x, int y){
26 28
         //CALULATES THE PRODUCT OF TWO NUMBERS
27
-        int z = x * y;
28
-        System.out.println(x + " * " + y + " = " + z);
29
-        return z;
29
+        int currentNumber = x * y;
30
+        System.out.println(x + " * " + y + " = " + currentNumber);
31
+        return currentNumber;
30 32
     }
31 33
     
32 34
     public static int div(int x, int y){
33 35
         //CALULATES THE QUOTIENT OF TWO NUMBERS
34
-        int z = x / y;
35
-        System.out.println(x + " / " + y + " = " + z);
36
-        return z;
36
+        int currentNumber = x / y;
37
+        System.out.println(x + " / " + y + " = " + currentNumber);
38
+        return currentNumber;
37 39
     }
38 40
     
39 41
     public static int squ(int x){
40 42
         //CALULATES THE SQUARE OF ONE NUMBER
41 43
         //CASTED TO INT FOR NOW... IT'S IN ALPHA, YOU DIG?
42
-        int z = (int) Math.pow(x,2);
43
-        System.out.println(x + "\u00B2 = " + z);
44
-        return z;
44
+        int currentNumber = (int) Math.pow(x,2);
45
+        System.out.println(x + "\u00B2 = " + currentNumber);
46
+        return currentNumber;
45 47
     }
46 48
     
47 49
     public static int sqrt(int x){
48 50
         //CALULATES THE SQUARE ROOT OF ONE NUMBER
49 51
         //CASTED TO INT FOR NOW... IT'S IN ALPHA, YOU DIG?
50
-        int z = (int) Math.sqrt(x);
51
-        System.out.println("√" + x + " = " + z);
52
-        return z;
52
+        int currentNumber = (int) Math.sqrt(x);
53
+        System.out.println("√" + x + " = " + currentNumber);
54
+        return currentNumber;
53 55
     }
54 56
     
55 57
     public static int exp(int x, int y){
56 58
         //CALULATES EXPONENTIATION OF X TO POWER OF Y
57 59
         //CASTED TO INT FOR NOW... IT'S IN ALPHA, YOU DIG?
58
-        int z = (int) Math.pow(x,y);
59
-        System.out.println(x + "^" + y + " = " + z);
60
-        return z;
60
+        int currentNumber = (int) Math.pow(x,y);
61
+        System.out.println(x + "^" + y + " = " + currentNumber);
62
+        return currentNumber;
61 63
     }
62 64
     
63 65
     public static double inv(double x){
64 66
         //CALULATES THE INVERSE OF NUMBER
65 67
         //CASTED TO INT FOR NOW... IT'S IN ALPHA, YOU DIG?
66
-        double z = 1 / x;
67
-        System.out.println("1 / " + x + " = " + z);
68
-        return z;
68
+        double currentNumber = 1 / x;
69
+        System.out.println("1 / " + x + " = " + currentNumber);
70
+        return currentNumber;
69 71
     }
70 72
     
71 73
     public static int invert(int number){
72 74
         //TURNS NEGATIVE TO POSITIVE OR POSITIVE TO NEGATIVE
73
-            int invertedNumber = -number;
74
-            System.out.println(invertedNumber);
75
-            return invertedNumber;
75
+            currentNumber = -number;
76
+            System.out.println(currentNumber);
77
+            return currentNumber;
76 78
     }
77 79
     
78 80
 }