Browse Source

Merge branch 'AddingCardsModel' into 'main'

Adding Cards Model

See merge request fdai7736/onses!6
main
fdai7920 11 months ago
parent
commit
36c7810635
  1. 47
      src/main/java/de/hsfulda/onses/models/Cards.java
  2. 96
      src/test/java/de/hsfulda/onses/CardsTest.java

47
src/main/java/de/hsfulda/onses/models/Cards.java

@ -0,0 +1,47 @@
package de.hsfulda.onses.models;
public class Cards {
public enum ecolor {
RED, BLUE, GREEN, YELLOW, BLACK;
private static final ecolor[] colors = ecolor.values();
public static ecolor getColors (int n)
{
return ecolor.colors[n];
}
};
public enum evalue {
ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, DRAWTWO, SKIP, REVERSE, CHOOSE, CHOOSEDRAW;
private static final evalue[] values = evalue.values();
public static evalue getValue(int n) {
return evalue.values[n];
}
};
private final int id;
private final ecolor color;
private final evalue value;
public Cards(int id, ecolor color, evalue value)
{
this.id = id;
this.color = color;
this.value = value;
}
public int getId() {
return this.id;
}
public ecolor getColor() {
return this.color;
}
public evalue getValue() {
return this.value;
}
}

96
src/test/java/de/hsfulda/onses/CardsTest.java

@ -0,0 +1,96 @@
package de.hsfulda.onses;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import de.hsfulda.onses.models.Cards;
public class CardsTest {
@Test
@DisplayName("CardGetID5")
public void CardTestGetID5() {
// arrange
int expected = 5;
int ID = 5;
// act
Cards testcard = new Cards(ID, Cards.ecolor.BLACK, Cards.evalue.FIVE);
int answer = testcard.getId();
// assert
assertEquals(expected, answer);
}
@Test
@DisplayName("CardGetID112")
public void CardTestGetID112() {
// arrange
int expected = 112;
int ID = 112;
// act
Cards testcard = new Cards(ID, Cards.ecolor.BLUE, Cards.evalue.CHOOSEDRAW);
int answer = testcard.getId();
// assert
assertEquals(expected, answer);
}
@Test
@DisplayName("CardGetColorBlue")
public void CardTestGetColorBlue() {
// arrange
Cards.ecolor expected = Cards.ecolor.BLUE;
Cards.ecolor color = Cards.ecolor.BLUE;
// act
Cards testcard = new Cards(9, color, Cards.evalue.FIVE);
Cards.ecolor answer = testcard.getColor();
// assert
assertEquals(expected, answer);
}
@Test
@DisplayName("CardGetColorBlack")
public void CardTestGetColorBlack() {
// arrange
Cards.ecolor expected = Cards.ecolor.BLACK;
Cards.ecolor color = Cards.ecolor.BLACK;
// act
Cards testcard = new Cards(15, color, Cards.evalue.CHOOSE);
Cards.ecolor answer = testcard.getColor();
// assert
assertEquals(expected, answer);
}
@Test
@DisplayName("CardGetValueThree")
public void CardTestGetValueThree() {
// arrange
Cards.evalue expected = Cards.evalue.THREE;
Cards.evalue value = Cards.evalue.THREE;
// act
Cards testcard = new Cards(2, Cards.ecolor.BLUE, value);
Cards.evalue answer = testcard.getValue();
// assert
assertEquals(expected, answer);
}
@Test
@DisplayName("CardGetValueSkip")
public void CardTestGetValueSkip() {
// arrange
Cards.evalue expected = Cards.evalue.SKIP;
Cards.evalue value = Cards.evalue.SKIP;
// act
Cards testcard = new Cards(19, Cards.ecolor.BLACK, value);
Cards.evalue answer = testcard.getValue();
// assert
assertEquals(expected, answer);
}
}
Loading…
Cancel
Save