Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

BlackJack.java

//Name - Isaiah Roman
//Date: 4-9-19

import static java.lang.System.*;
public class CardRunner {

    public static void main(String[] args) {
        TreeSet<Card> ss = new TreeSet<>();

        ss.add(new BlackJackCard("two", Suit.Club));
        ss.add(new BlackJackCard("five", Suit.Spade));
        ss.add(new BlackJackCard("king", Suit.Heart));
        ss.add(new BlackJackCard("jack", Suit.Diamond));
        ss.add(new BlackJackCard("ace", Suit.Spade));

        for (Card c : ss) {
            // System.out.println(c);
        }


class BlackJackCard extends Card {
	
	public BlackJackCard (int s, int v) {
		super(s, v);
		suit = s;
		value = v;
	}
	
	public BlackJackCard(String s, String val){
		super(s, val);
	}
	
	public int getValue() {
		if (value == 10) {
			return  10;
		}
		else if (value == 11) {
			return 10;
		}
		else if (value == 12) {
			return 10;
		}
		else if (value == 13) {
			return 10;
		}
		else {
			return value;
		}
	}
}	
	

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.