Question: 2) Create a class called MyBag in the bag package that implements the Bag interface. public interface Bag extends Iterable { public boolean is Empty

 2) Create a class called MyBag in the bag package that

2) Create a class called MyBag in the bag package that implements the Bag interface. public interface Bag extends Iterable { public boolean is Empty ; public int size(); public void add(T item); 3) Your MyBag implementation should use the Java ArrayList as its underlying data structure. 4) Add the following classes to the hands package. Both should implement HandOfCards & Iterable: 5) A class called ArrayListHand that uses the Java ArrayList as the underlying data structure. 6) A class called BagHand that uses your MyBag class as the underlying data structure. 7) In the driver class (Project5.java), simulate a game (several rounds) of Blackjack with three hands. You should use at least one BagHand and one ArrayListHand. In each round, deal a new hands and calculate their value (make use of the getValue() method of the PlayingCard class). Print each hand and if the value is 21, print "Blackjack", otherwise print the value. Each round should be dealt from a new deck. Make sure your output makes it clear which cards are from which hand and their total value. 2) Create a class called MyBag in the bag package that implements the Bag interface. public interface Bag extends Iterable { public boolean is Empty ; public int size(); public void add(T item); 3) Your MyBag implementation should use the Java ArrayList as its underlying data structure. 4) Add the following classes to the hands package. Both should implement HandOfCards & Iterable: 5) A class called ArrayListHand that uses the Java ArrayList as the underlying data structure. 6) A class called BagHand that uses your MyBag class as the underlying data structure. 7) In the driver class (Project5.java), simulate a game (several rounds) of Blackjack with three hands. You should use at least one BagHand and one ArrayListHand. In each round, deal a new hands and calculate their value (make use of the getValue() method of the PlayingCard class). Print each hand and if the value is 21, print "Blackjack", otherwise print the value. Each round should be dealt from a new deck. Make sure your output makes it clear which cards are from which hand and their total value

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!