Question
Creating card game SET in Java and below I have code that determines if the random set of cards is a set or not, but
Creating card game SET in Java and below I have code that determines if the random set of cards is a set or not, but when I run my code its never a set because the number that's prints out is always 0. if there are 0 shapes its never going to be a set, the number that prints out should either be a 1, 2, or a three and cant seem to find where in my code is the reason its always 0. I dont know whether its a problem with my Triad, TestTriad, or my Board class.
// Board class
import java.util.Arrays;
import java.util.ArrayList;
public class Board { private ArrayList
//Triad Class
public class Triad { private Card[] cards; public Triad(Card c1, Card c2, Card c3) { cards = new Card[3]; cards[0] = c1; cards[1] = c2; cards[2] = c3; }
public static boolean isSet(Card card_one, Card card_two, Card card_three) { return card_one.getColor()==card_two.getColor() && card_two.getColor()==card_three.getColor() && card_one.getShading()==card_two.getShading() && card_two.getShading()==card_three.getShading() && card_one.getShape()==card_two.getShape() && card_two.getShape()==card_three.getShape() ;
}
// Testing Triad
public class TestTriad { public static void main(String[] args) { Deck d = new Deck(); d.shuffle(); Board b = new Board(d); System.out.println(" " + b.getCard(0, 0) + " "); System.out.println(b); if(Triad.isSet(b.getCard(0, 0), b.getCard(0, 1), b.getCard(0, 2))) System.out.println("set"); System.out.println("not a set"); }
}
// Example of what I get when I run the code
Solid Diamond Red 0
Solid Diamond Red 0 Striped Diamond Red 0 Striped Squiggle Green 0
not a set
Wondering if anyone can see what I've missed, thankyou
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started