Przeglądaj źródła

added math methods

Seth 6 lat temu
rodzic
commit
9457132587
3 zmienionych plików z 42 dodań i 42 usunięć
  1. 24
    0
      Calculator.java
  2. 1
    1
      MathMethods.java
  3. 17
    41
      package.bluej

+ 24
- 0
Calculator.java Wyświetl plik

@@ -127,6 +127,30 @@ class Calculator{
127 127
                     memory = result;
128 128
                     calc.printAns(String.valueOf(result));
129 129
                     break;
130
+                    
131
+                    case "square":
132
+                    result = calc.square(num1);
133
+                    memory = result;
134
+                    calc.printAns(String.valueOf(result));
135
+                    break;
136
+                    
137
+                    case "inverse":
138
+                    result = calc.inverse(num1);
139
+                    memory = result;
140
+                    calc.printAns(String.format("1/%.0f", result));
141
+                    break;
142
+                    
143
+                    case "tangent":
144
+                    result = calc.tangent(num1);
145
+                    memory = result;
146
+                    calc.printAns(String.valueOf(result));
147
+                    break;
148
+                    
149
+                    case "inverse tangent":
150
+                    result = calc.iTan(num1);
151
+                    memory = result;
152
+                    calc.printAns(String.valueOf(result));
153
+                    break;
130 154
                 }
131 155
             }
132 156
         }

+ 1
- 1
MathMethods.java Wyświetl plik

@@ -80,7 +80,7 @@ public class MathMethods
80 80
         return Math.tan(n1);
81 81
     }
82 82
 
83
-    public static double itan(double n1) {
83
+    public static double iTan(double n1) {
84 84
         return Math.atan(n1);
85 85
     }
86 86
 

+ 17
- 41
package.bluej Wyświetl plik

@@ -1,33 +1,23 @@
1 1
 #BlueJ package file
2
-dependency1.from=Console
3
-dependency1.to=Calculator
2
+dependency1.from=Calculator
3
+dependency1.to=MathMethods
4 4
 dependency1.type=UsesDependency
5
-dependency2.from=MainApplication
6
-dependency2.to=Console
7
-dependency2.type=UsesDependency
8
-<<<<<<< HEAD
9
-editor.fx.0.height=765
10
-editor.fx.0.width=863
11
-editor.fx.0.x=601
12
-editor.fx.0.y=-945
13
-=======
14
-editor.fx.0.height=1020
5
+editor.fx.0.height=797
15 6
 editor.fx.0.width=1247
16
-editor.fx.0.x=1891
17
-editor.fx.0.y=66
18
->>>>>>> 9d9574817b6e6ff98ab240c0e423add0236a0300
7
+editor.fx.0.x=78
8
+editor.fx.0.y=23
19 9
 objectbench.height=80
20 10
 objectbench.width=595
21 11
 package.divider.horizontal=0.5993322203672788
22 12
 package.divider.vertical=0.8465608465608465
23
-package.editor.height=457
13
+package.editor.height=473
24 14
 package.editor.width=493
25 15
 package.editor.x=102
26
-package.editor.y=-1057
16
+package.editor.y=23
27 17
 package.frame.height=625
28 18
 package.frame.width=619
29
-package.numDependencies=2
30
-package.numTargets=4
19
+package.numDependencies=1
20
+package.numTargets=2
31 21
 package.showExtends=true
32 22
 package.showUses=true
33 23
 project.charset=UTF-8
@@ -37,30 +27,16 @@ readme.width=47
37 27
 readme.x=10
38 28
 readme.y=10
39 29
 target1.height=50
40
-target1.name=Memory
30
+target1.name=Calculator
41 31
 target1.showInterface=false
42 32
 target1.type=ClassTarget
43
-target1.width=80
44
-target1.x=400
45
-target1.y=120
33
+target1.width=90
34
+target1.x=200
35
+target1.y=310
46 36
 target2.height=50
47
-target2.name=Calculator
37
+target2.name=MathMethods
48 38
 target2.showInterface=false
49 39
 target2.type=ClassTarget
50
-target2.width=90
51
-target2.x=200
52
-target2.y=310
53
-target3.height=50
54
-target3.name=Console
55
-target3.showInterface=false
56
-target3.type=ClassTarget
57
-target3.width=80
58
-target3.x=80
59
-target3.y=200
60
-target4.height=50
61
-target4.name=MainApplication
62
-target4.showInterface=false
63
-target4.type=ClassTarget
64
-target4.width=120
65
-target4.x=70
66
-target4.y=70
40
+target2.width=110
41
+target2.x=70
42
+target2.y=10