Skip to content

Card and CardTest classes for Set Project. #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
e12e64b
Card and CardTest classes for Set Project.
Apr 1, 2015
302d202
Commit
ChrisSheehan01 Apr 7, 2015
f42a0c4
DeckTest Commit
ChrisSheehan01 Apr 7, 2015
9628080
Deck and DeckTest commit
ChrisSheehan01 Apr 8, 2015
840521a
DeckTest commit
ChrisSheehan01 Apr 8, 2015
ab0503e
DeckTest commit
ChrisSheehan01 Apr 8, 2015
c02381d
Deck and DeckTest
ChrisSheehan01 Apr 8, 2015
e76746a
Text files used for Deck class
ChrisSheehan01 Apr 8, 2015
e00c8cd
Updated files 4/11/15
ChrisSheehan01 Apr 11, 2015
018448b
Table and Table Node
ChrisSheehan01 Apr 12, 2015
fa372b6
Updated Table & TableNode files
ChrisSheehan01 Apr 13, 2015
a8b40bd
Updated files 17:43 13/4/2015
ChrisSheehan01 Apr 13, 2015
b731dc8
Updated files 6:25 13/4
ChrisSheehan01 Apr 13, 2015
5c24eca
Updated Table 21:47 4/13
ChrisSheehan01 Apr 14, 2015
2fd46dc
22:43 4/13
ChrisSheehan01 Apr 14, 2015
bf76c82
Table.java 22:57 4/13
ChrisSheehan01 Apr 14, 2015
4da7345
Table, TableTest, TableNodeTest, CardMain 15:13 4/14
ChrisSheehan01 Apr 14, 2015
3017c78
Table & TableTest 15:55 4/14
ChrisSheehan01 Apr 14, 2015
80828c8
Table&tabletest 6:56
ChrisSheehan01 Apr 14, 2015
30aa5cf
Table & TableTest
ChrisSheehan01 Apr 15, 2015
56743f9
Updated Table&TableNode classes and tests 22:13
ChrisSheehan01 Apr 15, 2015
feffa28
Finished Table
ChrisSheehan01 Apr 15, 2015
715ab2d
TableTest final
ChrisSheehan01 Apr 15, 2015
2783f41
Current src folder
ChrisSheehan01 Apr 20, 2015
95f9ed0
Updated files 4/20
ChrisSheehan01 Apr 20, 2015
8660730
Delete 12cards0setsMilestone.dat
ChrisSheehan01 Apr 20, 2015
96bd324
Delete 12cards14setsMilestone.dat
ChrisSheehan01 Apr 20, 2015
4c4fc57
Delete TableTestMilestone.class
ChrisSheehan01 Apr 20, 2015
9d2b6b3
Delete TableTestMilestone.java~
ChrisSheehan01 Apr 20, 2015
4edbaf8
Delete TableTestMilestone.java
ChrisSheehan01 Apr 20, 2015
b708f77
Delete README.md
ChrisSheehan01 Apr 20, 2015
80844e0
Initial Game class
ChrisSheehan01 Apr 21, 2015
ef23afc
Game and GameTest Files 4/21
ChrisSheehan01 Apr 21, 2015
d19dccf
Updated Game && GameTest 4/21
ChrisSheehan01 Apr 21, 2015
acbda2c
Game and GameTest
ChrisSheehan01 Apr 22, 2015
2084a02
All files 4/22
ChrisSheehan01 Apr 22, 2015
2353009
Monte Carlo & Updated Classes 4/24
ChrisSheehan01 Apr 24, 2015
3878121
All files
ChrisSheehan01 Apr 24, 2015
d5cfa7d
Delete Card.java~
ChrisSheehan01 Apr 24, 2015
2c80a51
Delete CardMain.java~
ChrisSheehan01 Apr 24, 2015
5fc1719
Delete CardTest.java~
ChrisSheehan01 Apr 24, 2015
b007be5
Delete Deck.java~
ChrisSheehan01 Apr 24, 2015
5e99ae4
Delete DeckTest.java~
ChrisSheehan01 Apr 24, 2015
8a57d4c
Delete Game.java~
ChrisSheehan01 Apr 24, 2015
c3298d5
Delete MonteCarlo.java~
ChrisSheehan01 Apr 24, 2015
b6327b7
Delete GameTest.java~
ChrisSheehan01 Apr 24, 2015
423da41
Delete Table.java~
ChrisSheehan01 Apr 24, 2015
88f1faf
MonteCarlo
ChrisSheehan01 May 1, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added src/.DS_Store
Binary file not shown.
13 changes: 13 additions & 0 deletions src/12cards0setsMilestone.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 12 cards with 0 sets
1 3 3 2
3 3 2 2
1 1 2 1
1 2 3 3
3 2 3 3
1 3 1 3
3 1 2 2
2 2 3 2
1 1 1 1
3 2 1 1
2 1 1 3
2 2 1 3
12 changes: 12 additions & 0 deletions src/12cards14setsMilestone.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
1 1 1 1
1 1 1 2
1 1 1 3
1 1 2 1
1 1 2 2
1 1 2 3
1 1 3 1
1 1 3 2
1 1 3 3
1 2 1 1
1 3 1 1
1 2 1 2
4 changes: 4 additions & 0 deletions src/3cards.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#3cards
1 1 1 1
1 1 1 2
1 1 1 3
12 changes: 12 additions & 0 deletions src/3cards0setsMilestone.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Lines starting with a # character are comments, and ignored
# Blank lines are also ignored, even if they contain whitespace

