This repo contains some short exercises to help get you used to Java, and also to prepare you for A3. You do not need to submit these exercises for credit. If you'd like to play around with these exercises, start by taking a look at ConversationIntro.java
. This file contains stubs for the following methods, which you'll fill in:
public int plusOne(int n)
public int timesTwo(int n)
public int squared(int n)
public int intDivideBy7(int n)
public double doubleDivideBy7(int n)
public static boolean isPrime(int n)
public boolean isEven(int n)
public static boolean isComma(String s)
public boolean isPunctuation(String s)
public String mirrorWord(String s)
public static int[] wholeNumbers(int n)
public static int[] squares(int n)
The outcomes of these exercises are tested in the ConversationIntroTest
class (which is defined in the file ConversationIntroTest.java
). If you run the project as given to you, it will fail on the first test. As you complete the functions with working code, it will begin to pass the tests instead. When you have completed every exercise, it should pass all the tests.
These tests were implemented using a helpful Java package called jUnit
(so you'll see a lot of references to that sprinkled around in ConversationIntroTest.java
and TestRunner.java
). If you're curious about how this works, feel free to explore those files.
Later on we will talk about writing your own unit tests (which are very helpful for making sure your code is working as expected!)