Share Pastebin
Guest
Public paste!

Trek.java

By: a guest | Mar 16th, 2010 | Syntax: Java | Size: 1.48 KB | Hits: 47 | Expires: Never
Copy text to clipboard
  1. /**
  2.  * Trek / Driver class of Trek 2010
  3.  * Assignment 4 - Trek.java
  4.  *
  5.  * The Trek class creates a new game by creating a new CommandProcessor
  6.  * object and calling the start() method of that object. Game begins,
  7.  * and when finished, returns to caller (Trek). This class then checks
  8.  * if the game was won or lost, and displays an appropriate sign-off
  9.  * message.
  10.  *
  11.  * Methods for use outside this class:
  12.  * - None
  13.  *
  14.  * Algorithm for Trek documented through in-line comments.
  15.  *
  16.  * Class files required:
  17.  * - Trek.java
  18.  * - Galaxy.java
  19.  * - StarShip.java
  20.  * - CommandProcessor.java
  21.  * - GameStatus.java
  22.  *
  23.  * Version 1.0 - Created March 16, 2010
  24.  *
  25.  * Name: Steven Fowler
  26.  * ID: 10044302
  27.  *
  28.  *
  29.  */
  30. public class Trek
  31. {
  32.         // Define the main method to be called by the OS at compile-time:
  33.         public static void main(String[] args)
  34.         {
  35.                 // Create a new CommandProcessor called newGame:
  36.                 CommandProcessor newGame = new CommandProcessor();
  37.                
  38.                 // Call newGame's start() method to begin playing:
  39.                 newGame.start();
  40.                
  41.                 // Determine whether the game was won or lost after game exits:
  42.                 if (newGame.currentGame.gameLost)
  43.                         System.out.println("You've lost the game. Better luck next time!");
  44.                 else if (newGame.currentGame.gameWon)
  45.                         System.out.println("Congratulations! You've won the game!");
  46.                
  47.                 // Print a sign-off message:
  48.                 System.out.println(" - Thank you for playing Trek 2010 by Steven Fowler - ");
  49.                
  50.         } // End of main()
  51.        
  52. } // End of class Trek