Skip to content

Commit

Permalink
tree lab and hw complete
Browse files Browse the repository at this point in the history
  • Loading branch information
jasojone committed May 30, 2021
1 parent 6ca910a commit 9780402
Show file tree
Hide file tree
Showing 75 changed files with 5,819 additions and 0 deletions.
Binary file not shown.
5 changes: 5 additions & 0 deletions cis17cProject2.0/.dep.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This code depends on make tool being used
DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES} ${TESTOBJECTFILES}))
ifneq (${DEPFILES},)
include ${DEPFILES}
endif
111 changes: 111 additions & 0 deletions cis17cProject2.0/Card.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* File: Card.h
* Author: Jason
*
* Created on April 1, 2021, 8:25 AM
*/

#ifndef CARD_H
#define CARD_H

#include <iostream>
#include <map>

using namespace std;
/*****************************************************************************\
* Card *
* The Card struct will contain the attributes of the card. *
* Attributes: the cards suit, the power of the card and the cards ascii art. *
\*****************************************************************************/
struct Card
{
string suit; // cards suit
int cPower; // power of the card to determine who will win the round
Card(string s, int p)// assign the power and suit when card is created
{
suit = s;
cPower = p;
}
friend bool operator==(const Card& l, const Card& r)
{
return l.cPower == r.cPower;
}
// cardArt is the map with a nested map that contains cars ascii visual art
// the outer map key is the suits outer maps value is another map who's key
// is the power of a card and the value is the art of the card.
map<string, map<int, string>> cardArt =
{
{"CLUBS",
{

{2, ".------.\n|2 ♣|\n| () |\n| ()() |\n|♣ 2|\n`------'\n"},
{3, ".------.\n|3 ♣|\n| () |\n| ()() |\n|♣ 3|\n`------'\n"},
{4, ".------.\n|4 ♣|\n| () |\n| ()() |\n|♣ 4|\n`------'\n"},
{5, ".------.\n|5 ♣|\n| () |\n| ()() |\n|♣ 5|\n`------'\n"},
{6, ".------.\n|6 ♣|\n| () |\n| ()() |\n|♣ 6|\n`------'\n"},
{7, ".------.\n|7 ♣|\n| () |\n| ()() |\n|♣ 7|\n`------'\n"},
{8, ".------.\n|8 ♣|\n| () |\n| ()() |\n|♣ 8|\n`------'\n"},
{9, ".------.\n|9 ♣|\n| () |\n| ()() |\n|♣ 9|\n`------'\n"},
{10, ".------.\n|10 ♣|\n| () |\n| ()() |\n|♣ 10|\n`------'\n"},
{11, ".------.\n|J ♣|\n| () |\n| ()() |\n|♣ J|\n`------'\n"},
{12, ".------.\n|Q ♣|\n| () |\n| ()() |\n|♣ Q|\n`------'\n"},
{13, ".------.\n|K ♣|\n| () |\n| ()() |\n|♣ K|\n`------'\n"},
{14, ".------.\n|A ♣|\n| () |\n| ()() |\n|♣ A|\n`------'\n"}
}
},
{"DIAMONDS",
{
{2, ".------.\n|2 ♦|\n| /\\ |\n| \\/ |\n|♦ 2|\n`------'\n"},
{3, ".------.\n|3 ♦|\n| /\\ |\n| \\/ |\n|♦ 3|\n`------'\n"},
{4, ".------.\n|4 ♦|\n| /\\ |\n| \\/ |\n|♦ 4|\n`------'\n"},
{5, ".------.\n|5 ♦|\n| /\\ |\n| \\/ |\n|♦ 5|\n`------'\n"},
{6, ".------.\n|6 ♦|\n| /\\ |\n| \\/ |\n|♦ 6|\n`------'\n"},
{7, ".------.\n|7 ♦|\n| /\\ |\n| \\/ |\n|♦ 7|\n`------'\n"},
{8, ".------.\n|8 ♦|\n| /\\ |\n| \\/ |\n|♦ 8|\n`------'\n"},
{9, ".------.\n|9 ♦|\n| /\\ |\n| \\/ |\n|♦ 9|\n`------'\n"},
{10, ".------.\n|10 ♦|\n| /\\ |\n| \\/ |\n|♦ 10|\n`------'\n"},
{11, ".------.\n|J ♦|\n| /\\ |\n| \\/ |\n|♦ J|\n`------'\n"},
{12, ".------.\n|Q ♦|\n| /\\ |\n| \\/ |\n|♦ Q|\n`------'\n"},
{13, ".------.\n|K ♦|\n| /\\ |\n| \\/ |\n|♦ K|\n`------'\n"},
{14, ".------.\n|A ♦|\n| /\\ |\n| \\/ |\n|♦ A|\n`------'\n"}
}
},
{"HEARTS",
{
{2, ".------.\n|2 ♥|\n| (\\/) |\n| \\/ |\n|♥ 2|\n`------'\n"},
{3, ".------.\n|3 ♥|\n| (\\/) |\n| \\/ |\n|♥ 3|\n`------'\n"},
{4, ".------.\n|4 ♥|\n| (\\/) |\n| \\/ |\n|♥ 4|\n`------'\n"},
{5, ".------.\n|5 ♥|\n| (\\/) |\n| \\/ |\n|♥ 5|\n`------'\n"},
{6, ".------.\n|6 ♥|\n| (\\/) |\n| \\/ |\n|♥ 6|\n`------'\n"},
{7, ".------.\n|7 ♥|\n| (\\/) |\n| \\/ |\n|♥ 7|\n`------'\n"},
{8, ".------.\n|8 ♥|\n| (\\/) |\n| \\/ |\n|♥ 8|\n`------'\n"},
{9, ".------.\n|9 ♥|\n| (\\/) |\n| \\/ |\n|♥ 9|\n`------'\n"},
{10, ".------.\n|10 ♥|\n| (\\/) |\n| \\/ |\n|♥ 10|\n`------'\n"},
{11, ".------.\n|J ♥|\n| (\\/) |\n| \\/ |\n|♥ J|\n`------'\n"},
{12, ".------.\n|Q ♥|\n| (\\/) |\n| \\/ |\n|♥ Q|\n`------'\n"},
{13, ".------.\n|K ♥|\n| (\\/) |\n| \\/ |\n|♥ K|\n`------'\n"},
{14, ".------.\n|A ♥|\n| (\\/) |\n| \\/ |\n|♥ A|\n`------'\n"}
}
},
{"SPADES",
{
{2, ".------.\n|2 ♠|\n| /\\ |\n| (__) |\n|♠ 2|\n`------'\n"},
{3, ".------.\n|3 ♠|\n| /\\ |\n| (__) |\n|♠ 3|\n`------'\n"},
{4, ".------.\n|4 ♠|\n| /\\ |\n| (__) |\n|♠ 4|\n`------'\n"},
{5, ".------.\n|5 ♠|\n| /\\ |\n| (__) |\n|♠ 5|\n`------'\n"},
{6, ".------.\n|6 ♠|\n| /\\ |\n| (__) |\n|♠ 6|\n`------'\n"},
{7, ".------.\n|7 ♠|\n| /\\ |\n| (__) |\n|♠ 7|\n`------'\n"},
{8, ".------.\n|8 ♠|\n| /\\ |\n| (__) |\n|♠ 8|\n`------'\n"},
{9, ".------.\n|9 ♠|\n| /\\ |\n| (__) |\n|♠ 9|\n`------'\n"},
{10, ".------.\n|10 ♠|\n| /\\ |\n| (__) |\n|♠ 10|\n`------'\n"},
{11, ".------.\n|J ♠|\n| /\\ |\n| (__) |\n|♠ J|\n`------'\n"},
{12, ".------.\n|Q ♠|\n| /\\ |\n| (__) |\n|♠ Q|\n`------'\n"},
{13, ".------.\n|K ♠|\n| /\\ |\n| (__) |\n|♠ K|\n`------'\n"},
{14, ".------.\n|A ♠|\n| /\\ |\n| (__) |\n|♠ A|\n`------'\n"}
}
}
};
};

