示例#1
0
  // Grab the number of buttons from all of the ballots in the program.
  // This will define the votes array, which stores all of the true and false values...
  // as to whether the button is really selected or not (because button.isSelected() won't work for
  // me for some reason).
  public void setVotesLength() {
    FileIO nullFile =
        new FileIO(); // need to create this just to gain access to the filename of the ballots file
    FileIO ballotsFile = new FileIO(nullFile.getBallotsFileName());
    ArrayList<Ballot> throwAwayList = ballotsFile.createBallots();
    int numButtons = 0;

    for (Ballot ballot : throwAwayList) {
      numButtons += ballot.getNumButtons();
    }

    votes = new boolean[numButtons];
  }