diff --git a/src/main/java/inf112/fiasko/roborally/objects/ProgrammingCard.java b/src/main/java/inf112/fiasko/roborally/objects/ProgrammingCard.java index d25e69d..20a8cc5 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/ProgrammingCard.java +++ b/src/main/java/inf112/fiasko/roborally/objects/ProgrammingCard.java @@ -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; } } diff --git a/src/test/java/inf112/fiasko/roborally/objects/ProgrammingCardTest.java b/src/test/java/inf112/fiasko/roborally/objects/ProgrammingCardTest.java index 16f6740..a6ce3ec 100644 --- a/src/test/java/inf112/fiasko/roborally/objects/ProgrammingCardTest.java +++ b/src/test/java/inf112/fiasko/roborally/objects/ProgrammingCardTest.java @@ -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()); } }