Class Main

Object
Main

public class Main extends Object
Main driver class for the Game. The game has a number of program arguments, with only two that are **required** to function.
  • --data={data filename}
    data file needed for the game, contains MOBs and Fortunes
  • {save filename}
    save file needed for the game, contains knights
Both are optional, as they have default values.

Examples:

     java Main 
     java Main knights.csv
     java Main --data=data/gamedata.csv
     java Main --data=gamedata2.csv mygame.csv
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static String
    The location of the game data.
    private static String
    The location of the saved file, with a default (new game) file being knights.csv.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    main(String[] args)
    Takes in command line parameters, looks through the program arguments.
    private static void
    loops through each each program argument (args).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • gamedata

      private static String gamedata
      The location of the game data. defaults to gamedata.csv, but the --data={file} arg will reset the value
    • saveData

      private static String saveData
      The location of the saved file, with a default (new game) file being knights.csv. The first non-specific/flagged argument replaces this file.
  • Constructor Details

    • Main

      public Main()
  • Method Details

    • main

      public static void main(String[] args)
      Takes in command line parameters, looks through the program arguments. Builds the objects to run the game, and passes control over to the GameController. Example code includes
           processArgs(args); // method that parses the args, optional but cleaned up the code
           GameData data = new CSVGameData(gamedata, saveData);
           GameView view  = new ConsoleView();
           CombatEngine engine = new CombatEngine(data, view);
           GameController controller = new GameController(data, view, engine);
           controller.start();
       
      Hint: first write a loop that looks at the arguments, and then worry about processing. We also suggest getting the entire programming working first, and work on this part last.
      Parameters:
      args - the command line arguments option
    • processArgs

      private static void processArgs(String[] args)
      loops through each each program argument (args). checks to see if the argument starts with --data. If it starts with data, takes the substring of the argument (after the = sign) to set the gamedata. else, any other argument sets the saveData value (even if it has been set)
      Parameters:
      args -