I am having some trouble understanding how to assign values to objects. I am trying to assign it so that method handScore will return the four cards in the method. I want to make it so that Ace of hearts = 1, five of diamonds = 5, jack of clubs = 10, etc
package cards; /** * * @author Logan */ class Card { int suit, rank; public Card () { this.suit = 0; this.rank = 0; } public Card (int suit, int rank){ this.suit = suit; this.rank = rank; } public static void printCard (Card c) { String[] suits = { "Clubs", "Diamonds", "Hearts", "Spades" }; String[] ranks = { "narf", "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King" }; System.out.println (ranks[c.rank] + " of " + suits[c.suit]); } public static void buildDeck () { int index = 0; Card[] deck = new Card [52]; for (int suit = 0; suit <= 3; suit++) { for (int rank = 1; rank <= 13; rank++) { deck[index] = new Card (suit, rank); index++; } } } public static int handScore () { Card threeOfClubs = new Card (0, 3); Card aceOfHearts = new Card (3, 1); Card fiveOfDiamonds = new Card (2, 5); Card jackofHearts = new Card (3, 10); return threeOfClubs+aceOfHearts+fiveOfDiamonds+jackOfHearts; } public static void main(String[] args) { Card card = new Card (1, 11); printCard (card); } }