Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions src/12cards14setsMilestone.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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
1 1 1 1
2 2 2 2
2 3 2 1
12 changes: 12 additions & 0 deletions src/12cards4setsMilestone.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 2 1 1
1 2 1 2
1 2 1 3
2 1 1 1
2 1 1 2
2 1 1 3
2 2 1 1
2 2 1 2
2 2 1 3
14 changes: 14 additions & 0 deletions src/14cardsMilestone.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
1 1 1 1
1 1 1 2
1 1 1 3
2 1 1 1
2 1 1 2
2 1 1 3
3 1 1 1
3 1 1 2
3 1 1 3
1 2 1 1
1 2 1 2
1 2 1 3
2 2 2 2
3 3 3 3
13 changes: 13 additions & 0 deletions src/14in12Milestone.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# this collection has 14 sets
1 1 1 1
1 1 1 2
1 1 1 3
2 2 2 1
2 2 2 2
2 2 2 3
3 3 3 1
3 3 3 2
3 3 3 3
1 2 2 2
1 3 3 3
1 2 2 1
17 changes: 17 additions & 0 deletions src/15cards0setsin12Milestone.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# The first 12 cards have 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
# These cards add some sets.
2 2 2 2
3 3 3 3
1 2 1 2
15 changes: 15 additions & 0 deletions src/15cards19setsMilestone.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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
1 1 1 1
2 2 2 2
2 3 2 1
18 changes: 18 additions & 0 deletions src/15cardsMilestone.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# a deck where the first 12 cards contain a set (3 actually)
# 3 purple solid diamond, 2 green open diamond, 1 red striped diamond
3 1 3 2
3 3 3 2
2 3 3 2
2 1 1 2
2 3 2 1
2 1 2 1
2 1 2 3
1 2 2 2
2 3 2 2
1 2 2 3
3 3 2 1
3 1 2 1
# extra cards for when the set is removed
1 3 2 1
1 1 2 1
1 1 3 1
18 changes: 18 additions & 0 deletions src/18cards0setsin15Milestone.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
1 1 1 1
1 1 1 2
1 1 2 1
1 1 2 2
1 2 1 1
1 2 1 2
1 2 2 1
1 2 2 2
2 1 1 1
2 1 1 2
2 1 2 1
2 1 2 2
2 2 1 1
2 2 1 2
2 2 2 1
2 2 2 2
3 3 3 3
3 1 1 1
3 changes: 3 additions & 0 deletions src/3cards.txt
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
7 changes: 7 additions & 0 deletions src/7cardsMilestone.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1 1 1 1
2 2 2 2
3 3 3 3
1 2 1 2
2 1 2 1
3 3 1 1
1 2 3 1
Binary file added src/Card.class
Binary file not shown.
117 changes: 116 additions & 1 deletion src/Card.java
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,12 +1,127 @@
import junit.framework.TestCase;

public class Card {
// Create the rest of this class yourself

private int[] c = new int[4];
private int quantity;
private int color;
private int shading;
private int shape;

public Card(int cardQuan, int cardColor, int cardShading, int cardShape) {

quantity = cardQuan;
color = cardColor;
shading = cardShading;
shape = cardShape;

c[0] = quantity;
c[1] = color;
c[2] = shading;
c[3] = shape;

for (int i = 0; i < 4; i++) {
if (c[i] >= 1 && c[i] <= 3) {
c[i] = c[i];
}
else {
if (c[i] < 0) {
c[i] = (((c[i] % 3) + 3) % 3) + 1;
}
else {
c[i] = c[i] % 3 + 1;
}
}
}

quantity = c[0];
color = c[1];
shading = c[2];
shape = c[3];

}
public boolean equals(Object obj) {

Card that = (Card)obj;

return quantity == that.getQuantity() &&
color == that.getColor() &&
shading == that.getShading() &&
shape == that.getShape();
}
public boolean isSet(Card c2, Card c3) {

int quanSum = quantity + c2.getQuantity() + c3.getQuantity();
int colorSum = color + c2.getColor() + c3.getColor();
int shadingSum = shading + c2.getShading() + c3.getShading();
int shapeSum = shape + c2.getShape() + c3.getShape();

if ((quanSum % 3 == 0) && (colorSum % 3 == 0) && (shadingSum % 3 == 0) && (shapeSum % 3 == 0)) {
return true;
}
else {
return false;
}
}

public String toString() {
String strQuantity = "";
String strColor = "";
String strShad = "";
String strShape = "";

if (quantity == 1) {
strQuantity += "1";
}
else if (quantity == 2) {
strQuantity += "2";
}
else if (quantity == 3) {
strQuantity += "3";
}
if (color == 1) {
strColor += "R";
}
else if (color == 2) {
strColor += "G";
}
else if(color == 3) {
strColor += "P";
}
if (shading == 1) {
strShad += "O";
}
else if (shading == 2) {
strShad += "T";
}
else if (shading == 3) {
strShad += "S";
}
if (shape == 1) {
strShape += "O";
}
else if (shape == 2) {
strShape += "D";
}
else if (shape == 3) {
strShape += "S";
}
return strQuantity + strColor + strShad + strShape;
}

public int getQuantity() {
return quantity;
}

public int getColor() {
return color;
}

public int getShading() {
return shading;
}

public int getShape() {
return shape;
}
}
Loading