mardi 18 avril 2017

Setting value in a class from enum in interfaces

I come across a difficulty in school assignment in creating a blackjack game. We are required to apply score value in a class from a face value in an interface. I figure out the way is to modify enum directly by writing Ace(1),Two(2)... but we are not allowed modify the interface. Is there any other way I can apply the value?

public interface PlayingCard

public enum Value
    Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King

public class PlayingCardImp implements PlayingCard {

    private Suit suit;
    private Value value;

    public PlayingCardImp (Value value, Suit suit)
        this.value = value;
        this.suit = suit;

    public int getScore() 
     @return the score value of this card (Ace=1, J, Q, K=10, All others int of face value)
        return 0;


0 commentaires:

Enregistrer un commentaire