public class Blackjack {
    
    public static void main ( String[] args ) {

	int  dscore, pscore;
	Deck deck = new Deck();
	/*------------------------------------------------------
	  (1) change these to use your player instead of the
	  generic class Player
	  ----------------------------------------------------*/
	Player dealer = new Player( deck );
	Player player = new Player( deck );

	// opening moves
	player.hitMe();
	dealer.hitMe();
	player.hitMe();
	dealer.hitMe();

	// deal to your player until you win or stand
	System.out.println( "PLAYER: " );
	System.out.println( player.toString() );
	player.play();
	System.out.println();

	// deal to dealer until win or stand
	System.out.println( "DEALER: " );
	System.out.println( dealer.toString() );
	dealer.play();
	System.out.println();

	// report results of the round
	if ( player.getScore() == 21 ) {
	    if ( dealer.getScore() == 21 ) {
		System.out.println( "you both have blackjack "+
				    "--> it's a tie!" );
	    }
	    else if ( dealer.getScore() > 21 ) {
		System.out.println( "you have blackjack; "+
				    "the dealer has gone bust "+
				    "--> you win!" );
	    }
	    else {
		System.out.println( "you have blackjack; "+
				    "the dealer has "+dealer.getScore()+" "+
				    "--> you win!" );
	    }
	}
	else if ( player.getScore() > 21 ) {
	    if ( dealer.getScore() == 21 ) {
		System.out.println( "you have gone bust; "+
				    "the dealer has blackjack "+
				    "--> the dealer wins!" );
	    }
	    else if ( dealer.getScore() > 21 ) {
		System.out.println( "you have gone bust; "+
				    "the dealer has gone bust "+
				    "--> nobody wins!" );
	    }
	    else {
		System.out.println( "you have gone bust; "+
				    "the dealer has "+dealer.getScore()+" "+
				    "--> the dealer wins!" );
	    }
	}
	else {
	    if ( dealer.getScore() == 21 ) {
		System.out.println( "you have "+player.getScore()+"; "+
				    "the dealer has blackjack "+
				    "--> the dealer wins!" );
	    }
	    else if ( dealer.getScore() > 21 ) {
		System.out.println( "you have "+player.getScore()+"; "+
				    "the dealer has gone bust "+
				    "--> you win!" );
	    }
	    else {
		System.out.print( "you have "+player.getScore()+"; "+
				  "the dealer has "+dealer.getScore()+" " );
		pscore = 21 - player.getScore();
		dscore = 21 - dealer.getScore();
		if ( pscore == dscore ) {
		    System.out.println( "--> it's a tie!" );
		}
		else if ( pscore < dscore ) {
		    System.out.println( "--> you win!" );
		}
		else {
		    System.out.println( "--> the dealer wins!" );
		}
	    }
	}

	// done!
	System.out.println();
	System.exit( 0 );
	    
    } // end of main()
    
} // end of class Blackjack
