import java.util.*;
import java.io.*;

public class FancySlotMachine extends SlotMachine {
	
	// no fields for the subclass of SlotMachine are required
	
	// constructor, just call the super class's constructor
	public FancySlotMachine (String na, int wf) {
			super(na, wf);
	}
	
	// this is the only method that needs to be different to the superclass, 
	// it overrides the one in the superclass
	public int playSlotMachine() throws IOException {
		java.io.BufferedReader stndin;
		stndin = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
		String answer = "";  // to hold the user's reply if they want to play again	
		
		// first use the superclass playSlotMachine method to do a spin
		int winnings = super.playSlotMachine();			
		while ( winnings > 0 ) {
			// double or nothing?
			// play again, double or nothing!
			System.out.println("Your current jackpot is at: " + winnings);
			System.out.println("Double or Nothing? y/n");
			answer = stndin.readLine();	
			if (answer.equalsIgnoreCase("y") ) {		
				System.out.println("Playing " + name + " for double or nothing....");
				if ( randomVal() == 0 ) {
					System.out.println("You won and doubled your jackpot!!!!");
					winnings = winnings*2; 
				} else {
					System.out.println("You lost");
					return 0;
				}
			} else { // the user doesn't want to double or nothing, didn't hit y
				return winnings;
			} // if
		}	// while
		return winnings;
	} // playSlotMachine
	
}