Przeglądaj źródła

committing YeOldeCode

chitraBegerhotta 8 lat temu
rodzic
commit
2cdafa1ad2
9 zmienionych plików z 472 dodań i 60 usunięć
  1. 2
    0
      Account.java
  2. 71
    0
      AccountTest.java
  3. 51
    0
      DepositAccountTest.java
  4. 49
    0
      ScrabbleTest.java
  5. 3
    1
      Squares.java
  6. 49
    0
      SquaresTest.java
  7. 51
    0
      TriangleOneTest.java
  8. 59
    0
      TriangleTwoTest.java
  9. 137
    59
      package.bluej

+ 2
- 0
Account.java Wyświetl plik

@@ -2,6 +2,8 @@
2 2
 class Account
3 3
 {
4 4
     private int amount;
5
+    
6
+    
5 7
 
6 8
     public Account()
7 9
     {

+ 71
- 0
AccountTest.java Wyświetl plik

@@ -0,0 +1,71 @@
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
+ * The test class AccountTest.
10
+ *
11
+ * @author  (your name)
12
+ * @version (a version number or a date)
13
+ */
14
+public class AccountTest
15
+{
16
+    /**
17
+     * Default constructor for test class AccountTest
18
+     */
19
+    public AccountTest()
20
+    {
21
+    }
22
+
23
+    /**
24
+     * Sets up the test fixture.
25
+     *
26
+     * Called before every test case method.
27
+     */
28
+    @Before
29
+    public void setUp()
30
+    {
31
+    }
32
+
33
+    /**
34
+     * Tears down the test fixture.
35
+     *
36
+     * Called after every test case method.
37
+     */
38
+    @After
39
+    public void tearDown()
40
+    {
41
+    }
42
+    @Test
43
+    public void testdeposit(){
44
+    int expected = 50;
45
+    Account ac = new Account(40);
46
+    ac.deposit(10);
47
+    int actual = ac.balance();
48
+    assertEquals(expected, actual);
49
+    
50
+    }
51
+    @Test
52
+    public void testtransfer(){
53
+    int expected_myAc = 30;
54
+    int expected_friendAc = 40;
55
+    Account myAc = new Account(40);
56
+    Account friendAcc = new Account(30);
57
+    myAc.transfer(friendAcc, 10);
58
+    int actual_myAc = myAc.balance();
59
+    int actual_friendAc = friendAcc.balance();
60
+    assertEquals(expected_myAc, actual_myAc);
61
+    assertEquals(expected_friendAc, actual_friendAc);
62
+    
63
+    }
64
+    @Test
65
+    public void testbalance(){
66
+    int expected = 30;
67
+    Account ac = new Account(30);
68
+    int actual = ac.balance();
69
+    assertEquals(expected, actual);
70
+    }
71
+}

+ 51
- 0
DepositAccountTest.java Wyświetl plik

@@ -0,0 +1,51 @@
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
+ * The test class DepositAccountTest.
10
+ *
11
+ * @author  (your name)
12
+ * @version (a version number or a date)
13
+ */
14
+public class DepositAccountTest
15
+{
16
+    /**
17
+     * Default constructor for test class DepositAccountTest
18
+     */
19
+    public DepositAccountTest()
20
+    {
21
+    }
22
+
23
+    /**
24
+     * Sets up the test fixture.
25
+     *
26
+     * Called before every test case method.
27
+     */
28
+    @Before
29
+    public void setUp()
30
+    {
31
+    }
32
+
33
+    /**
34
+     * Tears down the test fixture.
35
+     *
36
+     * Called after every test case method.
37
+     */
38
+    @After
39
+    public void tearDown()
40
+    {
41
+    }
42
+    @Test
43
+    public void testUpdate(){
44
+    int expected = 42;
45
+    DepositAccount da = new DepositAccount(30, 0.4);
46
+    da.update();
47
+    int actual = da.balance();
48
+    assertEquals(expected, actual);
49
+    }
50
+    
51
+}

+ 49
- 0
ScrabbleTest.java Wyświetl plik

@@ -0,0 +1,49 @@
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
+ * The test class ScrabbleTest.
10
+ *
11
+ * @author  (your name)
12
+ * @version (a version number or a date)
13
+ */
14
+public class ScrabbleTest
15
+{
16
+    /**
17
+     * Default constructor for test class ScrabbleTest
18
+     */
19
+    public ScrabbleTest()
20
+    {
21
+    }
22
+
23
+    /**
24
+     * Sets up the test fixture.
25
+     *
26
+     * Called before every test case method.
27
+     */
28
+    @Before
29
+    public void setUp()
30
+    {
31
+    }
32
+
33
+    /**
34
+     * Tears down the test fixture.
35
+     *
36
+     * Called after every test case method.
37
+     */
38
+    @After
39
+    public void tearDown()
40
+    {
41
+    }
42
+    @Test
43
+    public void testScore(){
44
+       int expected = 10;
45
+       Scrabble scrabble = new Scrabble();
46
+       int actual = scrabble.score("Q");
47
+       assertEquals(actual, expected);
48
+    }
49
+}

+ 3
- 1
Squares.java Wyświetl plik

@@ -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 limit;
15 17
  }
16 18
 }

