mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
lagde en kort classe og testet den
This commit is contained in:
parent
bbc776f1b5
commit
24d38af386
@ -0,0 +1,41 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
import inf112.fiasko.roborally.element_properties.Action;
|
||||
|
||||
/**
|
||||
* This class represents a programming card
|
||||
*/
|
||||
|
||||
public class ProgrammingCard implements ICardWithoutSuit<Integer, Action> {
|
||||
|
||||
private Integer cardValue;
|
||||
private Action cardAction;
|
||||
|
||||
/**
|
||||
* Initializes the value and the action of the card
|
||||
* @param cardValue the value of the card
|
||||
* @param cardAction the action of the card
|
||||
*/
|
||||
public ProgrammingCard(int cardValue,Action cardAction){
|
||||
this.cardValue=cardValue;
|
||||
this.cardAction=cardAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the card
|
||||
* @return the value of the card
|
||||
*/
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return cardValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the action the card should perform
|
||||
* @return the action of the card
|
||||
*/
|
||||
@Override
|
||||
public Action getSymbol() {
|
||||
return cardAction;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
import inf112.fiasko.roborally.element_properties.Action;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ProgrammingCardTest {
|
||||
|
||||
private ProgrammingCard programmingCard1;
|
||||
private ProgrammingCard programmingCard2;
|
||||
private ProgrammingCard programmingCard3;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
programmingCard1 = new ProgrammingCard(5, Action.MOVE_1);
|
||||
programmingCard2 = new ProgrammingCard(234, Action.ROTATE_LEFT);
|
||||
programmingCard3 = new ProgrammingCard(2334, Action.ROTATE_LEFT);
|
||||
}
|
||||
@Test
|
||||
public void testGetProgrammingCardAction(){
|
||||
assertEquals(Action.MOVE_1,programmingCard1.getSymbol());
|
||||
assertEquals(Action.ROTATE_LEFT,programmingCard2.getSymbol());
|
||||
}
|
||||
@Test
|
||||
public void testGetProgrammingCardValue(){
|
||||
assertEquals((Integer) 5,programmingCard1.getValue());
|
||||
assertEquals((Integer) 234,programmingCard2.getValue());
|
||||
assertEquals((Integer) 2334,programmingCard3.getValue());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user