/**
 * An example using HighScore objects.
 *
 * @author Zach Tomaszewski
 */
public class ArcadeGame {

  public static void main(String[] args) {

    // Two possible ways to create a HighScore object
    HighScore first = new HighScore("ZMT", 500);
    HighScore second = new HighScore("AAA");  //score will equal 0

    // Aracade game logic here.  :)
    int score = (int) (Math.random() * 1000) + 1;  // 1 to 1000

    java.util.Scanner keybd = new java.util.Scanner(System.in);
    System.out.println("You won!");
    System.out.print("Enter your initials: ");
    HighScore user = new HighScore(keybd.nextLine());

    // can set the score using mutator method
    user.setScore(score);

    //
    // Note how these things are now impossible due to encapsulation:
    //
    // user.score = -100;   //can't access private instance variable directly
    // user.setScore(-100); //setScore method will set this to 0
    // user.setName("ME");  //no set method written for name
    // user.name = "ME";    //again, can't access instance variable directly
    //
    // Thus, encapsulation lets HighScore enforce its two rules:
    // * You can't have a negative score
    // * You can't change the name once the HighScore object is created
    //

    System.out.println();
    System.out.println("SCORES:");

    // You can still access details with accessor methods
    if (user.getScore() > first.getScore()) {
      // Printing is easier with toString()
      // (though could use get methods to print details in different format)
      System.out.println(user.toString());
      System.out.println(first.toString());
    }else {
      // Actually, since every Object in Java has a toString() method,
      // println will call it for us.  So this works too:
      System.out.println(first);
      System.out.println(user);
    }
    System.out.println(second);
  }
}