+ 49
- 0
SquaresTest.java Wyświetl plik

@@ -0,0 +1,49 @@
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
+ * The test class SquaresTest.
10
+ *
11
+ * @author  (your name)
12
+ * @version (a version number or a date)
13
+ */
14
+public class SquaresTest
15
+{
16
+    /**
17
+     * Default constructor for test class SquaresTest
18
+     */
19
+    public SquaresTest()
20
+    {
21
+    }
22
+
23
+    /**
24
+     * Sets up the test fixture.
25
+     *
26
+     * Called before every test case method.
27
+     */
28
+    @Before
29
+    public void setUp()
30
+    {
31
+    }
32
+
33
+    /**
34
+     * Tears down the test fixture.
35
+     *
36
+     * Called after every test case method.
37
+     */
38
+    @After
39
+    public void tearDown()
40
+    {
41
+    }
42
+    @Test
43
+    public void testDisplay(){
44
+       int expected = 12;
45
+       Squares square = new Squares();
46
+       int actual = square.display(12);
47
+       assertEquals(expected, actual);
48
+    }
49
+}

+ 51
- 0
TriangleOneTest.java Wyświetl plik

@@ -0,0 +1,51 @@
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
+ * The test class TriangleOneTest.
10
+ *
11
+ * @author  (your name)
12
+ * @version (a version number or a date)
13
+ */
14
+public class TriangleOneTest
15
+{
16
+    /**
17
+     * Default constructor for test class TriangleOneTest
18
+     */
19
+    public TriangleOneTest()
20
+    {
21
+    }
22
+
23
+    /**
24
+     * Sets up the test fixture.
25
+     *
26
+     * Called before every test case method.
27
+     */
28
+    @Before
29
+    public void setUp()
30
+    {
31
+    }
32
+
33
+    /**
34
+     * Tears down the test fixture.
35
+     *
36
+     * Called after every test case method.
37
+     */
38
+    @After
39
+    public void tearDown()
40
+    {
41
+    }
42
+
43
+    @Test
44
+    public void testDisplay()
45
+    {
46
+        TriangleOne triangle1 = new TriangleOne();
47
+        triangle1.display(5);
48
+        triangle1.display();
49
+    }
50
+}
51
+

+ 59
- 0
TriangleTwoTest.java Wyświetl plik

@@ -0,0 +1,59 @@
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
+ * The test class TriangleTwoTest.
10
+ *
11
+ * @author  (your name)
12
+ * @version (a version number or a date)
13
+ */
14
+public class TriangleTwoTest
15
+{
16
+    /**
17
+     * Default constructor for test class TriangleTwoTest
18
+     */
19
+    public TriangleTwoTest()
20
+    {
21
+    }
22
+
23
+    /**
24
+     * Sets up the test fixture.
25
+     *
26
+     * Called before every test case method.
27
+     */
28
+    @Before
29
+    public void setUp()
30
+    {
31
+    }
32
+
33
+    /**
34
+     * Tears down the test fixture.
35
+     *
36
+     * Called after every test case method.
37
+     */
38
+    @After
39
+    public void tearDown()
40
+    {
41
+    }
42
+
43
+    @Test
44
+    public void testDisplay()
45
+    {
46
+        TriangleTwo triangle1 = new TriangleTwo();
47
+        triangle1.display();
48
+        triangle1.display(4, 3);
49
+    }
50
+
51
+    @Test
52
+    public void testDisplayTwo()
53
+    {
54
+        TriangleTwo triangle1 = new TriangleTwo();
55
+        triangle1.display(5, 2);
56
+    }
57
+}
58
+
59
+

