Package com.luxoft.dnepr.courses.unit3

Examples of com.luxoft.dnepr.courses.unit3.BlackJack


    public void play() {
        output.println("Console Blackjack application.\n" +
                "Author: Andrii Martyniuk\n" +
                "(C) Luxoft 2013\n");

        GameController controller = GameController.getInstance();

        controller.newGame();

        output.println();
        printState(controller);

        while (scanner.hasNext()) {
View Full Code Here


    public void play() {
        output.println("Console Blackjack application.\n" +
                "Author: Daria Shcherbyna & cat Yuki\n" +
                "(C) Luxoft 2013\n");

        GameController controller = GameController.getInstance();

        controller.newGame();

        output.println();
        printState(controller);

        while (scanner.hasNext()) {
View Full Code Here

    @Test
    public void testCostOf() {
        List<Card> cards = new ArrayList<Card>(Arrays.asList(
                //He may play the jack of diamonds
                new Card(Rank.RANK_JACK, Suit.DIAMONDS),
                //He may lay the queen of spades
                new Card(Rank.RANK_QUEEN, Suit.SPADES),
                //He may conceal a king in his hand
                //While the memory of it fades
                new Card(Rank.RANK_KING, Suit.CLUBS)
        ));
        assertEquals(30, Deck.costOf(cards));
        cards.add(new Card(Rank.RANK_6, Suit.DIAMONDS));
        assertEquals(36, Deck.costOf(cards));
    }
View Full Code Here

    public void testRequestMore() {
        GameController.getInstance().newGame(new Shuffler() {

            @Override
            public void shuffle(List<Card> deck) {
                deck.set(0, new Card(Rank.RANK_10, Suit.SPADES));
                deck.set(1, new Card(Rank.RANK_ACE, Suit.SPADES));
                deck.set(2, new Card(Rank.RANK_JACK, Suit.SPADES));

                deck.set(3, new Card(Rank.RANK_6, Suit.DIAMONDS));

            }

        });
        assertEquals(GameController.getInstance().getMyHand().size(), 2);
View Full Code Here

    public void testRequestStop() {
        GameController.getInstance().newGame(new Shuffler() {

            @Override
            public void shuffle(List<Card> deck) {
                deck.set(0, new Card(Rank.RANK_10, Suit.CLUBS));
                deck.set(1, new Card(Rank.RANK_KING, Suit.DIAMONDS));
                deck.set(2, new Card(Rank.RANK_ACE, Suit.SPADES));
                deck.set(3, new Card(Rank.RANK_4, Suit.DIAMONDS));
                deck.set(4, new Card(Rank.RANK_4, Suit.SPADES));
            }

        });
        GameController.getInstance().requestStop();
        assertEquals(GameController.getInstance().getDealersHand().size(), 3);
View Full Code Here

    public void testRequestStopUserLoose() {
        GameController.getInstance().newGame(new Shuffler() {

            @Override
            public void shuffle(List<Card> deck) {
                deck.set(0, new Card(Rank.RANK_10, Suit.CLUBS));
                deck.set(1, new Card(Rank.RANK_8, Suit.DIAMONDS));
                deck.set(2, new Card(Rank.RANK_ACE, Suit.SPADES));
                deck.set(3, new Card(Rank.RANK_4, Suit.DIAMONDS));
                deck.set(4, new Card(Rank.RANK_4, Suit.SPADES));
            }

        });
        GameController.getInstance().requestStop();
        assertEquals(GameController.getInstance().getDealersHand().size(), 3);
View Full Code Here

    public void testRequestStopPushState() {
        GameController.getInstance().newGame(new Shuffler() {

            @Override
            public void shuffle(List<Card> deck) {
                deck.set(0, new Card(Rank.RANK_10, Suit.CLUBS));
                deck.set(1, new Card(Rank.RANK_9, Suit.DIAMONDS));
                deck.set(2, new Card(Rank.RANK_ACE, Suit.SPADES));
                deck.set(3, new Card(Rank.RANK_4, Suit.DIAMONDS));
                deck.set(4, new Card(Rank.RANK_4, Suit.SPADES));
            }

        });
        GameController.getInstance().requestStop();
        assertEquals(GameController.getInstance().getDealersHand().size(), 3);
View Full Code Here

        }
        List<Card> deck = new ArrayList<Card>();
        for (int i = 0; i < size; i++) {
            for (Suit suit : Suit.values()) {
                for (Rank rank : Rank.values()) {
                    deck.add(new Card(rank, suit));
                }
            }
        }
        return deck;
    }
View Full Code Here

        size = size < 1 ? 1 : (size > 10 ? 10 : size);
        ArrayList<Card> wholeDeck = new ArrayList<Card>();
        for (int deckNumber = 0; deckNumber < size; deckNumber++)
            for (Suit suit : Suit.values())
                for (Rank rank : Rank.values()) {
                    wholeDeck.add(new Card(rank, suit));
                }
        return wholeDeck;
    }
View Full Code Here

        myHand.add(giveCard(deck));
        dealersHand.add(giveCard(deck));
    }

    private Card giveCard(List<Card> deck) {
        Card nextCard = deck.get(0);
        deck.remove(0);
        return nextCard;
    }
View Full Code Here

TOP

Related Classes of com.luxoft.dnepr.courses.unit3.BlackJack

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.