From 67f6b4681f5ddb2a764327577c4a3a1671b284d1 Mon Sep 17 00:00:00 2001 From: Charlie Date: Sat, 2 Aug 2014 16:46:43 -0400 Subject: [PATCH] getColor is now an array instead of a stupid method oops --- src/ca/gibstick/discosheep/DiscoParty.java | 79 ++++++---------------- 1 file changed, 21 insertions(+), 58 deletions(-) diff --git a/src/ca/gibstick/discosheep/DiscoParty.java b/src/ca/gibstick/discosheep/DiscoParty.java index 946fb35..81ef8e8 100644 --- a/src/ca/gibstick/discosheep/DiscoParty.java +++ b/src/ca/gibstick/discosheep/DiscoParty.java @@ -247,7 +247,7 @@ public class DiscoParty { public void setDoFloor(boolean doFloor) { this.doFloor = doFloor; } - + public DiscoParty setGuestNumber(String key, int n) throws IllegalArgumentException { if (getMaxGuestNumbers().containsKey(key.toUpperCase())) { if (n <= getMaxGuestNumbers().get(key.toUpperCase()) && n >= 0) { // so that /ds defaults can take 0 as arg @@ -395,62 +395,25 @@ public class DiscoParty { entity.setVelocity(newVel); } - private Color getColor(int i) { - Color c = null; - if (i == 1) { - c = Color.AQUA; - } - if (i == 2) { - c = Color.BLACK; - } - if (i == 3) { - c = Color.BLUE; - } - if (i == 4) { - c = Color.FUCHSIA; - } - if (i == 5) { - c = Color.GRAY; - } - if (i == 6) { - c = Color.GREEN; - } - if (i == 7) { - c = Color.LIME; - } - if (i == 8) { - c = Color.MAROON; - } - if (i == 9) { - c = Color.NAVY; - } - if (i == 10) { - c = Color.OLIVE; - } - if (i == 11) { - c = Color.ORANGE; - } - if (i == 12) { - c = Color.PURPLE; - } - if (i == 13) { - c = Color.RED; - } - if (i == 14) { - c = Color.SILVER; - } - if (i == 15) { - c = Color.TEAL; - } - if (i == 16) { - c = Color.WHITE; - } - if (i == 17) { - c = Color.YELLOW; - } - - return c; - } + Color[] getColor = { + Color.AQUA, + Color.BLACK, + Color.BLUE, + Color.FUCHSIA, + Color.GRAY, + Color.GREEN, + Color.LIME, + Color.MAROON, + Color.NAVY, + Color.OLIVE, + Color.ORANGE, + Color.PURPLE, + Color.RED, + Color.SILVER, + Color.TEAL, + Color.WHITE, + Color.YELLOW + }; void updateAll() { for (Sheep sheeple : getSheepList()) { @@ -521,7 +484,7 @@ public class DiscoParty { int numColours = r.nextInt(3) + 1; Color[] colourArray = new Color[numColours]; for (int i = 0; i < numColours; i++) { - colourArray[i] = getColor(r.nextInt(17) + 1); + colourArray[i] = getColor[r.nextInt(17)]; } // randomize effects