So totally lost here....
I am writing a poker program for a college programming class. I don't want anyone to "do my homework for me" but, I am totally at a loss as to where I have gone wrong. When I instantiate the class and execute the printCard method (code below) it always returns AD.
When I run the debugger (Eclipse version 3.2 if that makes a difference) I get this error: "ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183): [../../../src/share/back/util.c:820]"
Here is the code as it currently stands:
public class Card
{
public static final byte TWO=2;
public static final byte THREE=3;
public static final byte FOUR=4;
public static final byte FIVE=5;
public static final byte SIX=6;
public static final byte SEVEN=7;
public static final byte EIGHT=8;
public static final byte NINE=9;
public static final byte TEN=10;
public static final byte JACK=11;
public static final byte QUEEN=12;
public static final byte KING=13;
public static final byte ACE=14;
public static final byte CLUB=101;
public static final byte DIAMOND =102;
public static final byte HEART=103;
public static final byte SPADE=104;
private byte value=0;
private byte suit=0;
public Card() {}
/**
* Creates an instance of Card assigning suits and values.
* @param value The value of the card created.
* @param suit The suit of the card created.
*/
public Card (byte value, byte suit)
{
this.value = value;
this.suit = suit;
}
/**
* Gets the value of the card.
* @return value The value of the card.
*/
public void setValue(int numIn)
{
switch(numIn)
{
case 0: this.value = TWO;
case 1: this.value = THREE;
case 2: this.value = FOUR;
case 3: this.value = FIVE;
case 4: this.value = SIX;
case 5: this.value = SEVEN;
case 6: this.value = EIGHT;
case 7: this.value = NINE;
case 8: this.value = TEN;
case 9: this.value = JACK;
case 10:this.value = QUEEN;
case 11:this.value = KING;
case 12:this.value = ACE;
}
}
/**
* Sets the suit of the card.
* @param suit The suit of the card.
*/
public void setSuit(int numIn)
{
switch(numIn)
{
case 0: this.suit = CLUB;
case 1: this.suit = DIAMOND;
case 2: this.suit = HEART;
case 3: this.suit = SPADE;
}
}
/**
* Prints the description of the card.
*
*/
public String getValue()
{
String val ="";
switch(this.value)
{
case TWO:val = "2";
case THREE: val = "3";
case FOUR: val = "4";
case FIVE: val = "5";
case SIX:val = "6";
case SEVEN: val = "7";
case EIGHT: val = "8";
case NINE: val = "9";
case TEN:val ="10";
case JACK: val = "J";
case QUEEN: val = "Q";
case KING: val = "K";
case ACE:val = "A";
}
return val;
}
/**
* Gets the suit of the card.
* @return suit The suit of the card.
*/
public String getSuit()
{
String tempSuit = "";
switch(this.suit)
{
case CLUB: tempSuit ="C";
case SPADE:tempSuit ="S";
case HEART:tempSuit ="H";
case DIAMOND:tempSuit ="D";
}
return tempSuit;
}
/**
* Sets the suit of the card.
* @param value The value of the card.
*/
public void printCard()
{
System.out.println(getValue()+ getSuit());
}
}
Message was edited by:
jonathan.ownbey
note: the methods and constants were required in the assignment.
Thanks for any help.

