Fix: Order and OrderTest
This commit is contained in:
@@ -11,7 +11,7 @@ public class Order2 extends OrderLogicCard {
|
|||||||
@Override
|
@Override
|
||||||
public void effect(Player player,int index) throws IndexOutOfBoundsException
|
public void effect(Player player,int index) throws IndexOutOfBoundsException
|
||||||
{
|
{
|
||||||
if(index>=2)
|
if(index >= 2 || index < 0)
|
||||||
{
|
{
|
||||||
throw new IndexOutOfBoundsException("index out of bounds");
|
throw new IndexOutOfBoundsException("index out of bounds");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class Order3 extends OrderLogicCard {
|
|||||||
@Override
|
@Override
|
||||||
public void effect(Player player,int index) throws IndexOutOfBoundsException
|
public void effect(Player player,int index) throws IndexOutOfBoundsException
|
||||||
{
|
{
|
||||||
if(index>=3)
|
if(index >= 3 || index < 0)
|
||||||
{
|
{
|
||||||
throw new IndexOutOfBoundsException("index out of bounds");
|
throw new IndexOutOfBoundsException("index out of bounds");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class Order4 extends OrderLogicCard {
|
|||||||
@Override
|
@Override
|
||||||
public void effect(Player player,int index) throws IndexOutOfBoundsException
|
public void effect(Player player,int index) throws IndexOutOfBoundsException
|
||||||
{
|
{
|
||||||
if(index>=4)
|
if(index>=4 || index < 0)
|
||||||
{
|
{
|
||||||
throw new IndexOutOfBoundsException("index out of bounds");
|
throw new IndexOutOfBoundsException("index out of bounds");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class Order5 extends OrderLogicCard {
|
|||||||
@Override
|
@Override
|
||||||
public void effect(Player player,int index) throws IndexOutOfBoundsException
|
public void effect(Player player,int index) throws IndexOutOfBoundsException
|
||||||
{
|
{
|
||||||
if(index>=5)
|
if(index>=5 || index < 0)
|
||||||
{
|
{
|
||||||
throw new IndexOutOfBoundsException("index out of bounds");
|
throw new IndexOutOfBoundsException("index out of bounds");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,5 +35,7 @@ class Order2Test {
|
|||||||
|
|
||||||
Order2 order3 = new Order2(new ArrayList<>());
|
Order2 order3 = new Order2(new ArrayList<>());
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> order3.effect(p1, 2));
|
assertThrows(IndexOutOfBoundsException.class, () -> order3.effect(p1, 2));
|
||||||
|
Order2 order4 = new Order2(new ArrayList<>());
|
||||||
|
assertThrows(IndexOutOfBoundsException.class, () -> order4.effect(p1, -1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,5 +38,6 @@ class Order3Test {
|
|||||||
|
|
||||||
Order3 order3 = new Order3(new ArrayList<>());
|
Order3 order3 = new Order3(new ArrayList<>());
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> order3.effect(p1, 3));
|
assertThrows(IndexOutOfBoundsException.class, () -> order3.effect(p1, 3));
|
||||||
|
assertThrows(IndexOutOfBoundsException.class, () -> order3.effect(p1, -1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,5 +47,6 @@ class Order4Test {
|
|||||||
|
|
||||||
Order4 order3 = new Order4(new ArrayList<>());
|
Order4 order3 = new Order4(new ArrayList<>());
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> order3.effect(p1, 4));
|
assertThrows(IndexOutOfBoundsException.class, () -> order3.effect(p1, 4));
|
||||||
|
assertThrows(IndexOutOfBoundsException.class, () -> order3.effect(p1, -1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,5 +54,6 @@ class Order5Test {
|
|||||||
|
|
||||||
Order5 order3 = new Order5(new ArrayList<>());
|
Order5 order3 = new Order5(new ArrayList<>());
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> order3.effect(p1, 5));
|
assertThrows(IndexOutOfBoundsException.class, () -> order3.effect(p1, 5));
|
||||||
|
assertThrows(IndexOutOfBoundsException.class, () -> order3.effect(p1, -1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user