# All other lines are expected to have 4 integers, separated by spaces
1 1 1 1
1 1 1 2
2 2 2 3

# A file does not need to contain all 81 cards



3 changes: 3 additions & 0 deletions src/3cards1setMilestone.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1 1 1 1
2 2 2 2
3 3 3 3
81 changes: 81 additions & 0 deletions src/81cards.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
1 1 1 1
1 1 1 2
1 1 1 3
1 1 2 1
1 1 2 2
1 1 2 3
1 1 3 1
1 1 3 2
1 1 3 3
1 2 1 1
1 2 1 2
1 2 1 3
1 2 2 1
1 2 2 2
1 2 2 3
1 2 3 1
1 2 3 2
1 2 3 3
1 3 1 1
1 3 1 2
1 3 1 3
1 3 2 1
1 3 2 2
1 3 2 3
1 3 3 1
1 3 3 2
1 3 3 3
2 1 1 1
2 1 1 2
2 1 1 3
2 1 2 1
2 1 2 2
2 1 2 3
2 1 3 1
2 1 3 2
2 1 3 3
2 2 1 1
2 2 1 2
2 2 1 3
2 2 2 1
2 2 2 2
2 2 2 3
2 2 3 1
2 2 3 2
2 2 3 3
2 3 1 1
2 3 1 2
2 3 1 3
2 3 2 1
2 3 2 2
2 3 2 3
2 3 3 1
2 3 3 2
2 3 3 3
3 1 1 1
3 1 1 2
3 1 1 3
3 1 2 1
3 1 2 2
3 1 2 3
3 1 3 1
3 1 3 2
3 1 3 3
3 2 1 1
3 2 1 2
3 2 1 3
3 2 2 1
3 2 2 2
3 2 2 3
3 2 3 1
3 2 3 2
3 2 3 3
3 3 1 1
3 3 1 2
3 3 1 3
3 3 2 1
3 3 2 2
3 3 2 3
3 3 3 1
3 3 3 2
3 3 3 3
Binary file added src/Card.class
Binary file not shown.
114 changes: 112 additions & 2 deletions src/Card.java
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,114 @@
public class Card {
// Create the rest of this class yourself
public class Card{

private int quantity;
private int color;
private int shading;
private int shape;

private String quan;
private String col;
private String shad;
private String shap;

public Card(int cardQuantity, int cardColor, int cardShading, int cardShape) {
if (cardQuantity < 1 || cardQuantity > 3) {
quantity = (((cardQuantity % 3) + 3) % 3) + 1;
}
else {
quantity = cardQuantity;
}
if (cardColor < 1 || cardColor > 3) {
color = (((cardColor % 3) + 3) % 3) + 1;
}
else {
color = cardColor;
}
if (cardShading < 1 || cardShading > 3) {
shading = (((cardShading % 3) + 3) % 3) + 1;
}
else {
shading = cardShading;
}
if (cardShape < 1 || cardShape > 3) {
shape = (((cardShape % 3) + 3) % 3) + 1;
}
else {
shape = cardShape;
}
}

public int getQuantity() {
return quantity;
}

public int getColor() {
return color;
}

public int getShading() {
return shading;
}

public int getShape() {
return shape;
}

public boolean isSet(Card two, Card three) {

int totalQuantity = getQuantity() + two.getQuantity() + three.getQuantity();
int totalColor = getColor() + two.getColor() + three.getColor();
int totalShading = getShading() + two.getShading() + three.getShading();
int totalShape = getShape() + two.getShape() + three.getShape();

if (totalQuantity % 3 == 0 && totalColor % 3 == 0 && totalShading % 3 == 0 && totalShape % 3 == 0) {
return true;
}
else {
return false;
}
}

public String toString() {

if (quantity == 1) {
quan = ("1");
}
else if (quantity == 2) {
quan = ("2");
}
else { // (quantity == 3)
quan = ("3");
}
if (color == 1) {
col = ("R"); //red
}
else if (color == 2) {
col = ("G"); //green
}
else{ //(color == 3)
col = ("P"); //purple
}
if (shading == 1) {
shad = ("O"); //empty
}
else if (shading == 2) {
shad = ("T"); //striped/shaded
}
else{ // (shading == 3)
shad = ("S"); //solid/filled
}
if (shape == 1) {
shap = ("O"); //oval
}
else if (shape == 2) {
shap = ("D"); //diamond
}
else{ // (shading == 3)
shap = ("S"); //squiggle
}
String sequence = quan + col + shad + shap;
return sequence;
}

public boolean equals(Object obj) {
Card that = (Card)obj;
Expand All @@ -9,4 +118,5 @@ public boolean equals(Object obj) {
shading == that.getShading() &&
shape == that.getShape();
}

}
Binary file added src/CardMain.class
Binary file not shown.
14 changes: 14 additions & 0 deletions src/CardMain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class CardMain{
public static void main(String[] args){

Game g = new Game("81cards.txt");
System.out.println(g.numCards());
System.out.println(g.numSets());
g.playRound();
System.out.println(g.numSets());
System.out.println(g.numCards());
}
}



Binary file added src/CardTest.class
Binary file not shown.
Loading