Question: Class MyDeck: Property of MyDeck: -cardList ArrayList Additional constructor of MyDeck: Define a constructor which accepts a LFSR as parameter and produces a deck (list

Class MyDeck: Property of MyDeck: -cardList ArrayList Additional constructor of MyDeck: Define a constructor which accepts a LFSR as parameter and produces a deck (list of objects Cards) as follows: creates a card using the register [see Card constructors] if the card is not in MyDeck, add the card at the end of the list of cards and update the register, else stop. Methods of MyDeck: +void shuffle() {} The method corresponds to the "Pile shuffle" (see https://en.wikipedia.org/wiki/Shuffling ). The method produces a random index n, with 0 Moreovr, it modifies cardList as follows: the card in position n will be the moved in position 0, the card in position n+1 will be the moved in position 1 ... and so on !! the card in position 0 will be moved to position n, card in position 1 will be moved in position n+1 and so on +ArrayList distributeCards () {} Define a method which creates a list of cards containing the first 5 cards of the deck.

In the main method of the Main Class: initialize an object lfsr of type LFSR with initialRegister [0,0,0,0,1] and coefs [1,0,1,0,0] create an object of type MyDeck using lfsr shuffle the deck of cards at leas one time create an ArrayList containing the 5 card picked by the volonteers (use the method distributeCards() of MyDeck)

Print the volonteers' card color (print them using the getColor() method) and store it into an object of type BitArray, named volonteersColors Use volonteersColors to guess the cards: re-initialize the lfsr by re-setting the register on the value volonteersColors. define an array Card[5] named guessingCards. The first card is created by using the Card constructor with BitArray parameter volonteersColors the successive 4 cards are obtained similarly, by updating the lfsr before each iteration

Check if it is correct: the elements of the list of cards created by distributedCard() should be the same as the ones in guessingCards

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!