Khalil Malik Saboor před 8 roky
rodič
revize
17d451e7c8

+ 42
- 0
AccountExceptionTest.java Zobrazit soubor

@@ -0,0 +1,42 @@
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 AccountExceptionTest.
10
+ *
11
+ * @author  (your name)
12
+ * @version (a version number or a date)
13
+ */
14
+public class AccountExceptionTest
15
+{
16
+    /**
17
+     * Default constructor for test class AccountExceptionTest
18
+     */
19
+    public AccountExceptionTest()
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
+}

+ 50
- 0
AccountTest.java Zobrazit soubor

@@ -0,0 +1,50 @@
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
+    @Test 
24
+    public void testBalance(){
25
+        Account account = new Account(1000);
26
+        // int amount = 1000;
27
+        // int expected = 1000;
28
+        //int actual = Account.balance();
29
+        assertTrue(account.balance() == 1000);
30
+    }
31
+    /**
32
+     * Sets up the test fixture.
33
+     *
34
+     * Called before every test case method.
35
+     */
36
+    @Before
37
+    public void setUp()
38
+    {
39
+    }
40
+
41
+    /**
42
+     * Tears down the test fixture.
43
+     *
44
+     * Called after every test case method.
45
+     */
46
+    @After
47
+    public void tearDown()
48
+    {
49
+    }
50
+}

+ 42
- 0
Calendar1Test.java Zobrazit soubor

@@ -0,0 +1,42 @@
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 Calendar1Test.
10
+ *
11
+ * @author  (your name)
12
+ * @version (a version number or a date)
13
+ */
14
+public class Calendar1Test
15
+{
16
+    /**
17
+     * Default constructor for test class Calendar1Test
18
+     */
19
+    public Calendar1Test()
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
+}

+ 42
- 0
CalendarGraphicTest.java Zobrazit soubor

@@ -0,0 +1,42 @@
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 CalendarGraphicTest.
10
+ *
11
+ * @author  (your name)
12
+ * @version (a version number or a date)
13
+ */
14
+public class CalendarGraphicTest
15
+{
16
+    /**
17
+     * Default constructor for test class CalendarGraphicTest
18
+     */
19
+    public CalendarGraphicTest()
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
+}

+ 42
- 0
CalendarTest.java Zobrazit soubor

@@ -0,0 +1,42 @@
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 CalendarTest.
10
+ *
11
+ * @author  (your name)
12
+ * @version (a version number or a date)
13
+ */
14
+public class CalendarTest
15
+{
16
+    /**
17
+     * Default constructor for test class CalendarTest
18
+     */
19
+    public CalendarTest()
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
+}

+ 0
- 1
Date.java Zobrazit soubor

@@ -42,5 +42,4 @@ class Date
42 42
            return true;
43 43
   return false;
44 44
  }
45
-
46 45
 }

+ 42
- 0
DateExceptionTest.java Zobrazit soubor

@@ -0,0 +1,42 @@
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 DateExceptionTest.
10
+ *
11
+ * @author  (your name)
12
+ * @version (a version number or a date)
13
+ */
14
+public class DateExceptionTest
15
+{
16
+    /**
17
+     * Default constructor for test class DateExceptionTest
18
+     */
19
+    public DateExceptionTest()
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
+}

+ 46
- 0
DateTest.java Zobrazit soubor

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

+ 42
- 0
DepositAccountTest.java Zobrazit soubor

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

+ 32
- 32
Scrabble.java Zobrazit soubor

@@ -2,39 +2,39 @@ import java.io.*;
2 2
 
3 3
 class Scrabble
