You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.3 KiB

import java.util.Scanner;
public class ShipTest{
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));
}
public static void main(String[] args){
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);
}
}
}