-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKivaTest.java
More file actions
53 lines (47 loc) · 1.66 KB
/
Copy pathKivaTest.java
File metadata and controls
53 lines (47 loc) · 1.66 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
import edu.duke.FileResource;
import edu.duke.Point;
/**
* Write a description of class KivaTest here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class KivaTest
{
public KivaTest()
{
// initialise instance variables
}
FileResource fileResource = new FileResource("sample_floor_map2.txt");
String inputMap = fileResource.asString();
FloorMap defaultMap = new FloorMap(inputMap);
public void testSingleArgumentConstructor() {
Kiva kiva = new Kiva(defaultMap);
Point initialLocation = kiva.getCurrentLocation();
Point expectedLocation = new Point(2, 4);
if (sameLocation(initialLocation, expectedLocation))
{
System.out.println("testSingleArgumentConstructor SUCCESS");
}
else
{
System.out.println(String.format("testSingleArgumentConstructor FAIL: %s != (2,4)!", initialLocation));
}
}
public void testTowArgumentConstructor(Point point) {
Kiva kiva = new Kiva(defaultMap);
Point initialLocation = kiva.getCurrentLocation();
Point expectedLocation = point;
if (sameLocation(initialLocation, expectedLocation))
{
System.out.println("testTowArgumentConstructor SUCCESS");
}
else
{
System.out.println(String.format("testTowArgumentConstructor FAIL: %s != %z !", initialLocation,expectedLocation));
}
}
private boolean sameLocation(Point a, Point b) {
return a.getX() == b.getX() && a.getY() == b.getY();
}
}