4 4
 {
5
-// A class to give you the scrabble score of a word
5
+    // A class to give you the scrabble score of a word
6 6
 
7
- public static void main(String[] args) throws IOException
8
- {
9
-  BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
10
-  System.out.print("Enter a word: ");
11
-  String word=in.readLine();
12
-  System.out.println("Scrabble score is: "+score(word));
13
- }
7
+    public static void main(String[] args) throws IOException
8
+    {
9
+        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
10
+        System.out.print("Enter a word: ");
11
+        String word=in.readLine();
12
+        System.out.println("Scrabble score is: "+score(word));
13
+    }
14 14
 
15
- public static int score(String word)
16
- {
17
-  String uword=word.toUpperCase();
18
-  int score=0;
19
-  for(int i=0;i<uword.length();i++)
20
-     switch(uword.charAt(i))
21
-       {
22
-        case 'Q': case 'Z':
23
-          score+=10; break;
24
-        case 'J': case 'X':
25
-          score+=8; break;
26
-        case 'K':
27
-          score+=5; break;
28
-        case 'F': case 'H': case 'V': case 'W': case 'Y':
29
-          score+=4; break;
30
-        case 'B': case 'C': case 'M': case 'P':
31
-          score+=3; break;
32
-        case 'D': case 'G':
33
-          score+=2;break;
34
-        default:
35
-          score+=1;break;
36
-      } 
37
-  return score;
38
- }
15
+    public static int score(String word)
16
+    {
17
+        String uword=word.toUpperCase();
18
+        int score=0;
19
+        for(int i=0;i<uword.length();i++)
20
+            switch(uword.charAt(i))
21
+            {
22
+                case 'Q': case 'Z':
23
+                score+=10; break;
24
+                case 'J': case 'X':
25
+                score+=8; break;
26
+                case 'K':
27
+                score+=5; break;
28
+                case 'F': case 'H': case 'V': case 'W': case 'Y':
29
+                score+=4; break;
30
+                case 'B': case 'C': case 'M': case 'P':
31
+                score+=3; break;
32
+                case 'D': case 'G':
33
+                score+=2;break;
34
+                default:
35
+                score+=1;break;
36
+            } 
37
+        return score;
38
+    }
39 39
 
40 40
 }

+ 51
- 0
ScrabbleTest.java Zobrazit soubor

@@ -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 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
+    @Test
23
+    public void testScore(){
24
+    
25
+        String word = "world";
26
+        int score = 9;
27
+        
28
+        int expected = 9;
29
+        int actual = Scrabble.score(word);
30
+        assertEquals(expected,actual);
31
+    }
32
+    /**
33
+     * Sets up the test fixture.
34
+     *
35
+     * Called before every test case method.
36
+     */
37
+    @Before
38
+    public void setUp()
39
+    {
40
+    }
41
+
42
+    /**
43
+     * Tears down the test fixture.
44
+     *
45
+     * Called after every test case method.
46
+     */
47
+    @After
48
+    public void tearDown()
49
+    {
50
+    }
51
+}

+ 48
- 0
SquaresTest.java Zobrazit soubor

@@ -0,0 +1,48 @@
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
+           // : Given
22
+        int expected = 49;
23
+        // : When
24
+        int actual = 0; 
25
+        // : Then
26
+        assertEquals(expected,actual);
27
+    }
28
+
29
+    /**
30
+     * Sets up the test fixture.
31
+     *
32
+     * Called before every test case method.
33
+     */
34
+    @Before
35
+    public void setUp()
36
+    {
37
+    }
38
+
39
+    /**
40
+     * Tears down the test fixture.
41
+     *
42
+     * Called after every test case method.
43
+     */
44
+    @After
45
+    public void tearDown()
46
+    {
47
+    }
48
+}

+ 3
- 0
TriangleOne.java Zobrazit soubor

@@ -11,12 +11,15 @@ class TriangleOne
11 11
 
12 12
     public void display(int size)
13 13
     {
14
+        
14 15
         for(int i=0;i<size;i++)
15 16
         {
16 17
             for(int j=0;j<=i;j++)
17 18
                 System.out.print("*");
18 19
             System.out.println();
19 20
         }
21
+        
22
+        
20 23
     }
21 24
 
22 25
 }

+ 0
- 0
mo Zobrazit soubor


+ 157
- 59
package.bluej Zobrazit soubor

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