Fix: Orders

This commit is contained in:
rubenpirreram
2026-04-11 15:35:30 +02:00
parent 902e4ac729
commit cc460f414b
8 changed files with 60 additions and 85 deletions
@@ -3,14 +3,19 @@ package it.polimi.ingsw.gc14.Model.Orders;
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.OrderLogicCard;
import it.polimi.ingsw.gc14.Model.Player;
import jdk.jshell.spi.ExecutionControl;
import java.util.*;
public class Order2 extends OrderLogicCard {
public Order2(ArrayList<Player> players) {
public class Order2 extends OrderLogicCard {
public Order2(ArrayList<Player> players)throws NoSuchElementException {
if(players.size()!=2)
throw new NoSuchElementException();
super(players);
}
@Override
public void effect(Player player,int index) throws IndexOutOfBoundsException
protected void effect(Player player,int index) throws IndexOutOfBoundsException
{
if(index >= 2 || index < 0)
{
@@ -4,13 +4,16 @@ import it.polimi.ingsw.gc14.Model.OrderLogicCard;
import it.polimi.ingsw.gc14.Model.Player;
import java.util.ArrayList;
import java.util.NoSuchElementException;
public class Order3 extends OrderLogicCard {
public Order3(ArrayList<Player> players) {
public Order3(ArrayList<Player> players) throws NoSuchElementException{
if(players.size()!=3)
throw new NoSuchElementException();
super(players);
}
@Override
public void effect(Player player,int index) throws IndexOutOfBoundsException
protected void effect(Player player,int index) throws IndexOutOfBoundsException
{
if(index >= 3 || index < 0)
{
@@ -4,13 +4,16 @@ import it.polimi.ingsw.gc14.Model.OrderLogicCard;
import it.polimi.ingsw.gc14.Model.Player;
import java.util.ArrayList;
import java.util.NoSuchElementException;
public class Order4 extends OrderLogicCard {
public Order4(ArrayList<Player> players) {
public Order4(ArrayList<Player> players)throws NoSuchElementException {
if(players.size()!=4)
throw new NoSuchElementException();
super(players);
}
@Override
public void effect(Player player,int index) throws IndexOutOfBoundsException
protected void effect(Player player,int index) throws IndexOutOfBoundsException
{
if(index>=4 || index < 0)
{
@@ -4,13 +4,16 @@ import it.polimi.ingsw.gc14.Model.OrderLogicCard;
import it.polimi.ingsw.gc14.Model.Player;
import java.util.ArrayList;
import java.util.NoSuchElementException;
public class Order5 extends OrderLogicCard {
public Order5(ArrayList<Player> players) {
public Order5(ArrayList<Player> players) throws NoSuchElementException{
if(players.size()!=5)
throw new NoSuchElementException();
super(players);
}
@Override
public void effect(Player player,int index) throws IndexOutOfBoundsException
protected void effect(Player player,int index) throws IndexOutOfBoundsException
{
if(index>=5 || index < 0)
{