+ 137
- 59
package.bluej Wyświetl plik

@@ -1,26 +1,56 @@
1 1
 #BlueJ package file
2
-dependency1.from=Account
3
-dependency1.to=AccountException
2
+dependency1.from=Calendar1
3
+dependency1.to=CalendarGraphic
4 4
 dependency1.type=UsesDependency
5
-dependency2.from=DepositAccount
6
-dependency2.to=AccountException
5
+dependency10.from=Account
6
+dependency10.to=AccountException
7
+dependency10.type=UsesDependency
8
+dependency11.from=AccountTest
9
+dependency11.to=Account
10
+dependency11.type=UsesDependency
11
+dependency12.from=DepositAccountTest
12
+dependency12.to=DepositAccount
13
+dependency12.type=UsesDependency
14
+dependency2.from=Calendar1
15
+dependency2.to=DateException
7 16
 dependency2.type=UsesDependency
17
+dependency3.from=Calendar
18
+dependency3.to=DateException
19
+dependency3.type=UsesDependency
20
+dependency4.from=Date
21
+dependency4.to=DateException
22
+dependency4.type=UsesDependency
23
+dependency5.from=DepositAccount
24
+dependency5.to=AccountException
25
+dependency5.type=UsesDependency
26
+dependency6.from=ScrabbleTest
27
+dependency6.to=Scrabble
28
+dependency6.type=UsesDependency
29
+dependency7.from=SquaresTest
30
+dependency7.to=Squares
31
+dependency7.type=UsesDependency
32
+dependency8.from=TriangleOneTest
33
+dependency8.to=TriangleOne
34
+dependency8.type=UsesDependency
35
+dependency9.from=TriangleTwoTest
36
+dependency9.to=TriangleTwo
37
+dependency9.type=UsesDependency
8 38
 editor.fx.0.height=722
9 39
 editor.fx.0.width=800
10
-editor.fx.0.x=114
11
-editor.fx.0.y=175
40
+editor.fx.0.x=469
41
+editor.fx.0.y=30
12 42
 objectbench.height=101
13 43
 objectbench.width=461
14 44
 package.divider.horizontal=0.6
15 45
 package.divider.vertical=0.8007380073800738
16 46
 package.editor.height=427
17
-package.editor.width=674
18
-package.editor.x=1006
19
-package.editor.y=133
47
+package.editor.width=658
48
+package.editor.x=5
49
+package.editor.y=78
20 50
 package.frame.height=600
21 51
 package.frame.width=800
22
-package.numDependencies=2
23
-package.numTargets=13
52
+package.numDependencies=12
53
+package.numTargets=19
24 54
 package.showExtends=true
25 55
 package.showUses=true
26 56
 project.charset=UTF-8
@@ -37,86 +67,134 @@ target1.width=130
37 67
 target1.x=450
38 68
 target1.y=190
39 69
 target10.height=50
40
-target10.name=Scrabble
70
+target10.name=TextIO
41 71
 target10.showInterface=false
42 72
 target10.type=ClassTarget
43 73
 target10.width=80
44
-target10.x=10
45
-target10.y=250
74
+target10.x=490
75
+target10.y=40
46 76
 target11.height=50
47
-target11.name=TriangleTwo
77
+target11.name=Date
48 78
 target11.showInterface=false
49 79
 target11.type=ClassTarget
50
-target11.width=100
51
-target11.x=120
52
-target11.y=310
80
+target11.width=80
81
+target11.x=350
82
+target11.y=290
53 83
 target12.height=50
54
-target12.name=AccountException
84
+target12.name=ScrabbleTest
55 85
 target12.showInterface=false
56
-target12.type=ClassTarget
57
-target12.width=140
58
-target12.x=190
59
-target12.y=30
86
+target12.type=UnitTestTargetJunit4
87
+target12.width=80
88
+target12.x=40
89
+target12.y=220
90
+target13.association=ScrabbleTest
60 91
 target13.height=50
61
-target13.name=DateException
92
+target13.name=Scrabble
62 93
 target13.showInterface=false
63 94
 target13.type=ClassTarget
