Browse Source

finished lab

Eric Foster 6 years ago
parent
commit
2e0001b29c
13 changed files with 129 additions and 16 deletions
  1. BIN
      Calculator.class
  2. 6
    0
      Calculator.ctxt
  3. 18
    0
      Calculator.java
  4. BIN
      Console.class
  5. 8
    0
      Console.ctxt
  6. 21
    0
      Console.java
  7. BIN
      Main.class
  8. 6
    0
      Main.ctxt
  9. 3
    3
      Main.java
  10. BIN
      SumOfInput.class
  11. 6
    0
      SumOfInput.ctxt
  12. 18
    0
      SumOfInput.java
  13. 43
    13
      package.bluej

BIN
Calculator.class View File


+ 6
- 0
Calculator.ctxt View File

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

+ 18
- 0
Calculator.java View File

@@ -0,0 +1,18 @@
1
+
2
+/**
3
+ * Write a description of class Calculator here.
4
+ *
5
+ * @author (your name)
6
+ * @version (a version number or a date)
7
+ */
8
+public class Calculator
9
+{
10
+    public void run()
11
+    {
12
+        System.out.println("Enter a number,n, to get sum of 1 to n");
13
+        Console console = new Console();
14
+        SumOfInput sumOfInput = new SumOfInput();
15
+        int aSumOfInput = sumOfInput.sumOfInput(console.getUserInput());
16
+        console.printSumOfInput(aSumOfInput);
17
+    }
18
+}

BIN
Console.class View File


+ 8
- 0
Console.ctxt View File

@@ -0,0 +1,8 @@
1
+#BlueJ class context
2
+comment0.target=Console
3
+comment0.text=\n\ Write\ a\ description\ of\ class\ getUserInput\ here.\n\n\ @author\ (your\ name)\n\ @version\ (a\ version\ number\ or\ a\ date)\n
4
+comment1.params=
5
+comment1.target=int\ getUserInput()
6
+comment2.params=sum
7
+comment2.target=void\ printSumOfInput(int)
8
+numComments=3

+ 21
- 0
Console.java View File

@@ -0,0 +1,21 @@
1
+import java.util.Scanner;
2
+
3
+/**
4
+ * Write a description of class getUserInput here.
5
+ *
6
+ * @author (your name)
7
+ * @version (a version number or a date)
8
+ */
9
+public class Console
10
+{
11
+    public int getUserInput()
12
+    {
13
+        Scanner userInput = new Scanner(System.in);
14
+        int numberInput = userInput.nextInt();
15
+        return numberInput;
16
+    }
17
+    
18
+    public void printSumOfInput(int sum){
19
+        System.out.println("The sum of 1 to your number, n, is: " + sum);
20
+    }
21
+}

BIN
Main.class View File


+ 6
- 0
Main.ctxt View File

@@ -0,0 +1,6 @@
1
+#BlueJ class context
2
+comment0.target=Main
3
+comment0.text=\n\ Created\ by\ iyasuwatts\ on\ 10/17/17.\n
4
+comment1.params=
5
+comment1.target=void\ main()
6
+numComments=2

+ 3
- 3
Main.java View File

@@ -2,8 +2,8 @@
2 2
  * Created by iyasuwatts on 10/17/17.
3 3
  */
4 4
 public class Main {
5
-
6
-    public static void main(String[] args){
7
-
5
+    public static void main(){
6
+        Calculator calc = new Calculator();
7
+        calc.run();
8 8
     }
9 9
 }

BIN
SumOfInput.class View File


+ 6
- 0
SumOfInput.ctxt View File

@@ -0,0 +1,6 @@
1
+#BlueJ class context
2
+comment0.target=SumOfInput
3
+comment0.text=\n\ Write\ a\ description\ of\ class\ SumOfInput\ here.\n\n\ @author\ (your\ name)\n\ @version\ (a\ version\ number\ or\ a\ date)\n
4
+comment1.params=n
5
+comment1.target=int\ sumOfInput(int)
6
+numComments=2

+ 18
- 0
SumOfInput.java View File

@@ -0,0 +1,18 @@
1
+
2
+/**
3
+ * Write a description of class SumOfInput here.
4
+ *
5
+ * @author (your name)
6
+ * @version (a version number or a date)
7
+ */
8
+public class SumOfInput
9
+{
10
+    public int sumOfInput(int n)
11
+    {
12
+        int sum = 0;
13
+        for (int i=n; i>=1; i--){
14
+            sum += i;
15
+        }
16
+        return sum;
17
+    }
18
+}

+ 43
- 13
package.bluej View File

@@ -1,20 +1,29 @@
1 1
 #BlueJ package file
2
-editor.fx.0.height=0
3
-editor.fx.0.width=0
4
-editor.fx.0.x=0
5
-editor.fx.0.y=0
2
+dependency1.from=Main
3
+dependency1.to=Calculator
4
+dependency1.type=UsesDependency
5
+dependency2.from=Calculator
6
+dependency2.to=Console
7
+dependency2.type=UsesDependency
8
+dependency3.from=Calculator
9
+dependency3.to=SumOfInput
10
+dependency3.type=UsesDependency
11
+editor.fx.0.height=709
12
+editor.fx.0.width=1162
13
+editor.fx.0.x=170
14
+editor.fx.0.y=55
6 15
 objectbench.height=164
7
-objectbench.width=776
16
+objectbench.width=461
8 17
 package.divider.horizontal=0.6
9 18
 package.divider.vertical=0.6845018450184502
10 19
 package.editor.height=364
11 20
 package.editor.width=674
12
-package.editor.x=-816
13
-package.editor.y=445
21
+package.editor.x=110
22
+package.editor.y=131
14 23
 package.frame.height=600
15 24
 package.frame.width=800
16
-package.numDependencies=0
17
-package.numTargets=1
25
+package.numDependencies=3
26
+package.numTargets=4
18 27
 package.showExtends=true
19 28
 package.showUses=true
20 29
 project.charset=UTF-8
@@ -24,9 +33,30 @@ readme.width=47
24 33
 readme.x=10
25 34
 readme.y=10
26 35
 target1.height=50
27
-target1.name=Main
36
+target1.name=SumOfInput
28 37
 target1.showInterface=false
29 38
 target1.type=ClassTarget
30
-target1.width=80
31
-target1.x=70
32
-target1.y=10
39
+target1.width=100
40
+target1.x=270
41
+target1.y=100
42
+target2.height=50
43
+target2.name=Calculator
44
+target2.showInterface=false
45
+target2.type=ClassTarget
46
+target2.width=90
47
+target2.x=200
48
+target2.y=10
49
+target3.height=50
50
+target3.name=Console
51
+target3.showInterface=false
52
+target3.type=ClassTarget
53
+target3.width=80
54
+target3.x=140
55
+target3.y=100
56
+target4.height=50
57
+target4.name=Main
58
+target4.showInterface=false
59
+target4.type=ClassTarget
60
+target4.width=80
61
+target4.x=70
62
+target4.y=10