public Set(Card c1, Card c2, Card c3) { cards = new List<Card>(); cards.Add(c1); cards.Add(c2); cards.Add(c3); }
/// <summary> /// Returns true if three cards make up a set /// </summary> /// <param name="card 1"></param> /// <param name="card 2"></param> /// <param name="card 3"></param> /// <returns></returns> public bool IsASet(Card c1, Card c2, Card c3) { bool isASet = false; if ((c1.hasSameColor(c2, c3) || c1.hasDifferentColors(c2, c3)) && (c1.hasSameShading(c2, c3) || c1.hasDifferentShadings(c2, c3)) && (c1.hasSameShape(c2, c3) || c1.hasDifferentShapes(c2, c3)) && (c1.hasSameNumber(c2, c3) || c1.hasDifferentNumbers(c2, c3))) { isASet = true; } return isASet; }
/// <summary> /// Adds a card to the board /// </summary> /// <param name="card"></param> internal void AddCard(Card card) { cards.Add(card); }
internal bool hasSameShape(Card c2, Card c3) { return c2.shape == this.shape && c3.shape == this.shape; }
internal bool hasSameNumber(Card c2, Card c3) { return c2.number == this.number && c3.number == this.number; }
internal bool hasSameShading(Card c2, Card c3) { return c2.shading == this.shading && c3.shading == this.shading; }
internal bool hasSameColor(Card c2, Card c3) { return c2.color == this.color && c3.color == this.color; }
internal bool hasDifferentShapes(Card c2, Card c3) { return c2.shape != this.shape && c3.shape != this.shape && c2.shape != c3.shape; }
internal bool hasDifferentShadings(Card c2, Card c3) { return c2.shading != this.shading && c3.shading != this.shading && c2.shading != c3.shading; }
internal bool hasDifferentNumbers(Card c2, Card c3) { return c2.number != this.number && c3.number != this.number && c2.number != c3.number; }
internal bool hasDifferentColors(Card c2, Card c3) { return c2.color != this.color && c3.color != this.color && c2.color != c3.color; }