//********************************************************************
//Andrew Oliveros 
//Lab04.java
// Uses Coin class and Compute class
//********************************************************************

import java.io.*;

public class lab04
{
   //-----------------------------------------------------------------
   //  Toss two coins until one of them comes up heads the requisite
   //  number of times in a row.
   //-----------------------------------------------------------------
   public static void main (String[] args)
   {
      if (args.length != 1){
       System.out.println("Must input a number!");
       System.exit(1);
    }

    int numHeads = 0, numToss = 0, numTails = 0, count = 0;

    numToss = Integer.parseInt(args[0]);

      // Creates two separate coin objects
    Coin coin = new Coin();

    while (count < numToss){

      coin.toss();
         // the toString method is called by default as the object name
      System.out.println (coin);

         // Increment/reset the counters
      if(coin.isHeads()){numHeads = numHeads+1;}
      count = count + 1;
   }

      // Show Results

   System.out.println ("The number of tosses: " + numToss);
   System.out.println ("The number of heads: " + numHeads);
   numTails = (numToss - numHeads);
   System.out.println ("The number of tails: " + numTails);
   
   Compute compute = new Compute();
   compute.comp();
      

}

}

