Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6032077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:16:50+00:00 2026-05-23T05:16:50+00:00

My card class where the method is defined. package blackjackgamemodel; public class Card {

  • 0

My card class where the method is defined.

package blackjackgamemodel;

public class Card {
    protected Rank rank;
    protected Suit suit;

    public Card(Card.Rank rank, Card.Suit suit) {
        this.rank = rank;
        this.suit = suit;
    }

    public String toString() {
        return "" + rank + " of " + suit;
    }

    public Card.Rank rank() {
        return rank;
    }

    public Card.Suit suit() {
        return suit;
    }

    public enum Rank {
        ACE (1), TWO (2), THREE (3), FOUR (4), FIVE (5), SIX (6), SEVEN (7),
        EIGHT (8), NINE (9), TEN (10), JACK (11), QUEEN (12), KING (13);

        private int value;

        Rank(int value) {
            this.value = value;
        }

        public int value() {
            return value;
        }
    }

    public enum Suit {
        SPADES, HEARTS, CLUBS, DIAMONDS
    }

}

The game class where the error is

package blackjackgamemodel;

import blackjackgamemodel.Card;
import blackjackgamemodel.Deck;

public class Game {
    protected Deck deck;
    protected int sum;
    protected int aces;


    public Game() {
        // Initialize deck, sum and aces.
        deck = new Deck();
        sum = 0;
        aces = 0;
    }

    public Card draw() {

        // Draw a card from the deck
        Card drawn_card = deck.draw();

        // Calculate the value to add to sum
        int v = drawn_card.value();
        if (v == 1) {
            v = 11;
            // If the card is an ace, increase the count of aces.
            aces++;
        }
        else if (v > 10) {
            v = 10;
        }
        // Now v is the Blackjack value of the card.

        // If the sum is greater than 21 and there are aces,
        //   Then decrease the sum by 10 and the aces by 1.
        if (aces > 0 && sum > 21) {
            sum = sum - 10;
            aces = aces - 1;
        }

        // Return the card that was drawn.
    return drawn_card; 

    }

    public int sum() {
        // Getter for sum.
        return sum;

    }
}

ERROR

Description Resource    Path    Location    Type
The method value() is undefined for the type Card   Game.java   /BlackJack/src/blackjackgamemodel   line 25 Java Problem
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:16:51+00:00Added an answer on May 23, 2026 at 5:16 am

    It’s the Card.Rank enum that has the value() method, not the Card class.

    Try:

    int v = drawn_card.rank().value()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class Card { public enum Rank { DEUCE, THREE, FOUR, FIVE, SIX, SEVEN,
class Deal implements ActionListener { public void actionPerformed(ActionEvent e) { dl.setDeck(); dl.shuffle(); dl.firstDraw(pl); for(Card
In Java, I can override the toString() method of my class. Then Java's print
I work on implementation of playing card class and i've created the following method:
Hi I have Card class... In another class I create an arrayList of Card
I have a Card class and I want to overload the > operator to
For a homework assignment I was given a Card class that has enumerated types
I am making a card game in ruby. I have the Game class, which
Given a DBIx::Class resultset, for example: my $rs = $c->model(DB::Card)->search({family_name => Smith}); the tutorials
If you do something like this in your Repository: IQueryable<CarClass> GetCars(string condition, params object[]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.