Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 6: Uno Stacks We will create a deck of Uno cards and associated methods. 1. Make a new class UnoCard that contains the following

image text in transcribed

Lab 6: Uno Stacks We will create a deck of Uno cards and associated methods. 1. Make a new class UnoCard that contains the following protected data: color (String), and value (String). Make getters and setters for the data, and a toStringO method that returns a string containing the information for that card in a nice format. Make a compare(card) method that returns true if this card (as in this.compare(card)) may be played on top of card. Test the toString) and compare) methods. 2. We plan to use ArrayStack class for many of our Uno piles of cards (hands, discard pile, draw pile), but we want a way to shuffe the stack. The data stack is not public in class ArrayStack. Since we don't want to alter ArrayStack. java, create your own class public class MyArrayStack extends Arraystack and make a method to shuffle the stack. You may use many of the ideas from the RankCardDeck. java class in the support package by the book authors. Test that this works. You will need constructors for the MyArrayStack class. 3. Create a class UnoStack that contains protected data deck of type MyArrayStack (of length 150). In addition to the constructor, make the following methods: . Method makeStandardDeck ) makes the deck into a standard Uno deck, consisting of 108 cards: Two of each color with values: 1,2,..,9, Drau, Reverse, and Skip, One 0 of each color, and - Four Wild cards of each type: no value and Drau Method tostring) that outputs the stack to a string without destroying it. (Hint: I used a second stack, popped everything off the old stack onto the second stack, and then back, so that the cards would be in the same order.) Method shuffle) that can just call the shuffle) method in the MyArrayStack class. . Method drawCard that returns the top card in the stack and takes it off the stack. . Method deal(int nCards) that removes the top nCards cards from this deck, and re- turns a hand (itself of type UnoStack with those cards in it. add (UnoCard card) that adds card to this deck. V. add (UnoStack stack2) that adds stack2 to this. The two ori destroyed Test all these methods. Lab 6: Uno Stacks We will create a deck of Uno cards and associated methods. 1. Make a new class UnoCard that contains the following protected data: color (String), and value (String). Make getters and setters for the data, and a toStringO method that returns a string containing the information for that card in a nice format. Make a compare(card) method that returns true if this card (as in this.compare(card)) may be played on top of card. Test the toString) and compare) methods. 2. We plan to use ArrayStack class for many of our Uno piles of cards (hands, discard pile, draw pile), but we want a way to shuffe the stack. The data stack is not public in class ArrayStack. Since we don't want to alter ArrayStack. java, create your own class public class MyArrayStack extends Arraystack and make a method to shuffle the stack. You may use many of the ideas from the RankCardDeck. java class in the support package by the book authors. Test that this works. You will need constructors for the MyArrayStack class. 3. Create a class UnoStack that contains protected data deck of type MyArrayStack (of length 150). In addition to the constructor, make the following methods: . Method makeStandardDeck ) makes the deck into a standard Uno deck, consisting of 108 cards: Two of each color with values: 1,2,..,9, Drau, Reverse, and Skip, One 0 of each color, and - Four Wild cards of each type: no value and Drau Method tostring) that outputs the stack to a string without destroying it. (Hint: I used a second stack, popped everything off the old stack onto the second stack, and then back, so that the cards would be in the same order.) Method shuffle) that can just call the shuffle) method in the MyArrayStack class. . Method drawCard that returns the top card in the stack and takes it off the stack. . Method deal(int nCards) that removes the top nCards cards from this deck, and re- turns a hand (itself of type UnoStack with those cards in it. add (UnoCard card) that adds card to this deck. V. add (UnoStack stack2) that adds stack2 to this. The two ori destroyed Test all these methods

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

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions