I'm trying to create an instance named Ball with certain characteristics that will be tested in a test harness, such as radius, location, and initialVelocity. I keep getting errors from the instance lines however. This is what i have so far. Note: This is already in a public class, but this is just a snippet of the complete code.
private static void test_ball() {
Ball a = new Ball(4,8);
radius = a.getRadius(10);
location = a.getLocation(4,8);
initialVelocity = a.initialVelocity(20,15);
System.out.println("Testing ball getlocation method...");
try {
displaySuccessIfTrue(ball.getLocation(a.x() == 4 && a.y() == 8));
} catch(Exception e) {
displaySuccessIfTrue(false);
}
System.out.println("Testing ball getRadius method...");
try {
displaySuccessIfTrue(a.getRadius() == 10);
} catch(Exception e) {
displaySuccessIfTrue(false);
}
System.out.println("Testing ball initialVelocity method...");
try {
displaySuccessIfTrue(ball.initialVelocity(a.initialVelocity.x() == 20 && a.initialVelocity.y() == 15);
} catch(Exception e) {
displaySuccessIfTrue(false);
}
}**
Aucun commentaire:
Enregistrer un commentaire