/**
 * Counting methods for PA2: Fairly Odd Election.
 *
 * @author YOUR NAME HERE
 * @version DUE DATE HERE
 */
public class OddElectionPA2 {


   /**
    * isValidElection checks that all parms are non-negative.
    * @param voteCounts array of vote counts
    * @return true if the array and counts are valid, false otherwise.
    */
   public static boolean isValidElection(int[] voteCounts) {
      return false; // PROTOTYPE, remove this line 
   }  
   
 
   /**
    * Popular vote.
    * @param voteCounts array of vote counts
    * @return candidate that wins or -1 if error or tie
    */
     
   public static int countPopular(int[] voteCounts) {
      return -1; // PROTOTYPE, remove this line 
   }
  
   /**
    * Majority vote.
    * @param voteCounts array of vote counts
    * @return candidate that wins more than 50% or -1
    */
   
   public static int countMajority(int[] voteCounts) {
      return -1; // PROTOTYPE, remove this line
   }

    
   /**
    * countOdd.  Modified vote counts with oddVoteCountMod
    * and determine the winner by popular vote.
    *
    * @param voteCounts array of vote counts
    * @return candidate number of the winner or -1
    */    
   public static int countOdd(int[] voteCounts) {
      return -1; // PROTOTYPE, remove this line
        
   }
   
   /**
    * countVotes.  
    * Process the strings in the votes array extracting the 
    * candidate number and incrementing a tally for each 
    * candidate.
    * If a vote is for an invalid candidiate, discard
    * the vote.
    * @param votes The voting strings
    * @param candidateCount the number of candidates
    * @return an array that has the vote counts for each candidate.
    *        
    */    
   
   public static int[] countVotes(String[] votes, int candidateCount) {
      return null; // PROTOTYPE, remove this line 
   }
      
   /**
    * addVotes.  
    * Add votesToAdd to sumVotes.  The method can assume
    * that the 2 arrays are of equal size. 
    * @param sumVotes array to add to
    * @param votesToAdd add each value to their corresponding element
    *        in sumVotes
    *        
    */    
    
   public static void addVotes(int[] sumVotes, int[] votesToAdd) {
      // PROTOTYPE, MUST COMPLETE
   }
   
   /**
    * processVoteFiles.  Validate the number of entries
    * in the array (if less than 2, return null). Validate the number of 
    * candidates (first element in args) is valid (positive integer > 0).
    * If it is invalid, return null.
    * Process all remaining arguments as voting file names.
    *
    * @param args command line arguments.
    * @return an array that has the vote counts for ALL processed
    *         voting files.
    */    
   
   public static int[] processVoteFiles(String[] args) {
      return null; // PROTOTYPE, remove this line 
   }



   /**
    * main.  Call methods to read in votes and
    * perform all types of elections.
    *
    * @param args command line arguments
    */    
   
   public static void main(String[] args) {
      int[] voteCounts = processVoteFiles(args);
      
      if (voteCounts == null) {
         System.out.printf("invalid command line arguments\n");
         System.out.printf("usage:java OddElectionPA2 [nbr of candidates]");
         System.out.printf(" [voting files...]\n");
      } else {
         System.out.printf("The winner of the popular vote is: %d\n",
            countPopular(voteCounts));
         System.out.printf("The winner of the absolute majority vote is: %d\n",
            countMajority(voteCounts));
         System.out.printf("The winner of the count odd vote is: %d\n",
            countOdd(voteCounts));
            
      }
   }   
}
