// SpaceshipTester: tests your implementation of the Spaceship class
// Author: Kiri Wagstaff
// Date: July 7, 2001
// ----- Do not modify! ------

public class SpaceshipTester
{
    // Main method: provides a means to test your implementation
    // of the Spaceship methods.
    public static void main(String args[])
    {
		// Create a new spaceship.	
		// The ship starts out at position (5,5) with a full fuel tank.
		Spaceship enterprise = new Spaceship(5, 5);

		/**************************************************
		 * This will work when you have implemented
		 * getLocation() and getFuel().
		 **************************************************/
		// Check the stats.
		enterprise.displayStats();

		/**************************************************
	 	 * This will work when you have also implemented
	 	 * move().
	 	 **************************************************/
		// Move 3 to the right and 4 down:
		System.out.println("Moving 3 right and 4 down:");
		enterprise.move(3, 4);
		// Check the stats.
		enterprise.displayStats();
	
		// Try an invalid move.
		System.out.println("Moving 3 right and 4 down, again:");
		int success = enterprise.move(3, 4);
		switch (success)
    {
		case 0:
	  	System.out.println("It worked!  (But it shouldn't have.)");
	    break;
		case 1:
	    System.out.println("It failed, as expected (out of range).");
	    break;
		case 2:
	    System.out.println("It failed, due to lack of fuel??");
	    break;
		default:
	    System.out.println("Invalid return value from move(): " +
									       success);
		}
		// Check the stats.
		enterprise.displayStats();

		/**************************************************
	 	 * This will work when you have also implemented
	 	 * refuel().
	 	 **************************************************/
		// Attempt to fill the tank.
		System.out.print("Attempting to refuel...  ");
		success = enterprise.refuel();
		if (success == 0)
		{
	    System.out.println("It worked! (even though we aren't at Earth??)");
		}
		else
		{
	    System.out.println("It failed; not at Earth.");
		}
		System.out.println();

		/**************************************************
		 * This will work when you have also implemented
	 	 * hyperjump().
		 **************************************************/
		// Hyperjump to position (1,1)
		System.out.println("Jumping through hyperspace to (1,1):");
		success = enterprise.hyperjump(1, 1);
		switch (success)
  	{
		case 0:
	    System.out.println("It worked!");
	    break;
		case 1:
	    System.out.println("It failed (out of range)??");
	    break;
		case 2:
	    System.out.println("It failed, due to lack of fuel??");
	    break;
		default:
	    System.out.println("Invalid return value from hyperjump(): " +
			       success);
		}
		// Check the stats.
		enterprise.displayStats();

		/**************************************************
	 	 * This will work when you have also implemented
	 	 * refuel().
	 	 **************************************************/
		// Attempt to fill the tank.
		System.out.print("Attempting to refuel...  ");
		success = enterprise.refuel();
		if (success == 0)
		{
	    System.out.println("It worked!");
		}
		else
		{
	    System.out.println("It failed (why??)");
		}
		System.out.println();

		// Check the stats.
		enterprise.displayStats();
	
		/**************************************************
	   * BONUS POINT 1:
	 	 * Test sendMessage().
	 	 **************************************************/
		// ------ To test your code, uncomment starting here --------- // 
		/*
		// Declare some more ships, one at (2,2) and one at (6,5)
		Spaceship pegasus = new Spaceship(2, 2);
		Spaceship heartOfGold = new Spaceship(6, 5);
		pegasus.displayStats();
		heartOfGold.displayStats();
		// See if they can communicate
		int msgSent = pegasus.sendMessage(heartOfGold, "Hello out there!");
		if (msgSent == 0)
		{
			System.out.println("Message sent successfully.. but the ships are too far apart for that!");
		}
		else
		{
			System.out.println("Ships too far apart to communicate.");
		}
		// Move heartOfGold closer to pegasus
		heartOfGold.move(-4, -2);
		heartOfGold.displayStats();
		// Try to communicate again
		msgSent = pegasus.sendMessage(heartOfGold, "Hello again?");
		if (msgSent == 0)
		{
		 	System.out.println("Message sent successfully!");
		}
		else
		{
			System.out.println("Communication failed... but it shouldn't have.");
		}
	*/
	// ------------ And stop uncommenting here ------------- //	
	
	}
}
