Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this need to fill in the CardShoe, and pass the foloowing three testing method this is the CardShoeTest: import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; import

this need to fill in the CardShoe, and pass the foloowing three testing method

image text in transcribed

image text in transcribed

this is the CardShoeTest:

import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; import static org.junit.Assert.fail;

import java.lang.reflect.Field; import java.util.List;

import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout;

import edu.buffalo.correctness.Scorable;

/* * Homework test cases
* (C) 2018 by Matthew Hertz
* Posting this file to a website without the explicit written permission of the author is a violation of their * copyright. */ @Scorable(problem = "Homework07Problem1") public class CardShoeTest { @Test public final void testOneDeckCutAtTwelve() throws Exception { String[] oneCut = { "AC", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "TD", "JD", "QD", "KD", "AD", "2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "TH", "JH", "QH", "KH", "AH", "2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "TS", "JS", "QS", "KS", "AS", "2C", "3C", "4C", "5C", "6C", "7C", "8C", "9C", "TC", "JC", "QC", "KC" }; testee.cutDeck(12); Object newCards = cards.get(testee); assertSame("cutDeck(12) should not allocate a new List for the cards field.", testeeDecks, newCards); assertEquals("cutDeck(12) should not change the number of elements in cards when called with a complete deck of 52 cards", 52, testeeDecks.size()); for (int i = 0; i

@Test public final void testOneDeckCutAtFourty() throws Exception { String[] oneCut = { "3S", "4S", "5S", "6S", "7S", "8S", "9S", "TS", "JS", "QS", "KS", "AS", "2C", "3C", "4C", "5C", "6C", "7C", "8C", "9C", "TC", "JC", "QC", "KC", "AC", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "TD", "JD", "QD", "KD", "AD", "2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "TH", "JH", "QH", "KH", "AH", "2S" }; testee.cutDeck(40); Object newCards = cards.get(testee); assertSame("cutDeck(40) should not allocate a new List for the cards field.", testeeDecks, newCards); assertEquals("cutDeck(40) should not change the number of elements in cards when called with a complete deck of 52 cards", 52, testeeDecks.size()); for (int i = 0; i

@Test public final void testMultiDeckCutAtOneThirtyThree() throws Exception { String[] oneCut = { "5H", "6H", "7H", "8H", "9H", "TH", "JH", "QH", "KH", "AH", "2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "TS", "JS", "QS", "KS", "AS", "2C", "3C", "4C", "5C", "6C", "7C", "8C", "9C", "TC", "JC", "QC", "KC", "AC", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "TD", "JD", "QD", "KD", "AD", "2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "TH", "JH", "QH", "KH", "AH", "2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "TS", "JS", "QS", "KS", "AS", "2C", "3C", "4C", "5C", "6C", "7C", "8C", "9C", "TC", "JC", "QC", "KC", "AC", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "TD", "JD", "QD", "KD", "AD", "2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "TH", "JH", "QH", "KH", "AH", "2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "TS", "JS", "QS", "KS", "AS", "2C", "3C", "4C", "5C", "6C", "7C", "8C", "9C", "TC", "JC", "QC", "KC", "AC", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "TD", "JD", "QD", "KD", "AD", "2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "TH", "JH", "QH", "KH", "AH", "2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "TS", "JS", "QS", "KS", "AS", "2C", "3C", "4C", "5C", "6C", "7C", "8C", "9C", "TC", "JC", "QC", "KC", "AC", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "TD", "JD", "QD", "KD", "AD", "2H", "3H", "4H" }; testeeToo.cutDeck(133); Object newCards = cards.get(testee); assertSame("cutDeck(133) should not allocate a new List for the cards field when cards had 208 elements.", testeeDecks, newCards); assertEquals("cutDeck(133) should not change the number of elements in cards when called with a 4 complete decks (so the size of cards was 208)", 208, testeeTooDecks.size()); for (int i = 0; i

private Field cards; private CardShoe testee; private List testeeDecks; private CardShoe testeeToo; private List testeeTooDecks; private ListGenerator listGen;

@Before public final void checkFieldsUnchanged() { Class> shoe = CardShoe.class; Field[] fields = shoe.getDeclaredFields(); assertEquals("You should not add any fields to the CardShoe class. This class's field count:", 1, fields.length); try { cards = shoe.getDeclaredField("cards"); assertEquals("The cards field should be of type List", List.class, cards.getType()); cards.setAccessible(true); } catch (Exception e) { fail("Your CardShoe class should still define a field named \"cards\""); } listGen = new ListGenerator(); testeeDecks = listGen.createNewList(); PlayingCard[] decks = PlayingCard.generate(1); for (PlayingCard p : decks) { testeeDecks.add(p); } testee = new CardShoe(testeeDecks); testeeTooDecks = listGen.createNewList(); PlayingCard[] decksToo = PlayingCard.generate(4); for (PlayingCard p : decksToo) { testeeTooDecks.add(p); } testeeToo = new CardShoe(testeeTooDecks); } }

this is the list generator:

// Method descriptor #6 ()V // Stack: 1, Locals: 1 public ListGenerator(); 0 aload_0 [this] 1 invokespecial java.lang.Object() [8] 4 return Line numbers: [pc: 0, line: 13] Local variable table: [pc: 0, pc: 5] local: this index: 0 type: edu.buffalo.cse116.ListGenerator // Method descriptor #15 ()Ljava/util/List; // Signature: ()Ljava/util/List; // Stack: 2, Locals: 2 public java.util.List createNewList(); 0 new java.util.Random [18] 3 dup 4 invokespecial java.util.Random() [20] 7 astore_1 [rnd] 8 aload_1 [rnd] 9 invokevirtual java.util.Random.nextBoolean() : boolean [21] 12 ifeq 23 15 new java.util.ArrayList [25] 18 dup 19 invokespecial java.util.ArrayList() [27] 22 areturn 23 new java.util.LinkedList [28] 26 dup 27 invokespecial java.util.LinkedList() [30] 30 areturn Line numbers: [pc: 0, line: 20] [pc: 8, line: 21] [pc: 15, line: 22] [pc: 23, line: 24] Local variable table: [pc: 0, pc: 31] local: this index: 0 type: edu.buffalo.cse116.ListGenerator [pc: 8, pc: 31] local: rnd index: 1 type: java.util.Random Stack map table: number of frames 1 [pc: 23, append: {java.util.Random}] }

this is the playing card class:

public class PlayingCard { public enum Suits { CLUBS, DIAMONDS, HEARTS, SPADES;

@Override public String toString() { return name().substring(0, 1); } }

public enum Ranks { TWO("2"), THREE("3"), FOUR("4"), FIVE("5"), SIX("6"), SEVEN("7"), EIGHT("8"), NINE("9"), TEN("T"), JACK("J"), QUEEN("Q"), KING("K"), ACE("A"); private String display;

private Ranks(String s) { display = s; }

@Override public String toString() { return display; } }

private Suits suit; private Ranks value;

public PlayingCard(Suits s, Ranks r) { suit = s; value = r; }

public Suits getSuit() { return suit; }

public Ranks getValue() { return value; }

@Override public String toString() { return value.toString() + suit.toString(); }

public static PlayingCard[] generate(int numDecks) { int length = numDecks * Suits.values().length * Ranks.values().length; PlayingCard[] retVal = new PlayingCard[length]; int idx = 0; for (int i = 0; i Problem #1-Card Decks Download this file that represents the holder used when playing card games. You will also need to download the JAR file which contains the support classes for your class and JUnit test cases used to grade your solution. As is appropriate, Cardace stores the playing cards in a List. You will need to complete two methods for the cazdShae Class: Thea method by implementing the following algorithm: love the tirat halt ot card inta firstia This ay or may not be done in one ine of code oe rnning eeuents in carts into seconatir&This way or may not be don in one line of code in fi* Ret at the tart of firsad. add it to ar Reave thent at the start of secona and add it to carts th- eleaent Recve th 1eant at the start of sndaand add It tc card Endl cut DeckO does the last step of shuffling cutting the deck. This should move the first cuticcati o number of cards (first' meaning at the lowest index) from cards and add them to the back of the List. Make certain that you add cards in the same (relative) order that they were originally stored. You can see the tests and check most of your solution using the CardoeTest class in the JAR file. The test cases that check that sutis correctly implemented are only on AutoLab, so you will want to test this code on your own Problem #1-Card Decks Download this file that represents the holder used when playing card games. You will also need to download the JAR file which contains the support classes for your class and JUnit test cases used to grade your solution. As is appropriate, Cardace stores the playing cards in a List. You will need to complete two methods for the cazdShae Class: Thea method by implementing the following algorithm: love the tirat halt ot card inta firstia This ay or may not be done in one ine of code oe rnning eeuents in carts into seconatir&This way or may not be don in one line of code in fi* Ret at the tart of firsad. add it to ar Reave thent at the start of secona and add it to carts th- eleaent Recve th 1eant at the start of sndaand add It tc card Endl cut DeckO does the last step of shuffling cutting the deck. This should move the first cuticcati o number of cards (first' meaning at the lowest index) from cards and add them to the back of the List. Make certain that you add cards in the same (relative) order that they were originally stored. You can see the tests and check most of your solution using the CardoeTest class in the JAR file. The test cases that check that sutis correctly implemented are only on AutoLab, so you will want to test this code on your own

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What challenges do managers face in motivating todays workforce?

Answered: 1 week ago

Question

How do you determine the load-bearing capacity of a soil?

Answered: 1 week ago

Question

what is Edward Lemieux effect / Anomeric effect ?

Answered: 1 week ago

Question

Define Management by exception

Answered: 1 week ago

Question

Explain the importance of staffing in business organisations

Answered: 1 week ago

Question

Describe how to train managers to coach employees. page 404

Answered: 1 week ago

Question

Discuss the steps in the development planning process. page 381

Answered: 1 week ago