|
|
@ -1,6 +1,39 @@ |
|
|
|
|
|
import java.util.Scanner; |
|
|
public class ShipTest{ |
|
|
public class ShipTest{ |
|
|
public testShips(Ship ship1, Ship ship2){ |
|
|
|
|
|
|
|
|
public static void testShips(Ship ship1, Ship ship2,String name){ |
|
|
|
|
|
System.out.println("Testing " + name); |
|
|
|
|
|
ship1.print(); |
|
|
|
|
|
System.out.println(); |
|
|
|
|
|
ship2.print(); |
|
|
System.out.println(ship1.intersects(ship2)+"=="+ship2.intersects(ship1)); |
|
|
System.out.println(ship1.intersects(ship2)+"=="+ship2.intersects(ship1)); |
|
|
} |
|
|
} |
|
|
public static void main(String[] args){ |
|
|
public static void main(String[] args){ |
|
|
Ship test_intersect0 = new Ship(new int[]{ |
|
|
|
|
|
|
|
|
int[] ship1start = new int[2]; |
|
|
|
|
|
int[] ship1end = new int[2]; |
|
|
|
|
|
|
|
|
|
|
|
int[] ship2start = new int[2]; |
|
|
|
|
|
int[] ship2end = new int[2]; |
|
|
|
|
|
String name; |
|
|
|
|
|
while (true) { |
|
|
|
|
|
Scanner input = new Scanner(System.in); |
|
|
|
|
|
System.out.print("Enter test name: "); |
|
|
|
|
|
name = input.nextLine(); |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Enter ship1 start: "); |
|
|
|
|
|
ship1start[0] = input.nextInt(); |
|
|
|
|
|
ship1start[1] = input.nextInt(); |
|
|
|
|
|
System.out.print("Enter ship1 end: "); |
|
|
|
|
|
ship1end[0] = input.nextInt(); |
|
|
|
|
|
ship1end[1] = input.nextInt(); |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Enter ship2 start: "); |
|
|
|
|
|
ship2start[0] = input.nextInt(); |
|
|
|
|
|
ship2start[1] = input.nextInt(); |
|
|
|
|
|
System.out.print("Enter ship2 end: "); |
|
|
|
|
|
ship2end[0] = input.nextInt(); |
|
|
|
|
|
ship2end[1] = input.nextInt(); |
|
|
|
|
|
|
|
|
|
|
|
testShips(new Ship(ship1start,ship1end),new Ship(ship2start,ship2end),name); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |