-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTheCountTest.java
More file actions
executable file
·70 lines (67 loc) · 2.1 KB
/
Copy pathTheCountTest.java
File metadata and controls
executable file
·70 lines (67 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* The objective of the Count test is to practice
* the basic structures of OO programming: classes, objects,
* parameters, return values.
*
* @author ace
* @version 31 March 2010
*/
public class TheCountTest
{
/**
* Constructor for objects of class TheCountTest
*/
public TheCountTest()
{
}
/**
* This test requires that a string parser be created
* which can parse the strings "one" through "ten".
* (Technically, only "three" and "nine" are needed to get
* the test to pass, but it is intended that it is capable
* of handling any number one to ten.)
*/
//HINT: to test one at a time, comment out the second test while
//you're working on this one.
public void testTenTo10(){
TheCount count = new TheCount();
int three = count.tenTo10("three");
if(three == 3){
System.out.println("testTenTo10 passes test1");
}
else {
System.out.println("testTenTo10 fails test1");
}
int nine = count.tenTo10("nine");
if(nine == 9){
System.out.println("testTenTo10 passes test2");
}
else {
System.out.println("testTenTo10 fails test2");
}
}
/**
* This test does the opposite of the method above:
* it requires that the method is given a number between
* 1 and 10 and returns the equivilent string
*/
//HINT: to test one at a time, comment out this test while you're working
//on the first one.
public void testInt10ToTen(){
TheCount count = new TheCount();
String three = count.int10ToTen(3);
if(three.equals("three")){
System.out.println("testInt10ToTen passes test1");
}
else {
System.out.println("testInt10ToTen fails test1");
}
String nine = count.int10ToTen(9);
if(nine.equals("nine")){
System.out.println("testInt10ToTen passes test2");
}
else {
System.out.println("testInt10ToTen fails test2");
}
}
}