Grading Notes: For the initial API and UML
plan the grade is only that it shows effort to create an API/UML
based on the information given. For the final API and UML
when you turn in the completed project it is based on it matching
what you built - so I can tell you know how the API and UML connect
to the actual code.
For this project we will be expanding on the code provided in
Section 1.4 to build a program able to work with more than one card
game. You will be using different classes to help organize
the code and will need to first create
an API and UML of
your planned design. The second part is to then build the actual
project. All code in the second part should have JUnit tests
attached where possible to it to show it is functioning
correctly.
1. Card Games
You will need to support the following three types of decks of
cards:
Standard 52 Card Deck (see Section
1.4)
UNO Type Deck (minus wild cards, draw 4s,
and no duplicates of any cards – the color will act as the
Suit)
Skip Bo Type Deck (Has cards numbered 1 -
12 and a Skip Card - all cards are of the same suit called "Skip
Bo").
UNO Reference: How many cards in uno? A complete breakdown
of each card (unorules.org)
Skip Bo Reverence: Skip-Bo - Wikipedia
You will need a class that supports each deck type. I will
go into more detail on what operations the class needs to support
after going over some other key classes you will need.
Optional: You may use now or modify your
design later to use inheritance if you want as you should find a
lot of the code is duplicated across the classes.
2. The Cards
To better keep track of the information on the cards we need a
class that will track the following information for each card:
The Rank: e.g. 1, 3, Jack, etc…
The Suit: e.g. Clubs, Spaces, etc…
Value of the Card: You need to decide a
numerical value for each card that is unique. A simple
approach is just the index location of where it is in the deck
before the deck is shuffled.
The Card class should have a way to print out the card that
shows the name of the card (e.g. "1 of Clubs") and the Value of the
card (e.g. 3). Also, keep in mind a way to access the
instance variables as they should be set to private.
3. Hand of Cards
Your classes for the decks will be able to deal out a hands of
cards, as such you need a class that will keep track of an array of
Cards. Since all the different card games should use the same
Card class, you only need one Hand class. This class should
provide the following:
Be able to keep track of an initial set of
cards: Keeps track of an array of cards. We will use
other functionality if we need to add or remove cards.
Be able to print out the cards
held: Prints out all the cards in the hand, in the
order stored.
Be able to add a card: Will add a card to
the Hand. You will need to resize your array to make space
for the additional card.
4. Deck Functionality
Now that we have covered the Card and Hand class, let's get back
to the needs of the various Deck classes. Each deck should be
its own class and support the following operations:
Shuffle – Should shuffle the cards using
the algorithm from Section 1.4 – We will go over ways to test this
in class.
Deal – Should deal out a Hand of cards
from the deck. It should not deal out cards that have already
been dealt. It should throw an error if there are not enough
cards left to deal out a full hand – we will be discussing more on
how to create our own errors and throw them.
Standard
52 Card Deck – 5 Cards
UNO
Type Deck – 7 Cards
Skip
Bo Type Deck – 6 Cards
Draw – Removes a single card from the
Deck. It should throw an error if there are no cards left
Sort – Will sort the cards in a players
hand – we will go over this in Section 4.2.
Standard
52 Card Deck – Uses Insertion Sort and uses the Card
Value to sort by
UNO
Type Deck – Uses Selection Sort and uses the Suit of the
card to sort by
Skip
Bo Type Deck – Uses Bubble Sort and uses the Rank of the
card to sort by
Part I
Based on the information provided create an API and UML diagram
for your project. This should include the classes you need,
the instance variables for the classes, and methods required to
meet the requirements stated above.
Part II
Write and test your code using JUnit based on your design.
Remember to include class and method level comments in your
code as well as proper formatting. You may make changes as
you work on the project as you find out you need additional
methods/classes/instance variables, but you will also need to
update your API/UML to reflect these changes. Once finished
you will be turning in both your code and updated UML/API design to
D2L.
Grading Notes: For the initial API and UML plan the grade is only that it shows effort to create an API/UML based on the
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Grading Notes: For the initial API and UML plan the grade is only that it shows effort to create an API/UML based on the
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!