diff --git a/src/Practice.java b/src/Practice.java index 89acfd9..50d8379 100644 --- a/src/Practice.java +++ b/src/Practice.java @@ -14,10 +14,16 @@ public class Practice { * sdev * 220 * + * + * * @param items an array of strings to print */ + public static void printItems(String[] items) { // TODO: Implement this method here! + for (String item : items) { + System.out.println(item); + } } /** @@ -44,7 +50,9 @@ public static void printItems(String[] items) { * @return true if a is strictly more than twice the value of b, false otherwise */ public static boolean moreThanDouble(int a, int b) { - // TODO: Delete the dummy return statement and implement this method here! + if (a > b * 2) { + return true; + } return false; } @@ -70,8 +78,17 @@ public static boolean moreThanDouble(int a, int b) { * @return true if every word starts with A (case-insensitive), false otherwise. */ public static boolean allStartWithA(String[] words) { - // TODO: Delete the dummy return statement and implement this method here! - return false; + if (words == null || words.length == 0) { + return true; + } + + for (String word : words) { + if (!word.toLowerCase().startsWith("a")) { + return false; + } + } + + return true; } public static void main(String[] args) { @@ -82,13 +99,11 @@ public static void main(String[] args) { System.out.println(); System.out.println("Calling printItems(new String[]{\"hello\", \"world\"})"); printItems(new String[]{"hello", "world"}); - System.out.println(); System.out.println("///// More than Double /////"); System.out.println("moreThanDouble(10, 3): " + moreThanDouble(10, 3)); System.out.println("moreThanDouble(6, 4): " + moreThanDouble(6, 4)); System.out.println("moreThanDouble(4, 2): " + moreThanDouble(4, 2)); - System.out.println(); System.out.println("///// All Start With A /////"); System.out.println("allStartWithA(new String[]{\"alligators\", \"are\", \"AWESOME\"}): " + allStartWithA(new String[]{"alligators", "are", "AWESOME"})); @@ -96,4 +111,12 @@ public static void main(String[] args) { System.out.println("allStartWithA(new String[]{}): " + allStartWithA(new String[]{})); System.out.println(); } -} \ No newline at end of file +} +/* + + + + + + */ +