aboutsummaryrefslogtreecommitdiff
path: root/src/main/Card.cpp
diff options
context:
space:
mode:
authorCharlie Blake2017-10-13 19:05:13 +0100
committerGitHub2017-10-13 19:05:13 +0100
commitc1f4a1a4368bd45747f864910ae5136dccb857a6 (patch)
treeb3bdce7b7cd6c46f6928368f2c91f9d994fc48e7 /src/main/Card.cpp
parentMerge pull request #8 from thecharlesblake/docs (diff)
parentUpdate build instructions with new install (diff)
downloadmetasol-c1f4a1a4368bd45747f864910ae5136dccb857a6.tar.gz
metasol-c1f4a1a4368bd45747f864910ae5136dccb857a6.zip

Merge pull request #10 from thecharlesblake/project-setup-cpp

Project setup cpp

Diffstat (limited to 'src/main/Card.cpp')
-rw-r--r--src/main/Card.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/Card.cpp b/src/main/Card.cpp
new file mode 100644
index 0000000..ead2fd5
--- /dev/null
+++ b/src/main/Card.cpp
@@ -0,0 +1,25 @@
+//
+// Created by thecharlesblake on 10/11/17.
+//
+
+#include "Card.h"
+#include <string>
+
+Card::Card(const int r, const std::string s): rank(r), suit(s) {}
+
+std::ostream & operator<<(std::ostream & Str, Card const & c) {
+ std::string r;
+ if (c.rank == 1) {
+ r = "A";
+ } else if (c.rank <= 10) {
+ r = std::to_string(c.rank);
+ } else if (c.rank == 11) {
+ r = "J";
+ } else if (c.rank == 12) {
+ r = "Q";
+ } else if (c.rank == 13) {
+ r = "K";
+ }
+
+ return Str << r << c.suit;
+} \ No newline at end of file