Skip to content
This repository was archived by the owner on Jul 11, 2019. It is now read-only.

Commit 844339c

Browse files
author
Caleb Reister
committed
Initial
0 parents  commit 844339c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2650
-0
lines changed

.gitignore

+154
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
Recordings
2+
*.MP3
3+
4+
## Ignore Visual Studio temporary files, build results, and
5+
## files generated by popular Visual Studio add-ons.
6+
7+
# User-specific files
8+
*.suo
9+
*.user
10+
*.sln.docstates
11+
12+
# Build results
13+
14+
[Dd]ebug/
15+
[Rr]elease/
16+
x64/
17+
build/
18+
[Bb]in/
19+
[Oo]bj/
20+
21+
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
22+
!packages/*/build/
23+
24+
# MSTest test Results
25+
[Tt]est[Rr]esult*/
26+
[Bb]uild[Ll]og.*
27+
28+
*_i.c
29+
*_p.c
30+
*.ilk
31+
*.meta
32+
*.obj
33+
*.pch
34+
*.pdb
35+
*.pgc
36+
*.pgd
37+
*.rsp
38+
*.sbr
39+
*.tlb
40+
*.tli
41+
*.tlh
42+
*.tmp
43+
*.tmp_proj
44+
*.log
45+
*.vspscc
46+
*.vssscc
47+
.builds
48+
*.pidb
49+
*.log
50+
*.scc
51+
52+
# Visual C++ cache files
53+
ipch/
54+
*.aps
55+
*.ncb
56+
*.opensdf
57+
*.sdf
58+
*.cachefile
59+
60+
# Visual Studio profiler
61+
*.psess
62+
*.vsp
63+
*.vspx
64+
65+
# Guidance Automation Toolkit
66+
*.gpState
67+
68+
# ReSharper is a .NET coding add-in
69+
_ReSharper*/
70+
*.[Rr]e[Ss]harper
71+
72+
# TeamCity is a build add-in
73+
_TeamCity*
74+
75+
# DotCover is a Code Coverage Tool
76+
*.dotCover
77+
78+
# NCrunch
79+
*.ncrunch*
80+
.*crunch*.local.xml
81+
82+
# Installshield output folder
83+
[Ee]xpress/
84+
85+
# DocProject is a documentation generator add-in
86+
DocProject/buildhelp/
87+
DocProject/Help/*.HxT
88+
DocProject/Help/*.HxC
89+
DocProject/Help/*.hhc
90+
DocProject/Help/*.hhk
91+
DocProject/Help/*.hhp
92+
DocProject/Help/Html2
93+
DocProject/Help/html
94+
95+
# Click-Once directory
96+
publish/
97+
98+
# Publish Web Output
99+
*.Publish.xml
100+
*.pubxml
101+
102+
# NuGet Packages Directory
103+
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
104+
#packages/
105+
106+
# Windows Azure Build Output
107+
csx
108+
*.build.csdef
109+
110+
# Windows Store app package directory
111+
AppPackages/
112+
113+
# Others
114+
sql/
115+
*.Cache
116+
ClientBin/
117+
[Ss]tyle[Cc]op.*
118+
~$*
119+
*~
120+
*.dbmdl
121+
*.[Pp]ublish.xml
122+
*.pfx
123+
*.publishsettings
124+
125+
# RIA/Silverlight projects
126+
Generated_Code/
127+
128+
# Backup & report files from converting an old project file to a newer
129+
# Visual Studio version. Backup files are not needed, because we have git ;-)
130+
_UpgradeReport_Files/
131+
Backup*/
132+
UpgradeLog*.XML
133+
UpgradeLog*.htm
134+
135+
# SQL Server files
136+
App_Data/*.mdf
137+
App_Data/*.ldf
138+
139+
# =========================
140+
# Windows detritus
141+
# =========================
142+
143+
# Windows image file caches
144+
Thumbs.db
145+
ehthumbs.db
146+
147+
# Folder config file
148+
Desktop.ini
149+
150+
# Recycle Bin used on file shares
151+
$RECYCLE.BIN/
152+
153+
# Mac crap
154+
.DS_Store
153 KB
Binary file not shown.

CardSuperFun/CardSuperFun.sln

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2012
4+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CardSuperFun", "CardSuperFun\CardSuperFun.vcxproj", "{54EC0C9B-7BF6-4A8F-957E-8A6084CC0111}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Win32 = Debug|Win32
9+
Release|Win32 = Release|Win32
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{54EC0C9B-7BF6-4A8F-957E-8A6084CC0111}.Debug|Win32.ActiveCfg = Debug|Win32
13+
{54EC0C9B-7BF6-4A8F-957E-8A6084CC0111}.Debug|Win32.Build.0 = Debug|Win32
14+
{54EC0C9B-7BF6-4A8F-957E-8A6084CC0111}.Release|Win32.ActiveCfg = Release|Win32
15+
{54EC0C9B-7BF6-4A8F-957E-8A6084CC0111}.Release|Win32.Build.0 = Release|Win32
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
EndGlobal
+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#include "CardSuperFun.h"
2+
3+
int main()
4+
{
5+
int deck[deck::SIZE];
6+
deck::init(deck);
7+
cout << "Ordered deck" << endl;
8+
deck::dump(deck, deck::SIZE);//print non-random deck
9+
deck::shuffle(deck, deck::SIZE);
10+
cout << endl << "Shuffled deck" << endl;
11+
deck::dump(deck, deck::SIZE);//print shuffled deck
12+
cout << endl << endl;
13+
//testing card::print with all situations
14+
//testing card::HandPrint
15+
//NOTE: card::HandPrint calls card::print
16+
int TestHand[] = {301 ,310, 411, 512, 613, 600};
17+
cout << "HandPrint" << endl;
18+
card::HandPrint(TestHand, 5);
19+
cout << endl << "HandPrint hiding 1st card" << endl;
20+
card::HandPrint(TestHand, 5, true);
21+
22+
cin.get();
23+
cin.ignore();
24+
}
25+
26+
void deck::init(int deck[])
27+
{
28+
int index;
29+
int card = 0;// used as the card number because index cannot be reset
30+
for (index = 0; index < 13; index++)
31+
{
32+
deck[index] = card + 1 + 300;//sets value to index and sets suit to heart
33+
//the +1 offsets the fact that index starts at 0, giving Ace a value of 1
34+
card++;
35+
}
36+
card = 0;
37+
for (index; index < 26; index++)//26 gets to end of suit
38+
{
39+
deck[index] = card + 1 + 400;
40+
card++;
41+
}
42+
card = 0;
43+
for (index; index < 39; index++)
44+
{
45+
deck[index] = card + 1 + 500;
46+
card++;
47+
}
48+
card = 0;
49+
for (index; index < 52; index++)
50+
{
51+
deck[index] = card + 1 + 600;
52+
card++;
53+
}
54+
}
55+
56+
void deck::dump(const int deck[], int size)
57+
{
58+
for (int index = 0; index < size; index++)
59+
cout << deck[index] << endl;
60+
}
61+
62+
void deck::shuffle(int deck[], int size)
63+
{
64+
for (int rep = 0; rep < 5; rep++)//number of times to repeat the shuffling
65+
{
66+
for (int count = 0; count < size; count++)
67+
{
68+
int Card1 = deck[count];
69+
int index = RandNum(0, 51);
70+
int Card2 = deck[index];
71+
deck[index] = Card1;
72+
deck[count] = Card2;
73+
}
74+
}
75+
}
76+
77+
void card::print(int card)
78+
{
79+
char suit = card / 100;
80+
int num = card % 100;
81+
switch (num)
82+
{
83+
case 13://King
84+
cout << 'K' << suit;
85+
break;
86+
case 12://Queen
87+
cout << 'Q' << suit;
88+
break;
89+
case 11://Jack
90+
cout << 'J' << suit;
91+
break;
92+
case 1://Ace
93+
cout << 'A' << suit;
94+
break;
95+
default:
96+
cout << num << suit;
97+
}
98+
}
99+
100+
void card::HandPrint(const int cards[], int CardCount, bool HideTopCard)
101+
{
102+
int index = 0;
103+
if (HideTopCard == true)
104+
{
105+
cout << "X ";//placeholder for hidden card
106+
index = 1;
107+
}
108+
for (index; index < CardCount; index++)
109+
{
110+
if (cards[index] == 0)//skip cards that do not exist in the hand
111+
//example: the hand is smaller than the array
112+
continue;
113+
card::print(cards[index]);
114+
cout << ' ';
115+
}
116+
}
117+
118+
int RandNum(int low, int high)
119+
{
120+
static bool firstTime=true;
121+
int randNum;
122+
//if first time called, seed random number generator
123+
if (firstTime)
124+
{
125+
srand( static_cast<unsigned int>(time(NULL)) );
126+
firstTime=false;
127+
}
128+
//generate random number between given low and high values (inclusive)
129+
randNum = rand() % (high-low+1) + low;
130+
return randNum;
131+
}

0 commit comments

Comments
 (0)