Hey guys i'm in a bit of a pickle.
I am quite new to Java programming but I am capable of basic tasks. I'm creating a CardGuessing game which includes 3 classes; Game,Pack and Card. In the Card class I have 2 attributes which hold the card's suit and value. Within this class I have several methods that do different things.
I am not sure how I can implement the compareSuit and value method. Any advice would help.
Although I wouldn't like to, I have posted the class Card as so if anyone can help, the rest of the code might help. Thanks.
public class Card { private char suit; // The suit of the card (C,D,H,S) private char value; // The value of the card (A,2,3...10,J,Q,K) private String SuitName; // The suit's name(eg, "Heart") private String ValueName; // The Value's name (eg, "ace") /** * Constructor for objects of class Card * Creates a Card object with the parameter values as attribute values */ Card(char suit, char value) { this.suit = suit; this.value = value; } /** * Grabs the required char attribute from value. * * @return Value of the Card */ public char getValue() { return value; } /** * Grabs the required char attribute from suit. * * @return Suit of the Card */ public char getSuit() { return suit; } /** * Sets/changes the value of the Card. * * @param char value Asks for the attribute in value as a character */ public void setValue(char value) { this.value = value; } /** *Sets/changes the suit of the Card. * * @param char suit Asks for the attribute in suit as a character */ public void setSuit(char suit) { this.suit = suit; } /** *This method returns the suit of the Card as a String. * (eg "Diamond") * @return The suit of the Card as a String. */ public String getSuitName() { if(suit == 'C') { this.SuitName = "Clubs"; } else if(suit == 'D') { this.SuitName = "Diamonds"; } else if(suit == 'H') { this.SuitName = "Hearts"; } else if(suit == 'S') { this.SuitName = "Spades"; } return SuitName; } ] /** * This method returns the value of the Card as a Sting * (eg "King" or "6") * @return The value of the Card as a String. */ public String getValueName() { if(value == 'A') { this.ValueName = "Ace"; } else if(value == 'J') { this.ValueName = "Jack"; } else if(value == 'Q') { this.ValueName = "Queen"; } else if(value == 'K') { this.ValueName = "King"; } return ValueName; } /** * Returns - 1 if anotherCard's suit is before, 0 if equal to and +1 if after. * The order is 'C','D','H','S'. * * @param char anotherCardsSuit * @return */ public int compareSuit(char anotherCardsSuit) { } public int compareValue(char anotherCardsValue) { return value; } /** * * @param Card anotherCard * @return True if the Cards have the same suit and value; * false otherwise */ public boolean equals(Card anotherCard) { return true; }