// This is a simple card game applet. There are two players, // specified as PARAMs, Player1 and Player2. Each is dealt three // cards when the deal button is hit. To view the cards, hit the // show button. The scores are kept below where the cards are // displayed. // // Jason Duncan // ID 1687253 import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class CardGame extends Applet implements ActionListener { final static int CARDSDEALT=6; //Number of cards to deal each round final static int NUMCARDS=52; //Number of cards in the deck String player1; //The players names String player2; int score1=0; //The players scores int score2=0; int card[]; //Array used for duplicate cards dealt checking TextField txtScore2; //Textboxes to hold players' scores TextField txtScore1; Button cmdDeal; //Buttons Button cmdShow; Button cmdReset; Image[] cardFront; //Array of Card Images Image cardBack; //Cardback image ImageCanvas[] cardCanvas; //Canvas used to display card images public void init() { // Get Parameters player1=getParameter("Player1"); if (player1 == null) { player1="Player 1"; } player2= getParameter("Player2"); if (player2 == null) { player2="Player 2"; } // Load Images cardFront = new Image[NUMCARDS]; card = new int[CARDSDEALT]; for(int i=0;i 0) && (w!= imageWidth)) || ((imageHeight>0) && (h!=imageHeight))) { w = imageWidth; h = imageHeight; size = new Dimension(w,h); setSize(w,h); pappy.validate(); } } } g.drawImage(image,0,0,this); g.drawRect(0,0,w-1,h-1); } public void setImage(Image image) { this.image=image; this.repaint(); } }