mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-02-01 07:39:35 +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
|
* 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;
|
private final Action cardAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the value and the action of the card
|
* Initializes the priority and the action of the card
|
||||||
* @param cardValue the value of the card
|
* @param cardPriority the priority of the card
|
||||||
* @param cardAction the action of the card
|
* @param cardAction the action of the card
|
||||||
*/
|
*/
|
||||||
public ProgrammingCard(int cardValue, Action cardAction){
|
public ProgrammingCard(int cardPriority, Action cardAction) {
|
||||||
this.cardValue = cardValue;
|
this.cardPriority = cardPriority;
|
||||||
this.cardAction = cardAction;
|
this.cardAction = cardAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the programming card
|
* Gets the priority of the programming card
|
||||||
* @return The programming card value
|
* @return The programming card priority
|
||||||
*/
|
*/
|
||||||
public int getValue() {
|
public int getPriority() {
|
||||||
return cardValue;
|
return cardPriority;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the symbol of the programming card
|
* Gets the action of the programming card
|
||||||
* @return The programming card symbol
|
* @return The programming card action
|
||||||
*/
|
*/
|
||||||
public Action getSymbol() {
|
public Action getAction() {
|
||||||
return cardAction;
|
return cardAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
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);
|
programmingCard3 = new ProgrammingCard(2334, Action.ROTATE_LEFT);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testGetProgrammingCardAction(){
|
public void testGetProgrammingCardAction() {
|
||||||
assertEquals(Action.MOVE_1, programmingCard1.getSymbol());
|
assertEquals(Action.MOVE_1, programmingCard1.getAction());
|
||||||
assertEquals(Action.ROTATE_LEFT, programmingCard2.getSymbol());
|
assertEquals(Action.ROTATE_LEFT, programmingCard2.getAction());
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testGetProgrammingCardValue(){
|
public void testGetProgrammingCardValue() {
|
||||||
assertEquals(5, programmingCard1.getValue());
|
assertEquals(5, programmingCard1.getPriority());
|
||||||
assertEquals(234, programmingCard2.getValue());
|
assertEquals(234, programmingCard2.getPriority());
|
||||||
assertEquals(2334, programmingCard3.getValue());
|
assertEquals(2334, programmingCard3.getPriority());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user