Kaynağa Gözat

short calc done

John Kim 6 yıl önce
ebeveyn
işleme
bb3b7bcbca
7 değiştirilmiş dosya ile 91 ekleme ve 14 silme
  1. BIN
      Main.class
  2. 6
    0
      Main.ctxt
  3. 26
    0
      Main.java
  4. BIN
      ShortCalculator.class
  5. 15
    1
      ShortCalculator.ctxt
  6. 32
    1
      ShortCalculator.java
  7. 12
    12
      package.bluej

BIN
Main.class Dosyayı Görüntüle


+ 6
- 0
Main.ctxt Dosyayı Görüntüle

@@ -0,0 +1,6 @@
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

+ 26
- 0
Main.java Dosyayı Görüntüle

@@ -0,0 +1,26 @@
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 Dosyayı Görüntüle


+ 15
- 1
ShortCalculator.ctxt Dosyayı Görüntüle

@@ -1,3 +1,17 @@
1 1
 #BlueJ class context
2 2
 comment0.target=ShortCalculator
3
-numComments=1
3
+comment1.params=x\ y
4
+comment1.target=ShortCalculator(short,\ short)
5
+comment2.params=
6
+comment2.target=short\ sum()
7
+comment3.params=
8
+comment3.target=short\ difference()
9
+comment4.params=
10
+comment4.target=short\ product()
11
+comment5.params=
12
+comment5.target=short\ quotient()
13
+comment6.params=
14
+comment6.target=short\ remainder()
15
+comment7.params=operation\ value
16
+comment7.target=void\ printLine(java.lang.String,\ short)
17
+numComments=8

+ 32
- 1
ShortCalculator.java Dosyayı Görüntüle

@@ -1,5 +1,36 @@
1 1
  
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;
11
+    }
12
+    
13
+    public short sum() {
14
+        return (short) (n1 + n2);
15
+    }
16
+    
17
+    public short difference() {
18
+        return (short) (n1 - n2);
19
+    }
20
+    
21
+    public short product() {
22
+        return (short) (n1 * n2);
23
+    }
24
+    
25
+    public short quotient() {
26
+        return (short) (n1 / n2);
27
+    }
28
+    
29
+    public short remainder() {
30
+        return (short) (n1 % n2);
31
+    }
32
+    
33
+    public void printLine(String operation, short value) {
34
+        System.out.println(operation + ": " + value); 
35
+    }
5 36
 }

+ 12
- 12
package.bluej Dosyayı Görüntüle

@@ -11,20 +11,20 @@ dependency3.type=UsesDependency
11 11
 dependency4.from=IntegerPrinterTest
12 12
 dependency4.to=IntegerPrinter
13 13
 dependency4.type=UsesDependency
14
-editor.fx.0.height=0
15
-editor.fx.0.width=0
16
-editor.fx.0.x=0
17
-editor.fx.0.y=0
14
+editor.fx.0.height=722
15
+editor.fx.0.width=800
16
+editor.fx.0.x=1048
17
+editor.fx.0.y=298
18 18
 objectbench.height=101
19
-objectbench.width=1070
19
+objectbench.width=653
20 20
 package.divider.horizontal=0.6
21
-package.divider.vertical=0.837593984962406
22
-package.editor.height=550
23
-package.editor.width=968
24
-package.editor.x=59
25
-package.editor.y=82
26
-package.frame.height=723
27
-package.frame.width=1094
21
+package.divider.vertical=0.8325581395348837
22
+package.editor.height=530
23
+package.editor.width=551
24
+package.editor.x=1202
25
+package.editor.y=48
26
+package.frame.height=703
27
+package.frame.width=677
28 28
 package.numDependencies=4
29 29
 package.numTargets=10
30 30
 package.showExtends=true