Have a Question ?

Home / Answered Questions / CSE205 / cse205-assignment-2-q-163

(Solved): CSE205 Assignment 2...


CSE205 Assignment 2

Cards & Deck – 50pts
Topics:
• Arrays
• Classes
• Methods
• Loops and Conditionals


Description
The goal of this assignment is to create a re-usable Card and Deck class. This assignment will lead into Assignment 3 where you will build more classes to flesh out a card game.
Use the following Guidelines:
• Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc).
• Keep identifiers to a reasonably short length.
• User upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for all other identifiers (variables, methods, objects).
• Use tabs or spaces to indent code within blocks (code surrounded by braces). This includes classes, methods, and code associated with ifs, switches and loops. Be consistent with the number of spaces or tabs that you use to indent.
• Use white space to make your program more readable.
Important Note:
All files in submitted assignments must begin with the descriptive comment block. To avoid losing trivial points, make sure this comment header is included in every assignment you submit, and that it is updated accordingly from assignment to assignment.
Your header should identify you as the author and have a short description of the class contained in the file and what it does in your software.
Programming Assignment:
Instructions:
You are eventually going to create a multi-class system to play a card game. For this assignment you will lay the groundwork by creating the Card and Deck classes and demonstrating them working.
Required Classes:
• Card – Standard 52-Card Deck cards
• Deck – Deck of cards with deck behaviors
• Assn2 Class (Main) – Demonstrates the cards and deck functionality
Specifications:
Part 1 – Build your Card Class
Start by building your basic Card Class
Card:
Card:
• Properties
o Value:int
o suit:char
o faceup:boolean
• Methods
o Constructor
? Card(value:int, suit:char)
o Getters for value and suit
? You can’t change a card after its built, so no setters
o Getter/Setter for FaceUp
? You can flip it over
o toString()
? Override it to print your card nicely
Part 2 – Build your Deck Class
Deck:
Deck:
• Properties
o cards:Card[]
o cardCount:int
? Keeps track of the number of valid cards in the array
o maxSize:int
? Helps initialize the array
• Methods
o Constructors
? Deck()
• Default – fill with standard deck of 52
o Hint make a private method to help you fill it
? Deck(size:int)
• Set the maxSize to value passed in
• Initialize array … but don’t fill it
• Use this constructor to make an empty deck to fill via the Add() method
o Shuffle():void
? Shuffle the array
• Hint: remember Card object references
• Hint: Do the names Fisher and Yates ring a bell? Google might know …
o Draw:Card
? Reduce the card count, return a Card object reference
• Hint: last card in the array is easiest
• Hint2: think about setting the Card reference in the array to null – not necessary, but cleaner
o AddToTop(newCard:Card )
? Take a Card reference add it to the array at index last valid index if able to
o AddToBottom(newCard:Card)
? Take a Card reference add it to the array at the 0 index if able to
o PrintDeck
? Method to output your array all nice like …
? Hint: card.toString()
Both



We have an Answer from Expert View Expert Answer

Expert Answer


We have an Answer from Expert
Buy This Answer $120

-- OR --

Subscribe To View Unlimited Answers
Subscribe $12 / Month