diff --git a/README.md b/README.md index 64cab1e..67eeb69 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,21 @@ # java-mini-review + Practice writing Java code and using git/GitHub. Complete the github-intro assignment before this one! ## Setup + Fork and clone this repository. Do not forget to fork before cloning! For a refresher on git/GitHub, see the instructions on the github-intro repository. You will not need to create a `sdev220` directory again, you can re-use the exisiting one you have already made. ## **Commit Frequently!** + To receive full credit **you MUST commit frequently** for this assignment. At the very least, make one commit after completing each method. Make sure to push after each commit! ## Coding + Open this repository using VS Code. Edit the Practice.java file to implement the three methods according to the provided javadoc. ## Running Your Code + To run your code, open a terminal and navigate using `cd` to get to the `java-mini-review` directory (folder). Your terminal should show `java-mini-review` in the path. Execute the below command to run your code: ``` @@ -49,4 +54,5 @@ allStartWithA(new String[]{}): true Note that getting the correct output does NOT guarantee that your code is fully working. It is your resposibility to work on your code to make sure it works for all cases, not just the sample test cases provided. ## Submitting + Make a pull request (PR) against the original repository and submit the URL to your PR on Canvas. diff --git a/src/Practice.java b/src/Practice.java index 89acfd9..32c696a 100644 --- a/src/Practice.java +++ b/src/Practice.java @@ -18,6 +18,9 @@ public class Practice { */ public static void printItems(String[] items) { // TODO: Implement this method here! + for (String item : items) { + System.out.println(item); + } } /** @@ -45,7 +48,7 @@ public static void printItems(String[] items) { */ public static boolean moreThanDouble(int a, int b) { // TODO: Delete the dummy return statement and implement this method here! - return false; + return a > 2 * b; } @@ -71,7 +74,12 @@ public static boolean moreThanDouble(int a, int b) { */ public static boolean allStartWithA(String[] words) { // TODO: Delete the dummy return statement and implement this method here! - return false; + for (String word : words) { + if (word.isEmpty() || Character.toLowerCase(word.charAt(0)) != 'a') { + return false; + } + } + return true; } public static void main(String[] args) {