소스 검색

revised calc

John Kim 6 년 전
부모
커밋
6c483fdae6
6개의 변경된 파일29개의 추가작업 그리고 51개의 파일을 삭제
  1. BIN
      Main.class
  2. 0
    6
      Main.ctxt
  3. 0
    26
      Main.java
  4. BIN
      ShortCalculator.class
  5. 2
    2
      ShortCalculator.ctxt
  6. 27
    17
      ShortCalculator.java

BIN
Main.class 파일 보기


+ 0
- 6
Main.ctxt 파일 보기

@@ -1,6 +0,0 @@
1
-#BlueJ class context
2
-comment0.target=Main
3
-comment0.text=\n\ Write\ a\ description\ of\ class\ Main\ here.\n\n\ @author\ (your\ name)\n\ @version\ (a\ version\ number\ or\ a\ date)\n
4
-comment1.params=args
5
-comment1.target=void\ main(java.lang.String[])
6
-numComments=2

+ 0
- 26
Main.java 파일 보기

@@ -1,26 +0,0 @@
1
-import java.util.Scanner;
2
-/**
3
- * Write a description of class Main here.
4
- *
5
- * @author (your name)
6
- * @version (a version number or a date)
7
- */
8
-public class Main
9
-{
10
-    public static void main(String[] args) {
11
-        Scanner reader = new Scanner(System.in);
12
-
13
-        System.out.println("Enter two numbers between 0 and 65535");
14
-        System.out.println("Input the first number:"); 
15
-        short n1 = (short) reader.nextInt();
16
-        System.out.println("Input the second number:");
17
-        short n2 = (short) reader.nextInt();
18
-        ShortCalculator calc = new ShortCalculator(n1,n2);
19
-        
20
-        calc.printLine("Sum", calc.sum());
21
-        calc.printLine("Difference", calc.difference());
22
-        calc.printLine("Product", calc.product());
23
-        calc.printLine("Quotient", calc.quotient());
24
-        calc.printLine("Remainder", calc.remainder());
25
-    }
26
-}

BIN
ShortCalculator.class 파일 보기


+ 2
- 2
ShortCalculator.ctxt 파일 보기

@@ -1,7 +1,7 @@
1 1
 #BlueJ class context
2 2
 comment0.target=ShortCalculator
3
-comment1.params=x\ y
4
-comment1.target=ShortCalculator(short,\ short)
3
+comment1.params=args
4
+comment1.target=void\ main(java.lang.String[])
5 5
 comment2.params=
6 6
 comment2.target=short\ sum()
7 7
 comment3.params=

+ 27
- 17
ShortCalculator.java 파일 보기

@@ -2,35 +2,45 @@
2 2
 import java.util.Scanner;
3 3
 
4 4
 public class ShortCalculator {
5
-    private short n1;
6
-    private short n2;
7
-    
8
-    public ShortCalculator(short x, short y) {
9
-        this.n1 = x;
10
-        this.n2 = y;
5
+    private static int x;
6
+    private static int y;
7
+    public static void main(String[] args) {
8
+        Scanner reader = new Scanner(System.in);
9
+
10
+        System.out.println("Enter two numbers between 0 and 65535");
11
+        System.out.println("Input the first number:"); 
12
+        x = (short) reader.nextInt();
13
+        System.out.println("Input the second number:");
14
+        y = (short) reader.nextInt();
15
+        
16
+        ShortCalculator.printLine("Sum", ShortCalculator.sum());
17
+        ShortCalculator.printLine("Difference", ShortCalculator.difference());
18
+        ShortCalculator.printLine("Product", ShortCalculator.product());
19
+        ShortCalculator.printLine("Quotient", ShortCalculator.quotient());
20
+        ShortCalculator.printLine("Remainder", ShortCalculator.remainder());
11 21
     }
12 22
     
13
-    public short sum() {
14
-        return (short) (n1 + n2);
23
+    public static short sum() {
24
+        return (short) (x + y);
15 25
     }
16 26
     
17
-    public short difference() {
18
-        return (short) (n1 - n2);
27
+    public static short difference() {
28
+        return (short) (x / y);
19 29
     }
20 30
     
21
-    public short product() {
22
-        return (short) (n1 * n2);
31
+    public static short product() {
32
+        return (short) (x * y);
23 33
     }
24 34
     
25
-    public short quotient() {
26
-        return (short) (n1 / n2);
35
+    public static short quotient() {
36
+        return (short) (x / y);
27 37
     }
28 38
     
29
-    public short remainder() {
30
-        return (short) (n1 % n2);
39
+    public static short remainder() {
40
+        return (short) (x % y);
31 41
     }
32 42
     
33
-    public void printLine(String operation, short value) {
43
+    public static void printLine(String operation, short value) {
34 44
         System.out.println(operation + ": " + value); 
35 45
     }
36 46
 }