Class 2 Intermediate Java 30-IT-397  

PlayerHand.java

package blackjack;

// import the necessary libraries.
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
import java.lang.*;

/**
 *
 *
 * 12/31/2001 jonesbr@email.uc.edu
 **/

public class PlayerHand extends BodyTagSupport {

 
    /**
     * method doAfterBody
     *
     * Gets the value of the dealer's up card.
     *
     * @author jonesbr@email.uc.edu
     * date December 30, 2001
     */
 
    public int doAfterBody() {
        try {
            // Get the BodyContent object to manipulate the body.
            BodyContent body = getBodyContent();

            Play parent = (Play)findAncestorWithClass(this, Play.class);
            parent.setPlayerValue(Integer.parseInt(body.getString().trim()));
            // parent.setPlayerValue(11);
 
            JspWriter out = body.getEnclosingWriter();
            out.print("Player Total: " + body.getString() + "<br>");

        } catch (Exception e) {
            System.out.println("Exception in Replace " + e);
        }
        // Let them know I'm finished.
        return(SKIP_BODY);
    }
 
// End the class.
}

 Back
 

Created by:  Brandan Jones December 17, 2001