Question: JAVA PROGRAM STRICTLY FOLLOW THIS TEMPLATE import java.util.LinkedList; import java.util.Collections; import java.util.Iterator; /** * * * * * */ public class Deck { private static

JAVA PROGRAM

JAVA PROGRAM STRICTLY FOLLOW THIS TEMPLATE import java.util.LinkedList; import java.util.Collections; import java.util.Iterator;

/** * * * * * */ public class Deck { private

STRICTLY FOLLOW THIS TEMPLATE

import java.util.LinkedList; import java.util.Collections; import java.util.Iterator; /** * * * * * */ public class Deck { private static final int NUM = 3; // Number of cards in Deck private Card[] cards; public Deck() { cards = new Card[NUM]; cards[0] = new RelativeMovementCard("Go back 3 spaces", -3); cards[1] = new PayBankCard("Pay poor tax $15", 15); cards[2] = new PayBankCard("Pay school tax of $150", 150); } public void save() { for (int i = 0; i Write a class Deck. This class should declare one instance variable private Card() cards; // chance or community chest cards In the constructor of Deck construct the cards array and add RelativeMovementcard objects and PayBankcard objects to this array. You can assume that there are only 3 cards in the deck and construct these objects as follows new RelativeMovementCard "Go back 3 spaces", -3) new PayBankCard ("Pay poor tax of $15", 15) Add two methods: public void pickcard() This method should remove the first card from the cards array, call the execute method of the Card object and add the card back to the end of the array. public void save () This method should traverse the cards array using an index and call the save method of each card object . Write a small test driver (main) which constructs a Deck object and then calls the pickCard method twice

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!