Browse Source
Merge branch 'ChangeCards' into 'main'
Merge branch 'ChangeCards' into 'main'
Refactoring Cards See merge request fdai7736/onses!8main
fdai7736
11 months ago
3 changed files with 61 additions and 67 deletions
-
41src/main/java/de/hsfulda/onses/models/Card.java
-
47src/main/java/de/hsfulda/onses/models/Cards.java
-
40src/test/java/de/hsfulda/onses/CardTest.java
@ -0,0 +1,41 @@ |
|||
package de.hsfulda.onses.models; |
|||
|
|||
public class Card { |
|||
private int id; |
|||
private Color color; |
|||
private Value value; |
|||
|
|||
public enum Color { |
|||
RED, BLUE, GREEN, YELLOW, BLACK; |
|||
}; |
|||
public enum Value { |
|||
ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, DRAWTWO, SKIP, REVERSE, CHOOSE, CHOOSEDRAW; |
|||
}; |
|||
|
|||
public Card setId(int id) { |
|||
this.id = id; |
|||
return this; |
|||
} |
|||
|
|||
public Card setColor(Color color) { |
|||
this.color = color; |
|||
return this; |
|||
} |
|||
|
|||
public Card setValue(Value value) { |
|||
this.value = value; |
|||
return this; |
|||
} |
|||
|
|||
public int getId() { |
|||
return this.id; |
|||
} |
|||
|
|||
public Color getColor() { |
|||
return this.color; |
|||
} |
|||
|
|||
public Value getValue() { |
|||
return this.value; |
|||
} |
|||
} |
@ -1,47 +0,0 @@ |
|||
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; |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue