Aleena Rose-Mathew 8 yıl önce
ebeveyn
işleme
54b0827e8d
7 değiştirilmiş dosya ile 168 ekleme ve 41 silme
  1. 2
    2
      Account.java
  2. 46
    0
      AccountTest.java
  3. 30
    0
      ScrabbleTest.java
  4. 3
    1
      Squares.java
  5. 19
    0
      SquaresTest.java
  6. 10
    3
      TriangleTwo.java
  7. 58
    35
      package.bluej

+ 2
- 2
Account.java Dosyayı Görüntüle

@@ -20,8 +20,8 @@ class Account
20 20
 
21 21
     public boolean transfer(Account acc, int sum) {
22 22
         if(sum<=amount) {
23
-            amount-=sum;
24
-            acc.amount+=sum;
23
+            amount-=sum;//the one who is transfering
24
+            acc.amount+=sum;//the other personns account
25 25
             return true;
26 26
         }
27 27
         else return false;

+ 46
- 0
AccountTest.java Dosyayı Görüntüle

@@ -0,0 +1,46 @@
1
+
2
+
3
+import static org.junit.Assert.*;
4
+import org.junit.After;
5
+import org.junit.Before;
6
+import org.junit.Test;
7
+
8
+
9
+public class AccountTest
10
+{
11
+    /**
12
+     * Default constructor for test class AccountTest
13
+     */
14
+    public AccountTest()
15
+    {
16
+    }
17
+
18
+    /**
19
+     * Sets up the test fixture.
20
+     *
21
+     * Called before every test case method.
22
+     */
23
+    @Before
24
+    public void setUp()
25
+    {
26
+    }
27
+
28
+    /**
29
+     * Tears down the test fixture.
30
+     *
31
+     * Called after every test case method.
32
+     */
33
+    @After
34
+    public void tearDown()
35
+    {
36
+    }
37
+    @Test
38
+    public void testAccountBalance()
39
+    {
40
+        Account account=new Account(999);
41
+        int expected=999;
42
+        int actual=account.balance();
43
+        assertEquals(actual,expected);
44
+    }
45
+        
46
+}

+ 30
- 0
ScrabbleTest.java Dosyayı Görüntüle

@@ -0,0 +1,30 @@
1
+
2
+
3
+import static org.junit.Assert.*;
4
+import org.junit.After;
5
+import org.junit.Before;
6
+import org.junit.Test;
7
+
8
+
9
+public class ScrabbleTest
10
+{
11
+    
12
+    @Test
13
+    public void testScrabble()
14
+    {
15
+        int expected =10;
16
+        Scrabble t1=new Scrabble();
17
+        int actual=t1.score("q");
18
+        assertEquals(actual,expected);
19
+    }
20
+    @Test
21
+    public void testScrabble1()
22
+    {
23
+        int expected =10;
24
+        Scrabble t1=new Scrabble();
25
+        int actual=t1.score("bmw");
26
+        assertEquals(actual,expected);
27
+    }
28
+    
29
+    
30
+}

+ 3
- 1
Squares.java Dosyayı Görüntüle

@@ -4,13 +4,15 @@ class Squares
4 4
 
5 5
  static final int LIMIT=150;
6 6
 
7
- public void display(int limit)
7
+ public int display(int limit)
8 8
  {
9 9
   int i;
10 10
   for(i=1;i*i<limit;i++)
11 11
      {
12 12
       System.out.print("The square of "+i);
13 13
       System.out.println(" is "+i*i);
14
+      
14 15
      }
16
+     return i*i;
15 17
  }
16 18
 }

+ 19
- 0
SquaresTest.java Dosyayı Görüntüle

@@ -0,0 +1,19 @@
1
+
2
+
3
+import static org.junit.Assert.*;
4
+import org.junit.After;
5
+import org.junit.Before;
6
+import org.junit.Test;
7
+
8
+
9
+public class SquaresTest
10
+{
11
+    Squares square=new Squares();
12
+    @Test
13
+    public void testSquare()
14
+    {
15
+        int expected=1;
16
+        int actual=square.display(1);
17
+        assertEquals(actual,expected);
18
+    }
19
+}

+ 10
- 3
TriangleTwo.java Dosyayı Görüntüle

@@ -11,7 +11,7 @@ class TriangleTwo {
11 11
         this.display(XTRIANGLES, SIZE);
12 12
     }
13 13
 
14
-    public void display(int num, int size)
14
+    public void display(int num,int size)
15 15
     {
16 16
         for(int i=0;i<size;i++)
17 17
         {
@@ -23,8 +23,15 @@ class TriangleTwo {
23 23
                 for(;j<size;j++)
24 24
                     System.out.print(" ");
25 25
             }
26
-            System.out.println();
27 26
         }
27
+            System.out.println();
28
+       
29
+            
30
+        
28 31
     }
32
+}
33
+
34
+    
35
+       /* 
36
+        }*/
29 37
 