64
-target13.width=120
65
-target13.x=470
66
-target13.y=340
95
+target13.width=80
96
+target13.x=10
97
+target13.y=250
98
+target14.association=DepositAccountTest
99
+target14.height=50
100
+target14.name=DepositAccount
101
+target14.showInterface=false
102
+target14.type=ClassTarget
103
+target14.width=120
104
+target14.x=170
105
+target14.y=120
106
+target15.association=TriangleTwoTest
107
+target15.height=50
108
+target15.name=TriangleTwo
109
+target15.showInterface=false
110
+target15.type=ClassTarget
111
+target15.width=100
112
+target15.x=120
113
+target15.y=310
114
+target16.height=50
115
+target16.name=AccountException
116
+target16.showInterface=false
117
+target16.type=ClassTarget
118
+target16.width=140
119
+target16.x=190
120
+target16.y=30
121
+target17.height=50
122
+target17.name=AccountTest
123
+target17.showInterface=false
124
+target17.type=UnitTestTargetJunit4
125
+target17.width=80
126
+target17.x=80
127
+target17.y=80
128
+target18.height=50
129
+target18.name=DateException
130
+target18.showInterface=false
131
+target18.type=ClassTarget
132
+target18.width=120
133
+target18.x=470
134
+target18.y=340
135
+target19.height=50
136
+target19.name=TriangleOneTest
137
+target19.showInterface=false
138
+target19.type=UnitTestTargetJunit4
139
+target19.width=100
140
+target19.x=40
141
+target19.y=350
67 142
 target2.height=50
68
-target2.name=Account
143
+target2.name=TriangleTwoTest
69 144
 target2.showInterface=false
70
-target2.type=ClassTarget
71
-target2.width=80
72
-target2.x=50
73
-target2.y=110
145
+target2.type=UnitTestTargetJunit4
146
+target2.width=100
147
+target2.x=150
148
+target2.y=280
74 149
 target3.height=50
75
-target3.name=Calendar1
150
+target3.name=DepositAccountTest
76 151
 target3.showInterface=false
77
-target3.type=ClassTarget
78
-target3.width=90
79
-target3.x=330
80
-target3.y=220
152
+target3.type=UnitTestTargetJunit4
153
+target3.width=120
154
+target3.x=200
155
+target3.y=90
81 156
 target4.height=50
82
-target4.name=Squares
157
+target4.name=Calendar1
83 158
 target4.showInterface=false
84 159
 target4.type=ClassTarget
85
-target4.width=80
86
-target4.x=100
87
-target4.y=250
160
+target4.width=90
161
+target4.x=330
162
+target4.y=220
163
+target5.association=AccountTest
88 164
 target5.height=50
89
-target5.name=Calendar
165
+target5.name=Account
90 166
 target5.showInterface=false
91 167
 target5.type=ClassTarget
92 168
 target5.width=80
93
-target5.x=490
94
-target5.y=270
169
+target5.x=50
170
+target5.y=110
171
+target6.association=SquaresTest
95 172
 target6.height=50
96
-target6.name=TriangleOne
173
+target6.name=Squares
97 174
 target6.showInterface=false
98 175
 target6.type=ClassTarget
99
-target6.width=100
100
-target6.x=10
101
-target6.y=310
176
+target6.width=80
177
+target6.x=100
178
+target6.y=250
102 179
 target7.height=50
103
-target7.name=TextIO
180
+target7.name=Calendar
104 181
 target7.showInterface=false
105 182
 target7.type=ClassTarget
106 183
 target7.width=80
107 184
 target7.x=490
108
-target7.y=40
185
+target7.y=270
186
+target8.association=TriangleOneTest
109 187
 target8.height=50
110
-target8.name=Date
188
+target8.name=TriangleOne
111 189
 target8.showInterface=false
112 190
 target8.type=ClassTarget
113
-target8.width=80
114
-target8.x=350
115
-target8.y=290
191
+target8.width=100
192
+target8.x=10
193
+target8.y=380
116 194
 target9.height=50
117
-target9.name=DepositAccount
195
+target9.name=SquaresTest
118 196
 target9.showInterface=false
119
-target9.type=ClassTarget
120
-target9.width=120
121
-target9.x=170
122
-target9.y=120
197
+target9.type=UnitTestTargetJunit4
198
+target9.width=80
199
+target9.x=130
200
+target9.y=220