Browse Source

Refactoring: change enum Name to Color

main
fdai7736 11 months ago
parent
commit
d78f6b6eee
  1. 14
      src/main/java/de/hsfulda/onses/models/Card.java
  2. 20
      src/test/java/de/hsfulda/onses/CardTest.java

14
src/main/java/de/hsfulda/onses/models/Card.java

@ -2,14 +2,8 @@ package de.hsfulda.onses.models;
public class Card { public class Card {
public enum ecolor {
public enum Color {
RED, BLUE, GREEN, YELLOW, BLACK; 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 { public enum evalue {
ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, DRAWTWO, SKIP, REVERSE, CHOOSE, CHOOSEDRAW; ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, DRAWTWO, SKIP, REVERSE, CHOOSE, CHOOSEDRAW;
@ -21,11 +15,11 @@ public class Card {
}; };
private final int id; private final int id;
private final ecolor color;
private final Color color;
private final evalue value; private final evalue value;
public Card(int id, ecolor color, evalue value)
public Card(int id, Color color, evalue value)
{ {
this.id = id; this.id = id;
this.color = color; this.color = color;
@ -37,7 +31,7 @@ public class Card {
return this.id; return this.id;
} }
public ecolor getColor() {
public Color getColor() {
return this.color; return this.color;
} }

20
src/test/java/de/hsfulda/onses/CardTest.java

@ -17,7 +17,7 @@ public class CardTest {
int expected = 5; int expected = 5;
int ID = 5; int ID = 5;
// act // act
Card testcard = new Card(ID, Card.ecolor.BLACK, Card.evalue.FIVE);
Card testcard = new Card(ID, Card.Color.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 CardTest {
int expected = 112; int expected = 112;
int ID = 112; int ID = 112;
// act // act
Card testcard = new Card(ID, Card.ecolor.BLUE, Card.evalue.CHOOSEDRAW);
Card testcard = new Card(ID, Card.Color.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 CardTest {
public void CardTestGetColorBlue() { public void CardTestGetColorBlue() {
// arrange // arrange
Card.ecolor expected = Card.ecolor.BLUE;
Card.ecolor color = Card.ecolor.BLUE;
Card.Color expected = Card.Color.BLUE;
Card.Color color = Card.Color.BLUE;
// act // act
Card testcard = new Card(9, color, Card.evalue.FIVE); Card testcard = new Card(9, color, Card.evalue.FIVE);
Card.ecolor answer = testcard.getColor();
Card.Color answer = testcard.getColor();
// assert // assert
assertEquals(expected, answer); assertEquals(expected, answer);
} }
@ -56,11 +56,11 @@ public class CardTest {
public void CardTestGetColorBlack() { public void CardTestGetColorBlack() {
// arrange // arrange
Card.ecolor expected = Card.ecolor.BLACK;
Card.ecolor color = Card.ecolor.BLACK;
Card.Color expected = Card.Color.BLACK;
Card.Color color = Card.Color.BLACK;
// act // act
Card testcard = new Card(15, color, Card.evalue.CHOOSE); Card testcard = new Card(15, color, Card.evalue.CHOOSE);
Card.ecolor answer = testcard.getColor();
Card.Color answer = testcard.getColor();
// assert // assert
assertEquals(expected, answer); assertEquals(expected, answer);
} }
@ -74,7 +74,7 @@ public class CardTest {
Card.evalue expected = Card.evalue.THREE; Card.evalue expected = Card.evalue.THREE;
Card.evalue value = Card.evalue.THREE; Card.evalue value = Card.evalue.THREE;
// act // act
Card testcard = new Card(2, Card.ecolor.BLUE, value);
Card testcard = new Card(2, Card.Color.BLUE, value);
Card.evalue answer = testcard.getValue(); Card.evalue answer = testcard.getValue();
// assert // assert
assertEquals(expected, answer); assertEquals(expected, answer);
@ -87,7 +87,7 @@ public class CardTest {
Card.evalue expected = Card.evalue.SKIP; Card.evalue expected = Card.evalue.SKIP;
Card.evalue value = Card.evalue.SKIP; Card.evalue value = Card.evalue.SKIP;
// act // act
Card testcard = new Card(19, Card.ecolor.BLACK, value);
Card testcard = new Card(19, Card.Color.BLACK, value);
Card.evalue answer = testcard.getValue(); Card.evalue answer = testcard.getValue();
// assert // assert
assertEquals(expected, answer); assertEquals(expected, answer);

Loading…
Cancel
Save