/** * File: PokerChip.java * Author: Robert Banagale * Last Modified: March 2001 * Description: This file contains Information about the Poker Chip object. */ import java.awt.*; import javax.swing.*; public class PokerChip extends JPanel { private static final int RED = 1; // Chip Color Identifiers. private static final int BLUE = 2; private static final int GREEN = 3; private static final int COMP = 4; private static final int EMPTY = 0; // Non-existant chip. private static final int ZERO_VALUE = 0; // Non-existant chip. private static final int CHIPWIDTH = 70; private static final int CHIPHEIGHT = 70; public int chipValue; // The Chip's Value public int chipColor; // The Chip's Color public void setChipColor(int passedInColor) // Sets a chip's Color { this.chipColor = passedInColor; } // setChipType(1) public void setChipValue(int passedInValue) // Sets a chip's Value { this.chipValue = passedInValue; } // setChipValue(1) public int getChipColor() // Accesses a chip's Color { return this.chipColor; } // getChipColor() public int getChipValue() // Accesses a chip's Value { return this.chipValue; } // getChipValue() public void paintComponent(Graphics g) // Painting method { super.paintComponent(g); g.setColor(Color.black); // Give the Chip a Border g.fillOval(9,1,(CHIPWIDTH + 2),(CHIPHEIGHT + 2)); if (this.getChipColor() == RED) // Check and Set Chip Color g.setColor(Color.red); if (this.getChipColor() == BLUE) g.setColor(Color.blue); if (this.getChipColor() == GREEN) g.setColor(Color.green); if (this.getChipColor() == EMPTY) g.setColor(Color.gray); g.fillOval(10,2,CHIPWIDTH,CHIPHEIGHT); // Draw the Chip g.setColor(Color.black); if (this.getChipValue() != ZERO_VALUE) // Draw the Chip's value. g.drawString(Integer.toString(this.getChipValue()),33,43); } } // PokerChip.java