Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// Program deals two Poker hands import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Poker2 extends Jframe { private Card deck[],hand1[],hand2[]; private int currentCard; private

// Program deals two Poker "hands"

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class Poker2 extends Jframe

{

private Card deck[],hand1[],hand2[];

private int currentCard;

private Jbutton dealButton,shuffleButton;

private JTextField handField1,handField2;

private JTextArea displayCard1,displayCard2;

private JLabel handLabel1,handlabel2,status;

private String faces[],suits[],output;

private int numbers1[],numbers2[];

private int highValue1,highValue2,group1,group2;

private boolean straightHand1,straightHand2,pair1,pair2;

private final int ONEPAIR = 2;

private final int TWOPAIR = 4;

private final int THREEKIND = 6;

private final int STRAIGHT = 8;

private final int FULLHOUSE = 10;

private final int FLUSH = 12;

private final int FOURKIND = 14;

private final int STRAIGHTFLUSH = 16;

public POKER2 ();

}

super("Card Dealing Program");

String f[] = {"Ace","Deuce","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"};

String s[] = {"Hearts","Diamonds","Clubs","Spades"};

faces = f;

suits = s;

numbers1 = new int[ 13 ] ;

numbers2 = new int[ 13 ];

hand1 = new Card [ 5 ];

hand2 = new Card [ 5 ];

deck = new Card [ 52 ];

currentCard = -1;

for (int i = 0;i

deck[i] = new Card (faces[i%13],suits[i/13]);

Container container = getContentPane();

container.setLayout(new FlowLayout());

dealButton = newJButton("Deal hand");

dealButton.addActionListner(

new ActionListner(){ // anonymous inner class

//deal hands

public void actionPerformed (ActionEvent event)

{

handfield1.setText("");

handfield2.setText("");

displayCard1.setText("");

displayCard2.setText("");

output = "";

group1 = 0;

group2 = 0;

highValue1 = 0;

highValue2 = 0;

// deal hands

for(int n = 0;n< hand1.length;n++) {

Card dealt1 = dealCard();

Card dealt2 = dealCard();

of(dealt1 != null&& dealt2 ! = null) {

hand1[n] = dealt1;

hand2[n] = dealt2;

displayCard1.setText(

displayCard1.getText()+

hand1[n].toString()+" ");

displayCard2.setText(

displayCard2.getText()+

hand2[n].toString()+" ");

}

//not enough cards to deal

else if(dealt1 ==null || dealt2 == null) {

status.setText("NOT ENOUGH CARDS.SHUFFLE DECK.");

return;

}

}

totalHand(); // calculate contents of hands

pair();

threeOfAKind();

fourOfAKind();

straight();

flush();

When I run this program,I get this error.-

Deckofcard.java:94: error: class, interface, or enum expected

straight();

^

Deckofcard.java:95: error: class, interface, or enum expected

flush();

^

44 errors

----jGRASP wedge2: exit code for process is 1.

----jGRASP: operation complete.

----jGRASP exec: javac -g Deckofcard.java

---- at: Apr 20, 2017 2:08:24 AM

----jGRASP wedge: pid for wedge is 1164.

----jGRASP wedge2: pid for wedge2 is 8560.

----jGRASP wedge2: CLASSPATH is ";.;;;C:\Program Files (x86)\jGRASP\extensions\classes".

----jGRASP wedge2: working directory is [C:\Users\Bani\Documents] platform id is 2.

----jGRASP wedge2: actual command sent ["C:\Program Files\Java\jdk1.8.0_121\bin\javac.exe" -g Deckofcard.java].

----jGRASP wedge2: pid for process is 3252.

Deckofcard.java:27: error: invalid method declaration; return type required

public POKER2 ();

^

Deckofcard.java:29: error: class, interface, or enum expected

super("Card Dealing Program");

^

Deckofcard.java:31: error: class, interface, or enum expected

String f[] = {"Ace","Deuce","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"};

^

Deckofcard.java:32: error: class, interface, or enum expected

String s[] = {"Hearts","Diamonds","Clubs","Spades"};

^

Deckofcard.java:34: error: class, interface, or enum expected

faces = f;

^

Deckofcard.java:35: error: class, interface, or enum expected

suits = s;

^

Deckofcard.java:36: error: class, interface, or enum expected

numbers1 = new int[ 13 ] ;

^

Deckofcard.java:37: error: class, interface, or enum expected

numbers2 = new int[ 13 ];

^

Deckofcard.java:38: error: class, interface, or enum expected

hand1 = new Card [ 5 ];

^

Deckofcard.java:39: error: class, interface, or enum expected

hand2 = new Card [ 5 ];

^

Deckofcard.java:40: error: class, interface, or enum expected

deck = new Card [ 52 ];

^

Deckofcard.java:41: error: class, interface, or enum expected

currentCard = -1;

^

Deckofcard.java:43: error: class, interface, or enum expected

for (int i = 0;i

^

Deckofcard.java:43: error: class, interface, or enum expected

for (int i = 0;i

^

Deckofcard.java:43: error: class, interface, or enum expected

for (int i = 0;i

^

Deckofcard.java:46: error: class, interface, or enum expected

Container container = getContentPane();

^

Deckofcard.java:47: error: class, interface, or enum expected

container.setLayout(new FlowLayout());

^

Deckofcard.java:49: error: class, interface, or enum expected

Please fix these errors and update it

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions

Question

How to defuse hostile, potentially violent employees and customers

Answered: 1 week ago

Question

=+ What are the information and consultation requirements?

Answered: 1 week ago

Question

=+ Should the MNE belong (why, why not)?

Answered: 1 week ago