소스 검색

Merge branch 'master' of roympanju_1/ZCW-MacroLabs-OOP-ScientificCalculator into master

Jamez-s 6 년 전
부모
커밋
526442d21b
2개의 변경된 파일24개의 추가작업 그리고 14개의 파일을 삭제
  1. 10
    0
      Operations.java
  2. 14
    14
      bonusFunctions.java

+ 10
- 0
Operations.java 파일 보기

@@ -21,6 +21,7 @@ public class Operations
21 21
         scienticFunctions ScientificFunctions = new scienticFunctions();
22 22
         Memory memory = new Memory();
23 23
         DiplayMode displayMode = new DiplayMode();
24
+        bonusFunctions bonusFunctions = new bonusFunctions();
24 25
         // Calculator calc = new ....
25 26
         while (true) {
26 27
             System.out.print("Enter a command: ");
@@ -69,6 +70,15 @@ public class Operations
69 70
                 displayMode.switchDisplayMode(mode);
70 71
                 
71 72
             }
73
+            if (command.equalsIgnoreCase("log")){
74
+                Console.printResult(bonusFunctions.LogBaseTenOfAnumber(result));
75
+            }
76
+            if (command.equalsIgnoreCase("ln")){
77
+                Console.printResult(bonusFunctions.naturalLogLn(result));
78
+            }
79
+            if (command.equalsIgnoreCase("ex")){
80
+                Console.printResult(bonusFunctions.exponential(result));
81
+            }
72 82
             //firstNumber = result;
73 83
             // and on and on
74 84
         }

+ 14
- 14
bonusFunctions.java 파일 보기

@@ -7,27 +7,27 @@
7 7
  */
8 8
 public class bonusFunctions
9 9
 {
10
-    // instance variables - replace the example below with your own
11
-    private int x;
12
-
13
-    /**
14
-     * Constructor for objects of class bonusFunctions
15
-     */
16
-    public bonusFunctions()
17
-    {
18
-        // initialise instance variables
19
-        x = 0;
20
-    }
21
-
22 10
     /**
23 11
      * An example of a method - replace this comment with your own
24 12
      *
25 13
      * @param  y  a sample parameter for a method
26 14
      * @return    the sum of x and y
27 15
      */
28
-    public int sampleMethod(int y)
16
+    public Double naturalLogLn(Double x)
17
+    {
18
+        // put your code here
19
+        return Math.log(x);
20
+    }
21
+    
22
+    public Double LogBaseTenOfAnumber(Double x)
23
+    {
24
+        // put your code here
25
+        return Math.log10(x);
26
+    }
27
+    
28
+    public Double exponential(Double x)
29 29
     {
30 30
         // put your code here
31
-        return x + y;
31
+        return Math.exp(x);
32 32
     }
33 33
 }