Skip to content

Commit 56bbd92

Browse files
committed
Added skeleton files for IA2.
1 parent d56668f commit 56bbd92

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package rp.assignments.individual.ex2;
2+
3+
import lejos.robotics.RangeFinder;
4+
import rp.config.RangeFinderDescription;
5+
import rp.robotics.DifferentialDriveRobot;
6+
import rp.systems.StoppableRunnable;
7+
8+
/**
9+
* In this class you must edit the "create*" methods to provide instances of
10+
* your controller objects in order to pass the automated tests.
11+
*
12+
*/
13+
14+
public class SolutionFactory {
15+
16+
/***
17+
* Create a controller that stays up to _maxDistance away from an obstacle.
18+
* @param _robot The robot object.
19+
* @param _desc The description of the range finder (min/max range etc.)
20+
* @param _ranger The range finder itsef
21+
* @param _maxDistance The max distance the robot should be from the obstacle detected by the range finder.
22+
* @return The controller object.
23+
*/
24+
public static StoppableRunnable createRangeController(
25+
DifferentialDriveRobot _robot, RangeFinderDescription _desc,
26+
RangeFinder _ranger, Float _maxDistance) {
27+
return null;
28+
}
29+
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package rp.assignments.individual.ex2;
2+
3+
import org.junit.runner.JUnitCore;
4+
import org.junit.runner.Result;
5+
import org.junit.runner.notification.Failure;
6+
7+
/**
8+
* This class gives an example of how to run all the tests for Individual
9+
* Exercise 2.
10+
*
11+
* @author Nick Hawes
12+
*
13+
*/
14+
15+
public class TestHarness {
16+
17+
public static void main(String[] args) {
18+
19+
JUnitCore core = new JUnitCore();
20+
// This line loads and runs the tests you have been provided with
21+
Result result = core.run(Ex2Tests.class);
22+
23+
// This prints out the results
24+
System.out.println(String.format("%d/%d tests successful",
25+
result.getRunCount() - result.getFailureCount(),
26+
result.getRunCount()));
27+
for (Failure failure : result.getFailures()) {
28+
System.out.println(failure.toString());
29+
}
30+
31+
}
32+
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package rp.assignments.individual.ex2;
2+
3+
import rp.robotics.testing.RobotTest;
4+
import rp.robotics.testing.TestViewer;
5+
6+
public class ViewTest {
7+
8+
/**
9+
* Example of how to visualise a test running
10+
*
11+
* @throws ClassNotFoundException
12+
*/
13+
@SuppressWarnings("unused")
14+
private static void visualiseTest() throws ClassNotFoundException {
15+
Ex2Tests tests = new Ex2Tests();
16+
RobotTest<?> test = tests.createSlowTest();
17+
TestViewer demo = new TestViewer(test, test.getSimulation());
18+
demo.run();
19+
}
20+
21+
public static void main(String[] args) throws ClassNotFoundException {
22+
// Visualise an IA2 test. For further examples, reuse code from
23+
// ex1.ViewTest
24+
visualiseTest();
25+
26+
}
27+
28+
}

0 commit comments

Comments
 (0)