Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int hrs = match.getSchedule().getDateTime().getHour();
- int min = match.getSchedule().getDateTime().getMinute();
- if ((hrs > 20 || (hrs == 20 && min > 0)) && (this instanceof Stadium)) {
- throw new AddingMatchException("Match starts too late to be added to Stadium, try earlier than 8pm!");
- } else {
- ArrayList<Athlete> athletesList = match.getAthletesList();
- if (athletesList == null || athletesList.isEmpty()) {
- throw new SportDisciplineException("No athletes assigned to the match.");
- }
- for (Athlete athlete : athletesList) {
- if (athlete.getDiscipline() != this.getDiscipline()) {
- throw new SportDisciplineException("Unable to add the match to the venue, as the venue accepts matches of discipline " + this.getDiscipline() + ", and athlete " + athlete.getName() + " assigned to the match competes in discipline " + athlete.getDiscipline() + ".");
- }
- }
- for (int i = 0; i < listOfMatches.length; i++) {
- if (listOfMatches[i] == null) {
- listOfMatches[i] = match;
- System.out.println("Successfully added match: \n" + match.toString());
- break;
- } else if (i == listOfMatches.length - 1) {
- throw new AddingMatchException("List of matches is full!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement