#Java Issues

16 messages · Page 1 of 1 (latest)

heavy orbit
#

I am currently working on a project for Java, but whenever I try and compile the program I am given this error message:

./PokerHand.java:38: error: incompatible types: Card cannot be converted to int
this.cards[i] = new Card(cards[i]);
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error

The problem is I am unable to change this section of the code as the professor gave it to me and told me NOT to change it. The only methods I can change are the following hasFlush(), hasFourOfAKind(), hasFullHouse(), hasThreeOfAKind(), hasTwoPair(), hasOnePair().

Below is the code I am working with.

calm falconBOT
#

This post has been reserved for your question.

Hey @heavy orbit! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

viral plume
#

I would like to see it's constructors

heavy orbit
viral plume
#

yea that code is just broken

#

(specifically the line thats erroring)

#

Ill need to look at the source a bit more to figure out what it's supposed to do

#

but right now its tring to make a card with a card instead of a suit and number

#

it looks like its supposed to be = new Card(cards[i].getFace(), cards[i].getSuit())

#

or just this.cards[i] = cards[i]

#

what is numcards even usd for

#

I dont understand why not just java // For testing of scoreHand method, can be handy // to set fixed hand public PokerHand(DeckOfCards deck, Card[] cards) { this.deck = deck; this.cards = cards; scoreHand(); }

#

itd have the same effect afaik

heavy orbit
#

Ohh okay, I think I'll bring it up to my prof and let them know if it's just a file issue or smth