Exemplo n.º 1
0
  public void playGame() {
    displayInstructions();

    String a =
        "\033[41mAP Student\033[0m\n\t\t*Difficulty: Hard\n\t\t*7 period schedule (including lunch)\n\t\t*10 credits required to graduate\n";
    String b =
        "\033[43mHonors Student\033[0m\n\t\t*Difficulty: Medium\n\t\t*7 period schedule (including lunch)\n\t\t*6 credits required to graduate\n";
    String c =
        "\033[42mRegular Student\033[0m\n\t\t*Difficulty: Easy\n\t\t*3 period schedule\n\t\t*3 credits required to graduate\n";
    String[] student = {a, b, c};

    int numStudent = choose(student);
    if (numStudent == 1) {
      _player = new APStudent();
    } else if (numStudent == 2) {
      _player = new HonStudent();
    } else if (numStudent == 3) {
      _player = new RegStudent();
    }

    _name = ask("\nWhat is your name?");

    System.out.println(
        "\nWelcome "
            + _name
            + ". Get ready for a fun day in Stuyvesant High School :) Good luck (y)");
    Period.pause();

    // this plays the whole day
    for (int i = 1; i <= _player.scheduleLength(); i++) {
      _player.playPeriod(i);

      int earn = _player.getCreditsEarned();
      int need = _player.getCreditsNeeded();
      if (earn >= need) {
        System.out.println(
            "You have already earned enough credits ("
                + need
                + ") needed to graduate. You currently have earned "
                + earn
                + " credits.");
      } else {
        System.out.println(
            "\nYou still need "
                + (need - earn)
                + " credits to graduate. Make sure you earn them by the end of the day!\n");
      }
    }

    _player.endGame();
  }