Browse Source

Refactoring: change Class name Cards to Card

main
fdai7736 11 months ago
parent
commit
9b9dbda152
  1. 4
      src/main/java/de/hsfulda/onses/models/Card.java
  2. 40
      src/test/java/de/hsfulda/onses/CardTest.java

4
src/main/java/de/hsfulda/onses/models/Cards.java → src/main/java/de/hsfulda/onses/models/Card.java

@ -1,6 +1,6 @@
package de.hsfulda.onses.models; package de.hsfulda.onses.models;
public class Cards {
public class Card {
public enum ecolor { public enum ecolor {
RED, BLUE, GREEN, YELLOW, BLACK; RED, BLUE, GREEN, YELLOW, BLACK;
@ -25,7 +25,7 @@ public class Cards {
private final evalue value; private final evalue value;
public Cards(int id, ecolor color, evalue value)
public Card(int id, ecolor color, evalue value)
{ {
this.id = id; this.id = id;
this.color = color; this.color = color;

40
src/test/java/de/hsfulda/onses/CardsTest.java → src/test/java/de/hsfulda/onses/CardTest.java

@ -5,9 +5,9 @@ import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
import de.hsfulda.onses.models.Cards;
import de.hsfulda.onses.models.Card;
public class CardsTest {
public class CardTest {
@Test @Test
@DisplayName("CardGetID5") @DisplayName("CardGetID5")
@ -17,7 +17,7 @@ public class CardsTest {
int expected = 5; int expected = 5;
int ID = 5; int ID = 5;
// act // act
Cards testcard = new Cards(ID, Cards.ecolor.BLACK, Cards.evalue.FIVE);
Card testcard = new Card(ID, Card.ecolor.BLACK, Card.evalue.FIVE);
int answer = testcard.getId(); int answer = testcard.getId();
// assert // assert
assertEquals(expected, answer); assertEquals(expected, answer);
@ -31,7 +31,7 @@ public class CardsTest {
int expected = 112; int expected = 112;
int ID = 112; int ID = 112;
// act // act
Cards testcard = new Cards(ID, Cards.ecolor.BLUE, Cards.evalue.CHOOSEDRAW);
Card testcard = new Card(ID, Card.ecolor.BLUE, Card.evalue.CHOOSEDRAW);
int answer = testcard.getId(); int answer = testcard.getId();
// assert // assert
assertEquals(expected, answer); assertEquals(expected, answer);
@ -43,11 +43,11 @@ public class CardsTest {
public void CardTestGetColorBlue() { public void CardTestGetColorBlue() {
// arrange // arrange
Cards.ecolor expected = Cards.ecolor.BLUE;
Cards.ecolor color = Cards.ecolor.BLUE;
Card.ecolor expected = Card.ecolor.BLUE;
Card.ecolor color = Card.ecolor.BLUE;
// act // act
Cards testcard = new Cards(9, color, Cards.evalue.FIVE);
Cards.ecolor answer = testcard.getColor();
Card testcard = new Card(9, color, Card.evalue.FIVE);
Card.ecolor answer = testcard.getColor();
// assert // assert
assertEquals(expected, answer); assertEquals(expected, answer);
} }
@ -56,11 +56,11 @@ public class CardsTest {
public void CardTestGetColorBlack() { public void CardTestGetColorBlack() {
// arrange // arrange
Cards.ecolor expected = Cards.ecolor.BLACK;
Cards.ecolor color = Cards.ecolor.BLACK;
Card.ecolor expected = Card.ecolor.BLACK;
Card.ecolor color = Card.ecolor.BLACK;
// act // act
Cards testcard = new Cards(15, color, Cards.evalue.CHOOSE);
Cards.ecolor answer = testcard.getColor();
Card testcard = new Card(15, color, Card.evalue.CHOOSE);
Card.ecolor answer = testcard.getColor();
// assert // assert
assertEquals(expected, answer); assertEquals(expected, answer);
} }
@ -71,11 +71,11 @@ public class CardsTest {
public void CardTestGetValueThree() { public void CardTestGetValueThree() {
// arrange // arrange
Cards.evalue expected = Cards.evalue.THREE;
Cards.evalue value = Cards.evalue.THREE;
Card.evalue expected = Card.evalue.THREE;
Card.evalue value = Card.evalue.THREE;
// act // act
Cards testcard = new Cards(2, Cards.ecolor.BLUE, value);
Cards.evalue answer = testcard.getValue();
Card testcard = new Card(2, Card.ecolor.BLUE, value);
Card.evalue answer = testcard.getValue();
// assert // assert
assertEquals(expected, answer); assertEquals(expected, answer);
} }
@ -84,11 +84,11 @@ public class CardsTest {
public void CardTestGetValueSkip() { public void CardTestGetValueSkip() {
// arrange // arrange
Cards.evalue expected = Cards.evalue.SKIP;
Cards.evalue value = Cards.evalue.SKIP;
Card.evalue expected = Card.evalue.SKIP;
Card.evalue value = Card.evalue.SKIP;
// act // act
Cards testcard = new Cards(19, Cards.ecolor.BLACK, value);
Cards.evalue answer = testcard.getValue();
Card testcard = new Card(19, Card.ecolor.BLACK, value);
Card.evalue answer = testcard.getValue();
// assert // assert
assertEquals(expected, answer); assertEquals(expected, answer);
} }
Loading…
Cancel
Save