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.

38 lines
1.3 KiB

  1. import java.util.Scanner;
  2. public class ShipTest{
  3. public static void testShips(Ship ship1, Ship ship2,String name){
  4. System.out.println("Testing " + name);
  5. ship1.print();
  6. System.out.println();
  7. ship2.print();
  8. System.out.println(ship1.intersects(ship2)+"=="+ship2.intersects(ship1));
  9. }
  10. public static void main(String[] args){
  11. int[] ship1start = new int[2];
  12. int[] ship1end = new int[2];
  13. int[] ship2start = new int[2];
  14. int[] ship2end = new int[2];
  15. String name;
  16. while (true) {
  17. Scanner input = new Scanner(System.in);
  18. System.out.print("Enter test name: ");
  19. name = input.nextLine();
  20. System.out.print("Enter ship1 start: ");
  21. ship1start[0] = input.nextInt();
  22. ship1start[1] = input.nextInt();
  23. System.out.print("Enter ship1 end: ");
  24. ship1end[0] = input.nextInt();
  25. ship1end[1] = input.nextInt();
  26. System.out.print("Enter ship2 start: ");
  27. ship2start[0] = input.nextInt();
  28. ship2start[1] = input.nextInt();
  29. System.out.print("Enter ship2 end: ");
  30. ship2end[0] = input.nextInt();
  31. ship2end[1] = input.nextInt();
  32. testShips(new Ship(ship1start,ship1end),new Ship(ship2start,ship2end),name);
  33. }
  34. }
  35. }