From d948cc7e3dbba27225adfebece900030972e581b Mon Sep 17 00:00:00 2001 From: Attila Vachter Date: Tue, 20 Sep 2022 14:33:29 +0200 Subject: [PATCH] Intermediate - Fix example code array boundaries --- src/com/intermediate/endsection/Gang.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/intermediate/endsection/Gang.java b/src/com/intermediate/endsection/Gang.java index c2181e7..7f05a77 100644 --- a/src/com/intermediate/endsection/Gang.java +++ b/src/com/intermediate/endsection/Gang.java @@ -42,7 +42,7 @@ private boolean isSuccessfulRobbery() { } public void letsRob(Building[] buildings) { - int randomBuildingIndex = randomNumberGenerator.nextInt(buildings.length + 1); + int randomBuildingIndex = randomNumberGenerator.nextInt(buildings.length); System.out.println("-------------------------------"); if (isSuccessfulRobbery()) { System.out.println("The gang managed to rob the following items from the " + buildings[randomBuildingIndex].getName() + ":");