Download presentation
Presentation is loading. Please wait.
1
CS 106 Introduction to Computer Science I 04 / 07 / 2010 Instructor: Michael Eckmann
2
Michael Eckmann - Skidmore College - CS 106 - Spring 2010 Today’s Topics Comments and/or Questions? Card and Deck implementation
3
Card/Deck implementation Purpose of these classes will be to create a general Card class and general Deck class that could be used for an arbitrary card game. So, nothing game specific is desired to be in the classes. What data describes a Card? What data describes a Deck? What behaviors does a Card exhibit? What behaviors does a Deck exhibit?
4
Card/Deck implementation What data describes a Card? – Rank and suit (types for these?) What data describes a Deck? – An ordered group of some fixed number of cards What behaviors does a Card exhibit? – None really independent of a Deck What behaviors does a Deck exhibit? – Can shuffle it – Can cut it – Can deal a card from it
5
Shuffle method Ideas for the shuffle method – try to simulate human shuffling – or just swap 2 cards a bunch of times to get a mixed deck – or other ideas?
6
Cut method Ideas for the cut method Have another array of 52 Cards to copy into (then later copy this array back into original.) Generate some random number between 0 and 51 and use that as the place to cut the cards. Keeping track of starting and ending indicies is a challenge but its doable if we're careful. Draw copying idea on board. – How many loops and what will each one do?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.