30
-}

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

@@ -1,26 +1,41 @@
1 1
 #BlueJ package file
2
-dependency1.from=Account
2
+dependency1.from=DepositAccount
3 3
 dependency1.to=AccountException
4 4
 dependency1.type=UsesDependency
5
-dependency2.from=DepositAccount
6
-dependency2.to=AccountException
5
+dependency2.from=ScrabbleTest
6
+dependency2.to=Scrabble
7 7
 dependency2.type=UsesDependency
8
-editor.fx.0.height=722
9
-editor.fx.0.width=800
10
-editor.fx.0.x=114
11
-editor.fx.0.y=175
8
+dependency3.from=Calendar1
9
+dependency3.to=CalendarGraphic
10
+dependency3.type=UsesDependency
11
+dependency4.from=Calendar1
12
+dependency4.to=DateException
13
+dependency4.type=UsesDependency
14
+dependency5.from=Calendar
15
+dependency5.to=DateException
16
+dependency5.type=UsesDependency
17
+dependency6.from=Date
18
+dependency6.to=DateException
19
+dependency6.type=UsesDependency
20
+dependency7.from=Account
21
+dependency7.to=AccountException
22
+dependency7.type=UsesDependency
23
+editor.fx.0.height=0
24
+editor.fx.0.width=0
25
+editor.fx.0.x=0
26
+editor.fx.0.y=0
12 27
 objectbench.height=101
13 28
 objectbench.width=461
14 29
 package.divider.horizontal=0.6
15 30
 package.divider.vertical=0.8007380073800738
16 31
 package.editor.height=427
17 32
 package.editor.width=674
18
-package.editor.x=1006
33
+package.editor.x=480
19 34
 package.editor.y=133
20 35
 package.frame.height=600
21 36
 package.frame.width=800
22
-package.numDependencies=2
23
-package.numTargets=13
37
+package.numDependencies=7
38
+package.numTargets=14
24 39
 package.showExtends=true
25 40
 package.showUses=true
26 41
 project.charset=UTF-8
@@ -36,6 +51,7 @@ target1.type=ClassTarget
36 51
 target1.width=130
37 52
 target1.x=450
38 53
 target1.y=190
54
+target10.association=ScrabbleTest
39 55
 target10.height=50
40 56
 target10.name=Scrabble
41 57
 target10.showInterface=false
@@ -44,40 +60,47 @@ target10.width=80
44 60
 target10.x=10
45 61
 target10.y=250
46 62
 target11.height=50
47
-target11.name=TriangleTwo
63
+target11.name=DepositAccount
48 64
 target11.showInterface=false
49 65
 target11.type=ClassTarget
50
-target11.width=100
51
-target11.x=120
52
-target11.y=310
66
+target11.width=120
67
+target11.x=170
68
+target11.y=120
53 69
 target12.height=50
54
-target12.name=AccountException
70
+target12.name=TriangleTwo
55 71
 target12.showInterface=false
56 72
 target12.type=ClassTarget
57
-target12.width=140
58
-target12.x=190
59
-target12.y=30
73
+target12.width=100
74
+target12.x=120
75
+target12.y=310
60 76
 target13.height=50
61
-target13.name=DateException
77
+target13.name=AccountException
62 78
 target13.showInterface=false
63 79
 target13.type=ClassTarget
64
-target13.width=120
65
-target13.x=470
66
-target13.y=340
80
+target13.width=140
81
+target13.x=190
82
+target13.y=30
83
+target14.height=50
84
+target14.name=DateException
85
+target14.showInterface=false
86
+target14.type=ClassTarget
87
+target14.width=120
88
+target14.x=470
89
+target14.y=340
67 90
 target2.height=50
68
-target2.name=Account
91
+target2.name=Calendar1
69 92
 target2.showInterface=false
70 93
 target2.type=ClassTarget
71
-target2.width=80
72
-target2.x=50
73
-target2.y=110
94
+target2.width=90
95
+target2.x=330
96
+target2.y=220
74 97
 target3.height=50
75
-target3.name=Calendar1
98
+target3.name=Account
76 99
 target3.showInterface=false
77 100
 target3.type=ClassTarget
78
-target3.width=90
79
-target3.x=330
80
-target3.y=220
101
+target3.width=80
102
+target3.x=50
103
+target3.y=110
81 104
 target4.height=50
82 105
 target4.name=Squares
83 106
 target4.showInterface=false
@@ -114,9 +137,9 @@ target8.width=80
114 137
 target8.x=350
115 138
 target8.y=290
116 139
 target9.height=50
117
-target9.name=DepositAccount
140
+target9.name=ScrabbleTest
118 141
 target9.showInterface=false
119
-target9.type=ClassTarget
120
-target9.width=120
121
-target9.x=170
122
-target9.y=120
142
+target9.type=UnitTestTargetJunit4
143
+target9.width=80
144
+target9.x=40
145
+target9.y=220