mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Fjerner generalitet i ProgrammingCard
Bytter navn fra value til priority for bedre beskrivelse av verdien Gjør programmeringskort sammenlignbare slik at de kan sorteres
This commit is contained in:
parent
c207c56bca
commit
326f4d5755
@ -5,39 +5,44 @@ import inf112.fiasko.roborally.element_properties.Action;
|
||||
/**
|
||||
* This class represents a programming card
|
||||
*/
|
||||
public class ProgrammingCard {
|
||||
public class ProgrammingCard implements Comparable<ProgrammingCard> {
|
||||
|
||||
private final int cardValue;
|
||||
private final int cardPriority;
|
||||
private final Action cardAction;
|
||||
|
||||
/**
|
||||
* Initializes the value and the action of the card
|
||||
* @param cardValue the value of the card
|
||||
* Initializes the priority and the action of the card
|
||||
* @param cardPriority the priority of the card
|
||||
* @param cardAction the action of the card
|
||||
*/
|
||||
public ProgrammingCard(int cardValue, Action cardAction){
|
||||
this.cardValue = cardValue;
|
||||
public ProgrammingCard(int cardPriority, Action cardAction) {
|
||||
this.cardPriority = cardPriority;
|
||||
this.cardAction = cardAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the programming card
|
||||
* @return The programming card value
|
||||
* Gets the priority of the programming card
|
||||
* @return The programming card priority
|
||||
*/
|
||||
public int getValue() {
|
||||
return cardValue;
|
||||
public int getPriority() {
|
||||
return cardPriority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the symbol of the programming card
|
||||
* @return The programming card symbol
|
||||
* Gets the action of the programming card
|
||||
* @return The programming card action
|
||||
*/
|
||||
public Action getSymbol() {
|
||||
public Action getAction() {
|
||||
return cardAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getValue() + " " + this.cardAction.toString();
|
||||
return this.getPriority() + " " + this.cardAction.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ProgrammingCard programmingCard) {
|
||||
return this.cardPriority - programmingCard.cardPriority;
|
||||
}
|
||||
}
|
||||
|
@ -18,14 +18,14 @@ public class ProgrammingCardTest {
|
||||
programmingCard3 = new ProgrammingCard(2334, Action.ROTATE_LEFT);
|
||||
}
|
||||
@Test
|
||||
public void testGetProgrammingCardAction(){
|
||||
assertEquals(Action.MOVE_1, programmingCard1.getSymbol());
|
||||
assertEquals(Action.ROTATE_LEFT, programmingCard2.getSymbol());
|
||||
public void testGetProgrammingCardAction() {
|
||||
assertEquals(Action.MOVE_1, programmingCard1.getAction());
|
||||
assertEquals(Action.ROTATE_LEFT, programmingCard2.getAction());
|
||||
}
|
||||
@Test
|
||||
public void testGetProgrammingCardValue(){
|
||||
assertEquals(5, programmingCard1.getValue());
|
||||
assertEquals(234, programmingCard2.getValue());
|
||||
assertEquals(2334, programmingCard3.getValue());
|
||||
public void testGetProgrammingCardValue() {
|
||||
assertEquals(5, programmingCard1.getPriority());
|
||||
assertEquals(234, programmingCard2.getPriority());
|
||||
assertEquals(2334, programmingCard3.getPriority());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user