Moved to new folders
This commit is contained in:
31
Oving5/Oving 5.sln
Normal file
31
Oving5/Oving 5.sln
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.329
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Oving 5", "Oving 5\Oving 5.vcxproj", "{AB5577F7-8F95-4259-B198-2D9690F663F7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{AB5577F7-8F95-4259-B198-2D9690F663F7}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{AB5577F7-8F95-4259-B198-2D9690F663F7}.Debug|x64.Build.0 = Debug|x64
|
||||
{AB5577F7-8F95-4259-B198-2D9690F663F7}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{AB5577F7-8F95-4259-B198-2D9690F663F7}.Debug|x86.Build.0 = Debug|Win32
|
||||
{AB5577F7-8F95-4259-B198-2D9690F663F7}.Release|x64.ActiveCfg = Release|x64
|
||||
{AB5577F7-8F95-4259-B198-2D9690F663F7}.Release|x64.Build.0 = Release|x64
|
||||
{AB5577F7-8F95-4259-B198-2D9690F663F7}.Release|x86.ActiveCfg = Release|Win32
|
||||
{AB5577F7-8F95-4259-B198-2D9690F663F7}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {45C09BE7-875A-44D0-8CB8-6F2564F3F8C1}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
107
Oving5/Oving 5/Blackjack.cpp
Normal file
107
Oving5/Oving 5/Blackjack.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
#include "Blackjack.h"
|
||||
#include "Card.h"
|
||||
|
||||
Blackjack::Blackjack()
|
||||
{
|
||||
cards = CardDeck();
|
||||
cards.shuffle();
|
||||
|
||||
|
||||
player = Hand();
|
||||
dealer = Hand(true);
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
player.newCard(cards);
|
||||
dealer.newCard(cards);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Blackjack::printCards()
|
||||
{
|
||||
cout << flush;
|
||||
dealer.printCards();
|
||||
cout << endl;
|
||||
player.printCards();
|
||||
}
|
||||
|
||||
Hand::Hand()
|
||||
{
|
||||
d = false;
|
||||
}
|
||||
|
||||
Hand::Hand(bool dealer)
|
||||
{
|
||||
d = dealer;
|
||||
}
|
||||
|
||||
void Hand::newCard(CardDeck & cards)
|
||||
{
|
||||
card.push_back(cards.drawCard());
|
||||
addValue();
|
||||
}
|
||||
|
||||
/*
|
||||
void Hand::addValue()
|
||||
{
|
||||
Card c = card.back();
|
||||
int value = int(c.rankVal());
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void Hand::addValue()
|
||||
{
|
||||
Card c = card.back();
|
||||
int valueOfCard = c.rankVal();
|
||||
if (valueOfCard >= 2 && valueOfCard <= 10)
|
||||
total.push_back(valueOfCard);
|
||||
else if (valueOfCard < 14)
|
||||
total.push_back(10);
|
||||
else if (valueOfCard == 14)
|
||||
{
|
||||
if (!d)
|
||||
{
|
||||
cout << "Do you want the ace to be 1 or 11? ";
|
||||
int aceVal;
|
||||
cin >> aceVal;
|
||||
if (aceVal > 11 || aceVal > 5)
|
||||
aceVal = 11;
|
||||
else if (aceVal <= 5)
|
||||
aceVal = 1;
|
||||
total.push_back(aceVal);
|
||||
}
|
||||
else
|
||||
total.push_back(11);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Hand::printCards()
|
||||
{
|
||||
for (int i = 0; i < card.size(); ++i)
|
||||
{
|
||||
if (d && i > 0)
|
||||
cout << "Hidden dealer cards!" << endl;
|
||||
else
|
||||
cout << card[i].toString() << " \tValue: " << total[i] << endl;
|
||||
}
|
||||
}
|
||||
|
||||
int Hand::sum()
|
||||
{
|
||||
return calculateSum();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Hand::calculateSum()
|
||||
{
|
||||
int t = 0;
|
||||
for (int i : total)
|
||||
{
|
||||
t += i;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
34
Oving5/Oving 5/Blackjack.h
Normal file
34
Oving5/Oving 5/Blackjack.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include "CardDeck.h"
|
||||
|
||||
class Hand
|
||||
{
|
||||
public:
|
||||
Hand();
|
||||
Hand(bool dealer);
|
||||
void newCard(CardDeck& cards);
|
||||
void printCards();
|
||||
int sum();
|
||||
private:
|
||||
void addValue();
|
||||
vector<Card> card;
|
||||
vector<int> cardsToShow;
|
||||
vector<int> total;
|
||||
bool d;
|
||||
int calculateSum();
|
||||
};
|
||||
|
||||
class Blackjack
|
||||
{
|
||||
public:
|
||||
Blackjack();
|
||||
void printCards();
|
||||
private:
|
||||
CardDeck cards;
|
||||
Hand player;
|
||||
Hand dealer;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
88
Oving5/Oving 5/Card.cpp
Normal file
88
Oving5/Oving 5/Card.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
#include "Card.h"
|
||||
|
||||
|
||||
map<Suit, string> suitNames = { {Suit::clubs, "Clubs" },
|
||||
{Suit::diamonds, "Diamonds"},
|
||||
{Suit::hearts, "Hearts"},
|
||||
{Suit::spades, "Spades"} };
|
||||
|
||||
string suitToString(Suit s)
|
||||
{
|
||||
return suitNames[s];
|
||||
}
|
||||
|
||||
map<Rank, string> rankNames = { {Rank::two, "Two" },
|
||||
{Rank::three, "Three"},
|
||||
{Rank::four, "Four"},
|
||||
{Rank::five, "Five"},
|
||||
{Rank::six, "Six"},
|
||||
{Rank::seven, "Seven"},
|
||||
{Rank::eight, "Eight"},
|
||||
{Rank::nine, "Nine"},
|
||||
{Rank::ten, "Ten"},
|
||||
{Rank::jack, "Jack"},
|
||||
{Rank::queen, "Queen"},
|
||||
{Rank::king, "King"},
|
||||
{Rank::ace, "Ace"} };
|
||||
|
||||
string rankToString(Rank r)
|
||||
{
|
||||
return rankNames[r];
|
||||
}
|
||||
|
||||
string toString(CardStruct card)
|
||||
{
|
||||
return rankToString(card.rank) + " of " + suitToString(card.suit);
|
||||
}
|
||||
|
||||
string toStringShort(CardStruct card)
|
||||
{
|
||||
string suit = suitToString(card.suit);
|
||||
string rank = to_string(int(card.rank));
|
||||
return suit.at(0) + rank;
|
||||
|
||||
}
|
||||
|
||||
#pragma region Card - Class
|
||||
|
||||
Card::Card()
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
|
||||
Card::Card(Suit suit, Rank rank)
|
||||
{
|
||||
s = suit;
|
||||
r = rank;
|
||||
valid = true;
|
||||
}
|
||||
|
||||
inline Suit Card::suit() { return s; }
|
||||
inline Rank Card::rank() { return r; }
|
||||
int Card::suitVal()
|
||||
{
|
||||
return int(s);
|
||||
}
|
||||
int Card::rankVal()
|
||||
{
|
||||
return int(r);
|
||||
}
|
||||
inline bool Card::isValid() { return valid; }
|
||||
|
||||
string Card::toString()
|
||||
{
|
||||
if (valid)
|
||||
return rankToString(r) + " of " + suitToString(s);
|
||||
else
|
||||
return "Invalid card";
|
||||
}
|
||||
|
||||
string Card::toStringShort()
|
||||
{
|
||||
if (valid)
|
||||
return suitToString(s).at(0) + to_string(int(r));
|
||||
else
|
||||
return "Invalid card";
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
46
Oving5/Oving 5/Card.h
Normal file
46
Oving5/Oving 5/Card.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
#include "std_lib_facilities.h"
|
||||
|
||||
enum class Suit { clubs, diamonds, hearts, spades };
|
||||
|
||||
enum class Rank { two = 2, three, four, five, six, seven, eight, nine, ten, jack, queen, king, ace };
|
||||
|
||||
string suitToString(Suit s);
|
||||
|
||||
string rankToString(Rank r);
|
||||
|
||||
struct CardStruct
|
||||
{
|
||||
Suit suit;
|
||||
Rank rank;
|
||||
};
|
||||
|
||||
string toString(CardStruct card);
|
||||
|
||||
string toStringShort(CardStruct card);
|
||||
|
||||
#pragma region Card - Class
|
||||
|
||||
|
||||
class Card
|
||||
{
|
||||
public:
|
||||
Card();
|
||||
Card(Suit suit, Rank rank);
|
||||
|
||||
Suit suit();
|
||||
Rank rank();
|
||||
int suitVal();
|
||||
int rankVal();
|
||||
bool isValid();
|
||||
string toString();
|
||||
string toStringShort();
|
||||
private:
|
||||
Suit s;
|
||||
Rank r;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#pragma endregion
|
||||
53
Oving5/Oving 5/CardDeck.cpp
Normal file
53
Oving5/Oving 5/CardDeck.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "CardDeck.h"
|
||||
#include "utilities.h"
|
||||
|
||||
CardDeck::CardDeck()
|
||||
{
|
||||
currentCardIndex = 0;
|
||||
for (int s = 0; s < 4; s++)
|
||||
{
|
||||
for (int r = 2; r < 2 + 13; r++)
|
||||
{
|
||||
cards.push_back(Card((Suit)s, (Rank)r));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CardDeck::swap(int fromIndex, int toIndex)
|
||||
{
|
||||
Card c = cards[fromIndex];
|
||||
cards[fromIndex] = cards[toIndex];
|
||||
cards[toIndex] = c;
|
||||
}
|
||||
|
||||
void CardDeck::print()
|
||||
{
|
||||
for (Card c : cards)
|
||||
{
|
||||
cout << c.toString() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void CardDeck::printShort()
|
||||
{
|
||||
for (Card c : cards)
|
||||
{
|
||||
cout << c.toStringShort() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void CardDeck::shuffle(int depth)
|
||||
{
|
||||
srand(static_cast<unsigned int>(time(nullptr)));
|
||||
for (int i = 0; i < depth; i++)
|
||||
{
|
||||
swap(randomWithLimits(0, cards.size() - 1), randomWithLimits(0, cards.size() - 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const Card& CardDeck::drawCard()
|
||||
{
|
||||
++currentCardIndex;
|
||||
return cards[currentCardIndex - 1];
|
||||
}
|
||||
18
Oving5/Oving 5/CardDeck.h
Normal file
18
Oving5/Oving 5/CardDeck.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include "Card.h"
|
||||
|
||||
class CardDeck
|
||||
{
|
||||
public:
|
||||
CardDeck();
|
||||
void print();
|
||||
void printShort();
|
||||
void shuffle(int depth = 10000);
|
||||
const Card& drawCard();
|
||||
private:
|
||||
vector<Card> cards;
|
||||
int currentCardIndex;
|
||||
void swap(int fromIndex, int toIndex);
|
||||
|
||||
};
|
||||
|
||||
152
Oving5/Oving 5/Oving 5.vcxproj
Normal file
152
Oving5/Oving 5/Oving 5.vcxproj
Normal file
@@ -0,0 +1,152 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{ab5577f7-8f95-4259-b198-2d9690f663f7}</ProjectGuid>
|
||||
<RootNamespace>Oving_5</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>C:\Program Files\TDT4102\includes;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>C:\Program Files\TDT4102\includes;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IncludePath>C:\Program Files\TDT4102\includes;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>C:\Program Files\TDT4102\includes;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Blackjack.cpp" />
|
||||
<ClCompile Include="Card.cpp" />
|
||||
<ClCompile Include="CardDeck.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="utilities.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Blackjack.h" />
|
||||
<ClInclude Include="Card.h" />
|
||||
<ClInclude Include="CardDeck.h" />
|
||||
<ClInclude Include="utilities.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
48
Oving5/Oving 5/Oving 5.vcxproj.filters
Normal file
48
Oving5/Oving 5/Oving 5.vcxproj.filters
Normal file
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Card.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CardDeck.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="utilities.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Blackjack.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Card.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CardDeck.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="utilities.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Blackjack.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
57
Oving5/Oving 5/main.cpp
Normal file
57
Oving5/Oving 5/main.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "std_lib_facilities.h"
|
||||
#include "CardDeck.h"
|
||||
#include "Blackjack.h"
|
||||
|
||||
int main(){
|
||||
|
||||
#pragma region Task 1
|
||||
// a - d
|
||||
// Testing functions and mapping
|
||||
//cout << suitToString(Suit::diamonds) << endl;
|
||||
//cout << rankToString(Rank::ace) << endl;
|
||||
|
||||
// e
|
||||
/*
|
||||
Det er lurt <20> bruke symboler fordi
|
||||
- Mindre sansynlighet for misforst<73>else
|
||||
- Lettere <20> lese koden til senere
|
||||
*/
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Task 2
|
||||
/*
|
||||
CardStruct card1 = { Suit::spades, Rank::ace };
|
||||
CardStruct card2 = { Suit::diamonds, Rank::ten };
|
||||
cout << toString(card1) << endl;
|
||||
cout << toStringShort(card2) << endl;
|
||||
|
||||
*/
|
||||
#pragma endregion
|
||||
|
||||
Card c = Card(Suit::clubs, Rank::two);
|
||||
|
||||
cout << c.toString() << endl;
|
||||
|
||||
|
||||
CardDeck cD = CardDeck();
|
||||
|
||||
cD.print();
|
||||
|
||||
cD.shuffle();
|
||||
cD.printShort();
|
||||
|
||||
for (int i = 0; i < 52; i++)
|
||||
{
|
||||
Card c = cD.drawCard();
|
||||
cout << c.toString() << endl;
|
||||
}
|
||||
|
||||
|
||||
Blackjack bJack = Blackjack();
|
||||
|
||||
bJack.printCards();
|
||||
|
||||
keep_window_open();
|
||||
return 0;
|
||||
}
|
||||
8
Oving5/Oving 5/utilities.cpp
Normal file
8
Oving5/Oving 5/utilities.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "utilities.h"
|
||||
#include "std_lib_facilities.h"
|
||||
|
||||
int randomWithLimits(int min, int max)
|
||||
{
|
||||
return rand() % (max - min + 1) + min;;
|
||||
}
|
||||
|
||||
6
Oving5/Oving 5/utilities.h
Normal file
6
Oving5/Oving 5/utilities.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
int randomWithLimits(int min, int max);
|
||||
|
||||
|
||||
|
||||
BIN
Oving5/Øving_5(5.feb)_3.pdf
Normal file
BIN
Oving5/Øving_5(5.feb)_3.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user