Legger til tester for RoboRallyGame og legger til noen begrensinger

Begrenser prioritet på programmeringskort til prioriteter brukt i brettspillet
Begrenser programmet spillet mellomlagrer til et program med nøyaktig 5 kort
Fikser prioriteter brukt i tester
This commit is contained in:
2020-04-24 17:50:57 +02:00
parent 38cec559d9
commit 4f47e7e809
6 changed files with 88 additions and 20 deletions

View File

@@ -17,6 +17,9 @@ public class ProgrammingCard implements Comparable<ProgrammingCard> {
* @param cardAction the action of the card
*/
public ProgrammingCard(int cardPriority, Action cardAction) {
if (cardPriority < 10 || cardPriority > 840 || cardPriority % 10 != 0) {
throw new IllegalArgumentException("You cannot create a programming card not part of the original game.");
}
this.cardPriority = cardPriority;
this.cardAction = cardAction;
}

View File

@@ -131,6 +131,9 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
@Override
public void setProgram(List<ProgrammingCard> program) {
if (program.size() != 5) {
throw new IllegalArgumentException("Invalid program chosen.");
}
this.program = program;
}