/* @(#)Methods.java 1.0 31 December 2004 */ /* Useful imports */ package FinalProject; import edu.neu.ccs.*; import edu.neu.ccs.gui.*; import edu.neu.ccs.codec.*; import edu.neu.ccs.console.*; import edu.neu.ccs.filter.*; import edu.neu.ccs.jpf.*; import edu.neu.ccs.parser.*; import edu.neu.ccs.pedagogy.*; import edu.neu.ccs.quick.*; import edu.neu.ccs.util.*; import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.awt.font.*; import java.awt.image.*; import javax.swing.*; import javax.swing.border.*; import java.io.*; import java.util.*; import java.math.*; import java.beans.*; import java.lang.reflect.*; import java.net.*; import java.util.regex.*; // import java.text.*; public class Methods extends JPF { public static void main(String[] args) { LookAndFeelTools.adjustAllDefaultFontSizes(3); new Methods(); } // displays card according to inputted rank and suit value public void TestCard(int rank, int suit) { window.clearPanel(); Card card = new Card(rank, suit); Graphics2D g = window.getBufferGraphics(); card.getPicture().paint(g); window.repaint(); } CardDeck deck = new CardDeck(); int index = 0; // displays next card in a deck public void NextCard() { window.clearPanel(); if (index >= CardDeck.decksize) { deck.shuffle(); index = 0; } Card card = deck.getCard(index++); String rank = card.getRankAsString(); String suit = card.getSuitAsString(); Graphics2D g = window.getBufferGraphics(); card.getPicture().paint(g); String s = rank + " of " + suit; TextPaintable tp = new TextPaintable (s, null, null, null, null, 10, 125); tp.paint(g); window.repaint(); } // displays a five card hand with just a high card public void HighCard() { new SingleHandDisplay( new Card[] { new Card(4, Card.DIAMONDS), new Card(10, Card.DIAMONDS), new Card(1, Card.SPADES), new Card(5, Card.DIAMONDS), new Card(3, Card.DIAMONDS) } ); } // displays a five card hand with one pair public void OnePair() { new SingleHandDisplay( new Card[] { new Card(11, Card.SPADES), new Card(11, Card.DIAMONDS), new Card(2, Card.HEARTS), new Card(1, Card.SPADES), new Card(13, Card.CLUBS) } ); } // displays a five card hand with two pair public void TwoPair() { new SingleHandDisplay( new Card[] { new Card(11, Card.SPADES), new Card(11, Card.DIAMONDS), new Card(3, Card.HEARTS), new Card(3, Card.SPADES), new Card(13, Card.CLUBS) } ); } // displays a five card hand with three of a kind public void ThreeOfAKind() { new SingleHandDisplay( new Card[] { new Card(11, Card.SPADES), new Card(11, Card.DIAMONDS), new Card(11, Card.HEARTS), new Card(3, Card.SPADES), new Card(13, Card.CLUBS) } ); } // displays a five card hand with a straight public void Straight() { new SingleHandDisplay( new Card[] { new Card(4, Card.SPADES), new Card(5, Card.DIAMONDS), new Card(6, Card.HEARTS), new Card(7, Card.SPADES), new Card(8, Card.CLUBS) } ); } // displays a five card hand with straight, ace low public void StraightAceLow() { new SingleHandDisplay( new Card[] { new Card(1, Card.SPADES), new Card(2, Card.DIAMONDS), new Card(3, Card.HEARTS), new Card(4, Card.SPADES), new Card(5, Card.CLUBS) } ); } // displays a five card hand with a flush public void Flush() { new SingleHandDisplay( new Card[] { new Card(1, Card.SPADES), new Card(11, Card.SPADES), new Card(5, Card.SPADES), new Card(2, Card.SPADES), new Card(9, Card.SPADES) } ); } // displays a five card hand with a full house public void FullHouse() { new SingleHandDisplay( new Card[] { new Card(11, Card.DIAMONDS), new Card(11, Card.HEARTS), new Card(11, Card.SPADES), new Card(3, Card.SPADES), new Card(3, Card.HEARTS) } ); } // displays a five card hand with four of a kind public void FourOfAKind() { new SingleHandDisplay( new Card[] { new Card(11, Card.DIAMONDS), new Card(11, Card.HEARTS), new Card(11, Card.SPADES), new Card(11, Card.CLUBS), new Card(3, Card.HEARTS) } ); } // displays a five card hand with a straight flush public void StraightFlush() { new SingleHandDisplay( new Card[] { new Card(10, Card.HEARTS), new Card(11, Card.HEARTS), new Card(12, Card.HEARTS), new Card(13, Card.HEARTS), new Card(1, Card.HEARTS) } ); } // displays a two player 5-card hand game public void TwoPlayerGame() { new MultiPlayerGame2(2); } // displays a three player 5-card hand game public void ThreePlayerGame() { new MultiPlayerGame2(3); } // makes sure that entering more than 10 hands(max hands to be dealt from a 52 card deck) // will not produce an error //note: method will produce a ten-person game public void ErrorCheckMaxHands() { new MultiPlayerGame2(20); } }