#endif /* CARD_H */

Binary file added cis17cProject2.0/Cis17cProject1WarWriteUp.docx
Binary file not shown.
52 changes: 52 additions & 0 deletions cis17cProject2.0/Deck.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* File: Deck.cpp
* Author: Jason
*
* Created on April 4, 2021, 9:04 PM
*
*
*/
#include "Deck.h"

/*****************************************************************************\
* Deck Constructor *
* The default constructor will create the 52 cards using the card class *
* elements *
\*****************************************************************************/
Deck::Deck()
{
// Due to the decks private variable of suits being a list an iterator
// was used to traverses through the suits, there is a total of four
// suits traversing through the list from the begin and end will reach 4
for (list<string>::iterator itr = suits.begin(); itr != suits.end(); itr++)
{
// traverses though the powers of each suit and populates the deck
// with suited cards.
for (int j = 2; j <= 14; j++)
{
// emplace is used over
currDeck.emplace_back(Card(*itr, j));
}
}
// once the deck is populated it is then shuffled for play.
// using the random access iterator
random_shuffle(currDeck.begin(), currDeck.end());
}

/*****************************************************************************\
* dealCards *
* This function will take the deck of 52 cards and populate each players hand *
* with 26 cards each. *
\*****************************************************************************/
void Deck::dealCards(Player &currPlayer)
{
// for loop deals the cards to each player 26 to each player
for (int i = 0; i < 26; i++)
{
// pushes the cards to the hand in play form the deck then pops them
// off the current deck.
currPlayer.handInPlay.push(currDeck.back());
currDeck.pop_back();
}
}

40 changes: 40 additions & 0 deletions cis17cProject2.0/Deck.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* File: Deck.h
* Author: Jason
*
* Created on April 1, 2021, 8:25 AM
*/
#ifndef DECK_H
#define DECK_H
#include "Player.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <list>
using namespace std;

/*****************************************************************************\
* Deck *
* The Deck class will contain the attributes of the deck of cards. *
* Attributes: a vector of cards, a string array with suits for map keys. *
\*****************************************************************************/
class Deck
{
private:
// The currDack is a vector of cards which will be used to populate the
// 52 cards that will be used for the game. A vector was used for the
// purpose of random_shuffle
vector<Card> currDeck;
// The suits are held in a list container to allow us to assign the
// 14 cards of each suit typ. A list was used to fulfill the requirements
// of a list as well as iterators.
list<string> suits = {"CLUBS", "DIAMONDS", "HEARTS", "SPADES"};

public:
Deck(); // default constructor will create the deck when instantiated.
void dealCards(Player &currPlayer); // deals the card 26 per player.
};
#endif /* DECK_H */

Loading

0 comments on commit 9780402

Please sign in to comment.