commit f08f27373e93baa8187ff0dc3475380150ad70ae
Author: rodbailey <rodney.p.bailey@gmail.com>
Date:   Mon Jul 11 20:41:54 2016 +1000

    Added more unit tests for IntegerCalculatorValue

diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/IntegerCalculatorValue.java b/Calculator/src/main/java/com/example/rodbailey/keypad/IntegerCalculatorValue.java
index 7628b09..3e626b9 100644
--- a/Calculator/src/main/java/com/example/rodbailey/keypad/IntegerCalculatorValue.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/IntegerCalculatorValue.java
@@ -8,54 +8,86 @@ import org.valid4j.Assertive;
 /**
  * A value that can be considered by the IntegerCalculator. This value might be the current
  * value of the "memory" or the value of the "register" in the calculator. The results of mathematical
  * operations cannot exceed what can be stored in an IntegerCalculatorValue, otherwise you get an Underflow or
  * Oveflow error.
  */
 public class IntegerCalculatorValue {
 
+    /** The lowest value an IntegerCalculatorValue can have (inclusive) */
     public static final long VALUE_LOWEST = -9999;
 
+    /** The highest value an IntegerCalculatorValue can have (exclusive) */
     public static final long VALUE_HIGHEST = 9999;
 
     private long value;
 
+    /**
+     * Default constructor. Constructs an IntegerCalculatorValue with a zero value.
+     */
+    public IntegerCalculatorValue() {
+        this.value = 0L;
+        ensure(getValue() == 0L);
+    }
+
     /**
      * Constructs an IntegerCalculatorValue
      *
      * @param value Must be in the range [-9999, 9999]
      */
     public IntegerCalculatorValue(long value) {
         require(value >= VALUE_LOWEST);
         require(value <= VALUE_HIGHEST);
         this.value = value;
     }
 
+    /**
+     * Constructs an IntegerCalculatorValue
+     *
+     * @param copyMe
+     */
     public IntegerCalculatorValue(IntegerCalculatorValue copyMe) {
         require(copyMe != null);
         this.value = copyMe.getValue();
     }
 
+
+    /**
+     * Appends the given digit to the right end of the current value
+     *
+     * @param digit Must in [0,9] e.g. "123" -> "1230", "20" ->
+     *              200", "0" -> "9"
+     */
     public void appendDigit(long digit) {
+        require(digit >= 0);
+        require(digit <= 9);
         value = value * 10 + digit;
     }
 
+    /**
+     * Sets the current value to zero.
+     */
     public void clear() {
         value = 0L;
         ensure(getValue() == 0L);
     }
 
+    /** @return The current value as a long. Will be in [LOWEST, HIGHEST] */
     public long getValue() {
         ensure(value >= VALUE_LOWEST);
         ensure(value <= VALUE_HIGHEST);
         return value;
     }
 
+    /**
+     *
+     * @return The current value as String e.g. "1", "10"
+     */
     public String getValueAsString() {
         return Long.toString(value);
     }
 
     @Override
     public String toString() {
         return Long.toString(value);
     }
 }
diff --git a/Calculator/src/test/java/com/example/rodbailey/keypad/IntegerCalculatorValueTest.java b/Calculator/src/test/java/com/example/rodbailey/keypad/IntegerCalculatorValueTest.java
index f041da1..ed7b074 100644
--- a/Calculator/src/test/java/com/example/rodbailey/keypad/IntegerCalculatorValueTest.java
+++ b/Calculator/src/test/java/com/example/rodbailey/keypad/IntegerCalculatorValueTest.java
@@ -5,50 +5,111 @@ import org.junit.Test;
 import org.valid4j.errors.RequireViolation;
 
 /**
- * Uninstrumented tests for IntegerCalculatorValue class.
+ * JUnit 4 tests for the IntegerCalculatorValue class.
  */
 public class IntegerCalculatorValueTest {
 
     @Test
-    public void contructWithLowestValue() {
-        IntegerCalculatorValue value = new IntegerCalculatorValue(IntegerCalculatorValue.VALUE_LOWEST);
-        Assert.assertNotNull(value);
-        Assert.assertEquals(IntegerCalculatorValue.VALUE_LOWEST, value.getValue());
+    public void appendNonZeroToNonZero() {
+        IntegerCalculatorValue value = new IntegerCalculatorValue(5L);
+        value.appendDigit(6);
+        Assert.assertEquals(56, value.getValue());
+        Assert.assertEquals("56", value.getValueAsString());
+    }
+
+    @Test
+    public void appendNonZeroToZero() {
+        IntegerCalculatorValue value = new IntegerCalculatorValue(0L);
+        value.appendDigit(5L);
+        Assert.assertEquals(5, value.getValue());
+        Assert.assertEquals("5", value.getValueAsString());
+    }
+
+    @Test
+    public void appendZeroToNonZero() {
+        IntegerCalculatorValue value = new IntegerCalculatorValue(5L);
+        value.appendDigit(0L);
+        Assert.assertEquals(50, value.getValue());
+        Assert.assertEquals("50", value.getValueAsString());
+    }
+
+    @Test
+    public void appendZeroToZero() {
+        IntegerCalculatorValue value = new IntegerCalculatorValue(0L);
+        value.appendDigit(0);
+        Assert.assertEquals(0, value.getValue());
+        Assert.assertEquals("0", value.getValueAsString());
+    }
+
+    @Test
+    public void clearNonEmpty() {
+        IntegerCalculatorValue value = new IntegerCalculatorValue(5L);
+        value.clear();
+        Assert.assertEquals(0, value.getValue());
+    }
+
+    @Test
+    public void clearEmpty() {
+        IntegerCalculatorValue value = new IntegerCalculatorValue(0L);
+        value.clear();
+        Assert.assertEquals(0, value.getValue());
     }
 
     @Test
     public void constructWithHighestValue() {
         IntegerCalculatorValue value = new IntegerCalculatorValue(IntegerCalculatorValue.VALUE_HIGHEST);
         Assert.assertNotNull(value);
         Assert.assertEquals(IntegerCalculatorValue.VALUE_HIGHEST, value.getValue());
     }
 
     @Test
-    public void constructWithTooLowValueGivesRequireViolation() {
+    public void constructWithTooHighValueGivesRequireViolation() {
         boolean rvGenerated = false;
 
         try {
-            new IntegerCalculatorValue(IntegerCalculatorValue.VALUE_LOWEST - 1);
+            IntegerCalculatorValue value = new IntegerCalculatorValue(
+                    IntegerCalculatorValue.VALUE_HIGHEST + 1);
         }
         catch (RequireViolation rv) {
             rvGenerated = true;
         }
 
         Assert.assertTrue(rvGenerated);
     }
 
     @Test
-    public void constructWithTooHighValueGivesRequireViolation() {
+    public void constructWithTooLowValueGivesRequireViolation() {
         boolean rvGenerated = false;
 
         try {
-            IntegerCalculatorValue value = new IntegerCalculatorValue(
-                    IntegerCalculatorValue.VALUE_HIGHEST + 1);
+            new IntegerCalculatorValue(IntegerCalculatorValue.VALUE_LOWEST - 1);
         }
         catch (RequireViolation rv) {
             rvGenerated = true;
         }
 
         Assert.assertTrue(rvGenerated);
     }
+
+    @Test
+    public void contructWithLowestValue() {
+        IntegerCalculatorValue value = new IntegerCalculatorValue(IntegerCalculatorValue.VALUE_LOWEST);
+        Assert.assertNotNull(value);
+        Assert.assertEquals(IntegerCalculatorValue.VALUE_LOWEST, value.getValue());
+    }
+
+    @Test
+    public void copyConstructorCopiesValue() {
+        IntegerCalculatorValue value_1 = new IntegerCalculatorValue(1L);
+        IntegerCalculatorValue value_1_copy = new IntegerCalculatorValue(1L);
+        Assert.assertEquals(value_1.getValue(), value_1_copy.getValue() );
+    }
+
+    @Test
+    public void defaultConstructorHasZeroValue() {
+        IntegerCalculatorValue value = new IntegerCalculatorValue();
+        Assert.assertEquals(0, value.getValue());
+    }
+
+
 }

commit 9e6e0a8985687e74e33dcfca643e05ceb8cd0140
Author: rodbailey <rodney.p.bailey@gmail.com>
Date:   Sun Jul 10 23:04:08 2016 +1000

    Added unit test for IntegerCalculatorValue

diff --git a/Calculator/build.gradle b/Calculator/build.gradle
index 5c5df93..f08472c 100644
--- a/Calculator/build.gradle
+++ b/Calculator/build.gradle
@@ -48,19 +48,21 @@ configurations.all {
 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
     testCompile 'junit:junit:4.12'
     testCompile 'org.mockito:mockito-core:1.9.5'
     compile 'com.android.support:appcompat-v7:23.4.0'
 //    compile 'com.android.support:support-v4:23.4.0'
     compile 'com.jakewharton.timber:timber:4.1.2'
 
     androidTestCompile "com.android.support.test:runner:0.4.1"
     androidTestCompile "com.android.support.test:rules:0.4.1"
     androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
     androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.1'
 
     apply plugin: 'realm-android'
     compile 'de.halfbit:tinybus:3.0.2'
 
     compile 'com.jakewharton:butterknife:8.1.0'
     apt 'com.jakewharton:butterknife-compiler:8.1.0'
+
+    compile 'org.valid4j:valid4j:0.5.0'
 }
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorView.java b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorView.java
index b04af9c..d94fe95 100644
--- a/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorView.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorView.java
@@ -3,22 +3,22 @@ package com.example.rodbailey.keypad;
 /**
  * This interface must be implemented by any keypad view. It contains those directives delivered
  * from the IKeypadPresenter that instruct the ICalculatorView to make certain changes in its view
  * state.
  */
 public interface ICalculatorView {
 
+    public void clearDisplay();
+
     /**
-     * Briefly flashes the display, which means to briefly clear the display then redisplay it's previous
-     * contents.
+     * Briefly flashes the display, which means to briefly blank out the display (remove all digits) then redisplay
+     * it's previous contents.
      */
     public void flashDisplay();
 
     /**
-     * Displays the given string in the keypad's display area
+     * Displays the given value in the keypad's display area
      *
      * @param display The string to literally display. e.g. "25.4302", "-23.12"
      */
     public void setDisplay(IntegerCalculatorValue display);
-
-    public void clearDisplay();
 }
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/IntegerCalculatorValue.java b/Calculator/src/main/java/com/example/rodbailey/keypad/IntegerCalculatorValue.java
index e475b7a..7628b09 100644
--- a/Calculator/src/main/java/com/example/rodbailey/keypad/IntegerCalculatorValue.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/IntegerCalculatorValue.java
@@ -1,46 +1,61 @@
 package com.example.rodbailey.keypad;
 
+import static org.valid4j.Assertive.require;
+import static org.valid4j.Assertive.ensure;
+
+import org.valid4j.Assertive;
+
 /**
  * A value that can be considered by the IntegerCalculator. This value might be the current
  * value of the "memory" or the value of the "register" in the calculator. The results of mathematical
  * operations cannot exceed what can be stored in an IntegerCalculatorValue, otherwise you get an Underflow or
  * Oveflow error.
  */
 public class IntegerCalculatorValue {
 
+    public static final long VALUE_LOWEST = -9999;
+
+    public static final long VALUE_HIGHEST = 9999;
+
     private long value;
 
     /**
      * Constructs an IntegerCalculatorValue
      *
      * @param value Must be in the range [-9999, 9999]
      */
     public IntegerCalculatorValue(long value) {
+        require(value >= VALUE_LOWEST);
+        require(value <= VALUE_HIGHEST);
         this.value = value;
     }
 
     public IntegerCalculatorValue(IntegerCalculatorValue copyMe) {
+        require(copyMe != null);
         this.value = copyMe.getValue();
     }
 
-    public long getValue() {
-        return value;
-    }
-
-    public String getValueAsString() {
-        return Long.toString(value);
-    }
-
     public void appendDigit(long digit) {
         value = value * 10 + digit;
     }
 
     public void clear() {
         value = 0L;
+        ensure(getValue() == 0L);
+    }
+
+    public long getValue() {
+        ensure(value >= VALUE_LOWEST);
+        ensure(value <= VALUE_HIGHEST);
+        return value;
+    }
+
+    public String getValueAsString() {
+        return Long.toString(value);
     }
 
     @Override
     public String toString() {
         return Long.toString(value);
     }
 }
diff --git a/Calculator/src/test/java/com/example/rodbailey/keypad/IntegerCalculatorValueTest.java b/Calculator/src/test/java/com/example/rodbailey/keypad/IntegerCalculatorValueTest.java
new file mode 100644
index 0000000..f041da1
--- /dev/null
+++ b/Calculator/src/test/java/com/example/rodbailey/keypad/IntegerCalculatorValueTest.java
@@ -0,0 +1,54 @@
+package com.example.rodbailey.keypad;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.valid4j.errors.RequireViolation;
+
+/**
+ * Uninstrumented tests for IntegerCalculatorValue class.
+ */
+public class IntegerCalculatorValueTest {
+
+    @Test
+    public void contructWithLowestValue() {
+        IntegerCalculatorValue value = new IntegerCalculatorValue(IntegerCalculatorValue.VALUE_LOWEST);
+        Assert.assertNotNull(value);
+        Assert.assertEquals(IntegerCalculatorValue.VALUE_LOWEST, value.getValue());
+    }
+
+    @Test
+    public void constructWithHighestValue() {
+        IntegerCalculatorValue value = new IntegerCalculatorValue(IntegerCalculatorValue.VALUE_HIGHEST);
+        Assert.assertNotNull(value);
+        Assert.assertEquals(IntegerCalculatorValue.VALUE_HIGHEST, value.getValue());
+    }
+
+    @Test
+    public void constructWithTooLowValueGivesRequireViolation() {
+        boolean rvGenerated = false;
+
+        try {
+            new IntegerCalculatorValue(IntegerCalculatorValue.VALUE_LOWEST - 1);
+        }
+        catch (RequireViolation rv) {
+            rvGenerated = true;
+        }
+
+        Assert.assertTrue(rvGenerated);
+    }
+
+    @Test
+    public void constructWithTooHighValueGivesRequireViolation() {
+        boolean rvGenerated = false;
+
+        try {
+            IntegerCalculatorValue value = new IntegerCalculatorValue(
+                    IntegerCalculatorValue.VALUE_HIGHEST + 1);
+        }
+        catch (RequireViolation rv) {
+            rvGenerated = true;
+        }
+
+        Assert.assertTrue(rvGenerated);
+    }
+}
diff --git a/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadModelTest.java b/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadModelTest.java
index d6a61c7..f791ace 100644
--- a/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadModelTest.java
+++ b/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadModelTest.java
@@ -8,44 +8,44 @@ import static org.junit.Assert.*;
 /**
  * To work on unit tests, switch the Test Artifact in the Build Variants view.
  */
 public class KeypadModelTest {
 
-    private CalculatorModel model;
-
-    @Before
-    public void createNewModel() {
-        model = new CalculatorModel();
-    }
-
-    @Test
-    public void modelIsInitializedWithEmptyString() throws Exception {
-        assertEquals(model.getRegister(), "");
-    }
-
-    @Test
-    public void appendToEmptyModel() throws Exception {
-        model.appendToRegister('5');
-        assertEquals(model.getRegister(), "5");
-    }
-
-    @Test
-    public void appendToNonEmptyModel() throws Exception {
-        model.appendToRegister('1');
-        model.appendToRegister('2');
-        assertEquals(model.getRegister(), "12");
-    }
-
-    @Test
-    public void clearEmptyModel() throws Exception {
-        model.clearAll();
-        assertEquals(model.getRegister(), "");
-    }
-
-    @Test
-    public void clearNonEmptyModel() throws Exception {
-        model.appendToRegister('1');
-        model.appendToRegister('2');
-        model.clearAll();
-        assertEquals(model.getRegister(), "");
-    }
+//    private CalculatorModel model;
+//
+//    @Before
+//    public void createNewModel() {
+//        model = new CalculatorModel();
+//    }
+//
+//    @Test
+//    public void modelIsInitializedWithEmptyString() throws Exception {
+//        assertEquals(model.getRegister(), "");
+//    }
+//
+//    @Test
+//    public void appendToEmptyModel() throws Exception {
+//        model.appendToRegister('5');
+//        assertEquals(model.getRegister(), "5");
+//    }
+//
+//    @Test
+//    public void appendToNonEmptyModel() throws Exception {
+//        model.appendToRegister('1');
+//        model.appendToRegister('2');
+//        assertEquals(model.getRegister(), "12");
+//    }
+//
+//    @Test
+//    public void clearEmptyModel() throws Exception {
+//        model.clearAll();
+//        assertEquals(model.getRegister(), "");
+//    }
+//
+//    @Test
+//    public void clearNonEmptyModel() throws Exception {
+//        model.appendToRegister('1');
+//        model.appendToRegister('2');
+//        model.clearAll();
+//        assertEquals(model.getRegister(), "");
+//    }
 }
\ No newline at end of file
diff --git a/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java b/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
index 077098e..6687e2e 100644
--- a/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
+++ b/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
@@ -6,38 +6,38 @@ import org.mockito.Mockito;
 /**
  * Test the CalculatorPresenter, for which we need a mock model and a mock view
  */
 public class KeypadPresenterTest {
 
-    @Test
-    public void presenterPassesNumericKeyPressesOntoModel() {
-        ICalculatorModel mockModel = Mockito.mock(ICalculatorModel.class);
-        ICalculatorView mockView = Mockito.mock(ICalculatorView.class);
-        ICalculatorPresenter presenter = new CalculatorPresenter(mockView, mockModel);
-
-        // When the model.getRegister() is called, return "1"
-        Mockito.when(mockModel.getRegister()).thenReturn("1");
-        presenter.keyPressed(KeypadKey.KEY_1);
-
-        // Verify that presenter called mockModel.appendToRegister('1');
-        Mockito.verify(mockModel).appendToRegister('1');
-
-        // Verify that presenter called mockView.setDisplay("1");
-        Mockito.verify(mockView).setDisplay("1");
-    }
-
-    @Test
-    public void presenterPassesClearKeyPressOntoModel() {
-        ICalculatorModel mockModel = Mockito.mock(ICalculatorModel.class);
-        ICalculatorView mockView = Mockito.mock(ICalculatorView.class);
-        ICalculatorPresenter presenter = new CalculatorPresenter(mockView, mockModel);
-        presenter.keyPressed(KeypadKey.KEY_CLEAR);
-
-        // Verify that presenter called mockModel.clearAll()
-        Mockito.verify(mockModel).clearAll();
-
-        // Verify that presenter called mockView.clearDisplay();
-        Mockito.verify(mockView).clearDisplay();
-    }
+//    @Test
+//    public void presenterPassesNumericKeyPressesOntoModel() {
+//        ICalculatorModel mockModel = Mockito.mock(ICalculatorModel.class);
+//        ICalculatorView mockView = Mockito.mock(ICalculatorView.class);
+//        ICalculatorPresenter presenter = new CalculatorPresenter(mockView, mockModel);
+//
+//        // When the model.getRegister() is called, return "1"
+//        Mockito.when(mockModel.getRegister()).thenReturn("1");
+//        presenter.keyPressed(KeypadKey.KEY_1);
+//
+//        // Verify that presenter called mockModel.appendToRegister('1');
+//        Mockito.verify(mockModel).appendToRegister('1');
+//
+//        // Verify that presenter called mockView.setDisplay("1");
+//        Mockito.verify(mockView).setDisplay("1");
+//    }
+//
+//    @Test
+//    public void presenterPassesClearKeyPressOntoModel() {
+//        ICalculatorModel mockModel = Mockito.mock(ICalculatorModel.class);
+//        ICalculatorView mockView = Mockito.mock(ICalculatorView.class);
+//        ICalculatorPresenter presenter = new CalculatorPresenter(mockView, mockModel);
+//        presenter.keyPressed(KeypadKey.KEY_CLEAR);
+//
+//        // Verify that presenter called mockModel.clearAll()
+//        Mockito.verify(mockModel).clearAll();
+//
+//        // Verify that presenter called mockView.clearDisplay();
+//        Mockito.verify(mockView).clearDisplay();
+//    }
 
 
 }

commit 16f846293838ca303a1f040391894ff0e1e41e72
Author: rodbailey <rodney.p.bailey@gmail.com>
Date:   Sun Jul 10 20:47:17 2016 +1000

    Basic reworking to be a "mini calculator" without a remote service.

diff --git a/.idea/misc.xml b/.idea/misc.xml
index fbb6828..5d19981 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,46 +1,46 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="EntryPointsManager">
     <entry_points version="2.0" />
   </component>
   <component name="NullableNotNullManager">
     <option name="myDefaultNullable" value="android.support.annotation.Nullable" />
     <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
     <option name="myNullables">
       <value>
         <list size="4">
           <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
           <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
           <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
           <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
         </list>
       </value>
     </option>
     <option name="myNotNulls">
       <value>
         <list size="4">
           <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
           <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
           <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
           <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
         </list>
       </value>
     </option>
   </component>
   <component name="ProjectLevelVcsManager" settingsEditedManually="false">
     <OptionsSetting value="true" id="Add" />
     <OptionsSetting value="true" id="Remove" />
     <OptionsSetting value="true" id="Checkout" />
     <OptionsSetting value="true" id="Update" />
     <OptionsSetting value="true" id="Status" />
     <OptionsSetting value="true" id="Edit" />
     <ConfirmationsSetting value="0" id="Add" />
     <ConfirmationsSetting value="0" id="Remove" />
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/build/classes" />
   </component>
   <component name="ProjectType">
     <option name="id" value="Android" />
   </component>
 </project>
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 21e1aec..a319fe0 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -1,10 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ProjectModuleManager">
     <modules>
       <module fileurl="file://$PROJECT_DIR$/Calculator/Calculator.iml" filepath="$PROJECT_DIR$/Calculator/Calculator.iml" />
-      <module fileurl="file://$PROJECT_DIR$/Calculator/app.iml" filepath="$PROJECT_DIR$/Calculator/app.iml" />
       <module fileurl="file://$PROJECT_DIR$/calculator.iml" filepath="$PROJECT_DIR$/calculator.iml" />
     </modules>
   </component>
 </project>
\ No newline at end of file
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorFragment.java b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorFragment.java
index 20f03a5..ee7338e 100644
--- a/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorFragment.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorFragment.java
@@ -10,2 +10,4 @@ import android.widget.TextView;
 
+import com.example.rodbailey.keypad.util.Log;
+
 import java.util.HashMap;
@@ -16,2 +18,3 @@ import butterknife.ButterKnife;
 import hugo.weaving.DebugLog;
+import timber.log.Timber;
 
@@ -21,102 +24,101 @@ import static com.example.rodbailey.keypad.KeypadKey.KEY_3;
 import static com.example.rodbailey.keypad.KeypadKey.KEY_4;
-import static com.example.rodbailey.keypad.KeypadKey.KEY_5;
-import static com.example.rodbailey.keypad.KeypadKey.KEY_6;
-import static com.example.rodbailey.keypad.KeypadKey.KEY_7;
-import static com.example.rodbailey.keypad.KeypadKey.KEY_8;
-import static com.example.rodbailey.keypad.KeypadKey.KEY_9;
-import static com.example.rodbailey.keypad.KeypadKey.KEY_CLEAR;
+import static com.example.rodbailey.keypad.KeypadKey.KEY_CLEAR_ALL;
 import static com.example.rodbailey.keypad.KeypadKey.KEY_EQUALS;
+import static com.example.rodbailey.keypad.KeypadKey.KEY_MINUS;
+import static com.example.rodbailey.keypad.KeypadKey.KEY_PLUS;
 
 
 /**
  * View of the keypad. This is a *passive* view - it does nothing itself, it contains no logic of its own.
  * It simply presents an LCD numeric display at top and a keypad underneath that contains the
  * digits 1 - 9
  */
 public class CalculatorFragment extends Fragment implements ICalculatorView {
 
     private static final String TAG = CalculatorFragment.class.getSimpleName();
 
     private final Map<Button, KeypadKey> keys = new HashMap<Button, KeypadKey>();
 
     private final KeypadClickListener keypadClickListener = new KeypadClickListener();
 
     private final ICalculatorPresenter keypadPresenter;
 
     /**
      * The output display at the top of the keypad
      */
     @BindView(R.id.keypad_display)
-    private TextView display;
+    TextView display;
 
     /**
      * Fragments must have a public empty constructor
      */
     public CalculatorFragment() {
         keypadPresenter = new CalculatorPresenter(this, new CalculatorModel());
     }
 
     /**
      * Use this factory method to create a new instance of
      * this fragment using the provided parameters.
      *
      * @return A new instance of fragment CalculatorFragment.
      */
     public static CalculatorFragment newInstance() {
         CalculatorFragment fragment = new CalculatorFragment();
         return fragment;
     }
 
     @Override
-    public void flashDisplay() {
+    public void clearDisplay() {
+
+    }
 
+    @Override
+    public void flashDisplay() {
+        Timber.e("flashDisplay() not implemented yet");
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
     }
 
     @DebugLog
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
         View fragmentView = inflater.inflate(R.layout.keypad_view, container, false);
 
         ButterKnife.bind(this, fragmentView);
 
         // Each key in the keypad is in the 'keys' array, so we can identify symbolically which
         // button is clicked on.
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_1), KEY_1);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_2), KEY_2);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_3), KEY_3);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_4), KEY_4);
-        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_5), KEY_5);
-        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_6), KEY_6);
-        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_7), KEY_7);
-        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_8), KEY_8);
-        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_9), KEY_9);
-        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_clear), KEY_CLEAR);
-        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_ok), KEY_EQUALS);
+        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_plus), KEY_PLUS);
+        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_minus), KEY_MINUS);
+        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_clear), KEY_CLEAR_ALL);
+        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_equals), KEY_EQUALS);
 
         for (Button button : keys.keySet()) {
             button.setOnClickListener(keypadClickListener);
         }
 
         return fragmentView;
     }
 
     @DebugLog
     @Override
-    public void setDisplay(String display) {
-        this.display.setText(display);
+    public void setDisplay(IntegerCalculatorValue display) {
+        this.display.setText(display.getValueAsString());
     }
 
     private class KeypadClickListener implements View.OnClickListener {
         @Override
         public void onClick(View view) {
             KeypadKey keyClicked = keys.get(view);
             keypadPresenter.keyPressed(keyClicked);
         }
     }
 }
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorModel.java b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorModel.java
index fc2031f..230e4f9 100644
--- a/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorModel.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorModel.java
@@ -5,28 +5,55 @@ import hugo.weaving.DebugLog;
 import static com.example.rodbailey.keypad.util.Log.log;
 
 /**
- * The keypad itself.
+ * The state and business logic of the calculator.
+ *
+ * @see ICalculatorModel
  */
 public class CalculatorModel implements ICalculatorModel {
 
     private static final String TAG = CalculatorModel.class.getSimpleName();
 
-    private StringBuffer register = new StringBuffer();
+    private IntegerCalculatorValue register = new IntegerCalculatorValue(0);
 
-    public String getRegister() {
-        return register.toString();
-    }
+    private IntegerCalculatorValue memory = new IntegerCalculatorValue(0);
 
     @DebugLog
-    public void appendToRegister(char value) {
-        log(TAG, "append to register value: " + value);
-        register.append(value);
-        log(TAG, "new register value: \"" + register.toString() + "\"");
+    public void clearAll() {
+        register.clear();
+        log(TAG, "register cleared. new register value: \"" + register.toString() + "\"");
     }
 
-    @DebugLog
-    public void clearRegister() {
-        register.setLength(0);
-        log(TAG, "register cleared. new register value: \"" + register.toString() + "\"");
+    @Override
+    public IntegerCalculatorValue getMemory() {
+        return memory;
+    }
+
+    public IntegerCalculatorValue getRegister() {
+        return register;
+    }
+
+    @Override
+    public void performOperationAdd() {
+
+    }
+
+    @Override
+    public void performOperationEqual() throws CalculatorOverflowException, CalculatorUnderflowException {
+
+    }
+
+    @Override
+    public void performOperationSubtract() {
+
+    }
+
+    @Override
+    public void setMemory(IntegerCalculatorValue value) {
+        memory = new IntegerCalculatorValue(value);
+    }
+
+    @Override
+    public void setRegister(IntegerCalculatorValue value) {
+        register = new IntegerCalculatorValue(value);
     }
 }
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorOverflowException.java b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorOverflowException.java
new file mode 100644
index 0000000..31bfb6f
--- /dev/null
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorOverflowException.java
@@ -0,0 +1,7 @@
+package com.example.rodbailey.keypad;
+
+/**
+ *
+ */
+public class CalculatorOverflowException extends Exception {
+}
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorPresenter.java b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorPresenter.java
index e6a1340..e5c66d7 100644
--- a/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorPresenter.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorPresenter.java
@@ -9,80 +9,81 @@ import static com.example.rodbailey.keypad.util.Log.log;
 /**
  *
  */
 public class CalculatorPresenter implements ICalculatorPresenter {
     private static final String TAG = CalculatorPresenter.class.getSimpleName();
 
     private final ICalculatorModel keypadModel;
 
     private final ICalculatorView keypadView;
 
     /**
      * You have to pass in a model, otherwise how can you tell if the
      * presenter is working or not? You need to have access to the model
      * to tell if the presenter is modifying it correctly, which precludes
      * creating it privately.
      *
      * @param model
      * @param view
      */
     public CalculatorPresenter(ICalculatorView view, ICalculatorModel model) {
         keypadModel = model;
         keypadView = view;
     }
 
     @DebugLog
     @Override
     public void keyPressed(KeypadKey key) {
         Timber.d("keyPressed: %s", key);
 
         // Pass user interaction onto the model
         if (key.isNumeric()) {
-            char charToRegister = numericKeyToChar(key);
-            keypadModel.appendToRegister(charToRegister);
+            long toLong = numericKeyToLong(key);
+            Timber.d("toLong=%d", toLong);
+
+            IntegerCalculatorValue register = keypadModel.getRegister();
+            Timber.d("register=%s", register);
+
+            register.appendDigit(toLong);
+
+            Timber.d("register afert append=%s", register);
+
+            keypadModel.setRegister(register);
+
             // Pass new model contents back up to view
-            String newDisplay = keypadModel.getRegister();
+            IntegerCalculatorValue newDisplay = keypadModel.getRegister();
+            Timber.d("register value retrieved from keypadModel is %s", newDisplay);
+
+            keypadView.setDisplay(newDisplay);
+        } else if (key == KeypadKey.KEY_CLEAR_ALL) {
+            keypadModel.clearAll();
+
+            // Pass new model contents back up to view
+            IntegerCalculatorValue newDisplay = keypadModel.getRegister();
             keypadView.setDisplay(newDisplay);
-        } else if (key == KeypadKey.KEY_CLEAR) {
-            keypadModel.clearRegister();
-            keypadView.clearDisplay();
         } else if (key == KeypadKey.KEY_EQUALS) {
             // Do what?
         }
     }
 
-    private char numericKeyToChar(KeypadKey key) {
-        char result = ' ';
+    private long numericKeyToLong(KeypadKey key) {
+        long result = 0L;
 
         switch (key) {
             case KEY_1:
-                result = '1';
+                result = 1;
                 break;
             case KEY_2:
-                result = '2';
+                result = 2;
                 break;
             case KEY_3:
-                result = '3';
+                result = 3;
                 break;
             case KEY_4:
-                result = '4';
-                break;
-            case KEY_5:
-                result = '5';
-                break;
-            case KEY_6:
-                result = '6';
-                break;
-            case KEY_7:
-                result = '7';
-                break;
-            case KEY_8:
-                result = '8';
-                break;
-            case KEY_9:
-                result = '9';
+                result = 4;
                 break;
+
         }
 
         return result;
     }
 }
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorUnderflowException.java b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorUnderflowException.java
new file mode 100644
index 0000000..b0fe826
--- /dev/null
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorUnderflowException.java
@@ -0,0 +1,7 @@
+package com.example.rodbailey.keypad;
+
+/**
+ *
+ */
+public class CalculatorUnderflowException extends Exception {
+}
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorModel.java b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorModel.java
index f4d0ab5..7fe8278 100644
--- a/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorModel.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorModel.java
@@ -1,70 +1,65 @@
 package com.example.rodbailey.keypad;
 
 /**
  * Contains all the state information for a calculator. All state is captured in two places:
  * the "register" and the "memory". The "register" is the number you are currently typing in,
  * the contents of which is always reflected on the calculator's display. The "memory" is the
  * running "tally" of the current operation and is the implied second argument to the mathematical
  * operation being performed. The first argument is the register.</p>
  * <p>
  * The ICalculatorModel also contains the business logic for the calculator. It is an integer-only
  * calculator. Any operation resulting in a fractional number will be rounded to the nearest
  * integer.
  * </p>
  * When a property changes value, an event is broadcast on the event bus. The following property change events
  * are broadcast:
  * <ul>
- *     <li>RegisterPropertyChangedEvent</li>
- *     <li>MemoryPropertyChangedEvent</li>
+ * <li>RegisterPropertyChangedEvent</li>
+ * <li>MemoryPropertyChangedEvent</li>
  * </ul>
  */
 public interface ICalculatorModel {
 
     /**
-     * Sets the current register's value to zero. Equivalent to calling #setRegister(0)
+     * Sets both register and model values to zero. Also cancels any pending operations.
      */
-    public void clearRegister();
+    public void clearAll();
 
     /**
      * @return The current value of the calculator's memory. This is the off-screen, running
      * tally and the implied second argument of all binary operations.
      */
-    public long getMemory();
+    public IntegerCalculatorValue getMemory();
 
     /**
      * @return The current register value.
      */
-    public long getRegister();
+    public IntegerCalculatorValue getRegister();
 
     /**
      * Performs the mathematical operation: register = memory + register
      */
-    public void performOperationAdd();
+    public void performOperationAdd() throws CalculatorOverflowException;
 
     /**
-     * Performs the mathematical operation: register = round(memory / register).
+     * Executes any pending operation.
      */
-    public void performOperationDivide();
-
-    /**
-     * Performs the mathematical operation: register = memory * register
-     */
-    public void performOperationMultiply();
+    public void performOperationEqual() throws CalculatorOverflowException, CalculatorUnderflowException;
 
     /**
      * Performs the mathematical operation: register = memory - register
      */
-    public void performOperationSubtract();
+    public void performOperationSubtract() throws CalculatorOverflowException, CalculatorUnderflowException;
 
     /**
      * @param value The new memory value
      */
-    public void setMemory(long value);
+    public void setMemory(IntegerCalculatorValue value);
 
     /**
      * Sets the calculator's register to have the given value.
      *
      * @param value New value of register. Zero or greater.
      */
-    public void setRegister(long value);
+    public void setRegister(IntegerCalculatorValue value);
 }
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorView.java b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorView.java
index e106f00..b04af9c 100644
--- a/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorView.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorView.java
@@ -3,20 +3,22 @@ package com.example.rodbailey.keypad;
 /**
  * This interface must be implemented by any keypad view. It contains those directives delivered
  * from the IKeypadPresenter that instruct the ICalculatorView to make certain changes in its view
  * state.
  */
 public interface ICalculatorView {
 
     /**
      * Briefly flashes the display, which means to briefly clear the display then redisplay it's previous
      * contents.
      */
     public void flashDisplay();
 
     /**
      * Displays the given string in the keypad's display area
      *
-     * @param display The string to literally display.
+     * @param display The string to literally display. e.g. "25.4302", "-23.12"
      */
-    public void setDisplay(String display);
+    public void setDisplay(IntegerCalculatorValue display);
+
+    public void clearDisplay();
 }
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/IntegerCalculatorValue.java b/Calculator/src/main/java/com/example/rodbailey/keypad/IntegerCalculatorValue.java
new file mode 100644
index 0000000..e475b7a
--- /dev/null
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/IntegerCalculatorValue.java
@@ -0,0 +1,46 @@
+package com.example.rodbailey.keypad;
+
+/**
+ * A value that can be considered by the IntegerCalculator. This value might be the current
+ * value of the "memory" or the value of the "register" in the calculator. The results of mathematical
+ * operations cannot exceed what can be stored in an IntegerCalculatorValue, otherwise you get an Underflow or
+ * Oveflow error.
+ */
+public class IntegerCalculatorValue {
+
+    private long value;
+
+    /**
+     * Constructs an IntegerCalculatorValue
+     *
+     * @param value Must be in the range [-9999, 9999]
+     */
+    public IntegerCalculatorValue(long value) {
+        this.value = value;
+    }
+
+    public IntegerCalculatorValue(IntegerCalculatorValue copyMe) {
+        this.value = copyMe.getValue();
+    }
+
+    public long getValue() {
+        return value;
+    }
+
+    public String getValueAsString() {
+        return Long.toString(value);
+    }
+
+    public void appendDigit(long digit) {
+        value = value * 10 + digit;
+    }
+
+    public void clear() {
+        value = 0L;
+    }
+
+    @Override
+    public String toString() {
+        return Long.toString(value);
+    }
+}
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/KeypadKey.java b/Calculator/src/main/java/com/example/rodbailey/keypad/KeypadKey.java
index 432feaf..bb6912f 100644
--- a/Calculator/src/main/java/com/example/rodbailey/keypad/KeypadKey.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/KeypadKey.java
@@ -3,29 +3,21 @@ package com.example.rodbailey.keypad;
 /**
  * Symbolic representation of every key in the ICalculatorView
  */
 public enum KeypadKey {
     KEY_1, //
     KEY_2, //
     KEY_3, //
     KEY_4, //
-    KEY_5, //
-    KEY_6, //
-    KEY_7, //
-    KEY_8, //
-    KEY_9, //
-    KEY_CLEAR, //
-    KEY_DIVIDE, //
+    KEY_CLEAR_ALL, //
     KEY_PLUS, //
     KEY_MINUS, //
-    KEY_MULTIPLY, //
     KEY_EQUALS;//
 
     public boolean isNumeric() {
-        return ((this == KEY_1) || (this == KEY_2) || (this == KEY_3) || (this == KEY_4) || (this == KEY_5)
-                || (this == KEY_6) || (this == KEY_7) || (this == KEY_9));
+        return ((this == KEY_1) || (this == KEY_2) || (this == KEY_3) || (this == KEY_4));
     }
 
-    public boolean isArithmeticOperation() {
-        return ((this == KEY_DIVIDE) || (this == KEY_PLUS) || (this == KEY_MINUS) || (this == KEY_MULTIPLY));
+    public boolean isOperation() {
+        return ((this == KEY_PLUS) || (this == KEY_MINUS) || (this == KEY_CLEAR_ALL) || (this == KEY_EQUALS));
     }
 }
diff --git a/Calculator/src/main/res/layout/keypad_view.xml b/Calculator/src/main/res/layout/keypad_view.xml
index 7ec78d1..e81df33 100644
--- a/Calculator/src/main/res/layout/keypad_view.xml
+++ b/Calculator/src/main/res/layout/keypad_view.xml
@@ -1,114 +1,81 @@
 <GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
-    android:background="#ccc"
-    android:columnCount="4"
-    android:rowCount="4"
-    android:useDefaultMargins="true">
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:background="#ccc"
+            android:columnCount="2"
+            android:rowCount="4"
+            android:useDefaultMargins="true">
 
     <!-- ============================ -->
     <!-- The keypad's LED display -->
     <!-- ============================ -->
 
     <TextView
         android:id="@+id/keypad_display"
-        android:background="#0ef"
         android:layout_height="80dp"
+        android:layout_columnSpan="2"
         android:layout_gravity="fill_horizontal"
+        android:background="#0ef"
         android:gravity="right|bottom"
-        android:layout_columnSpan="4"
         android:textSize="54sp"/>
 
-    <!-- =============== -->
-    <!-- Row 1 of keypad -->
-    <!-- =============== -->
-
-    <!-- The "7" button -->
+    <!-- ======================================= -->
+    <!-- Row 1 of keypad has "+" and "-" buttons -->
+    <!-- ======================================= -->
 
     <Button
-        android:id="@+id/keypad_button_7"
-        style="@style/keypad_numeric_button"
-        android:text="7" />
-
-    <!-- The "8" button -->
-
-    <Button
-        android:id="@+id/keypad_button_8"
-        style="@style/keypad_numeric_button"
-        android:text="8" />
-
-    <!-- The "9" button -->
+        android:id="@+id/keypad_button_plus"
+        style="@style/keypad_function_button"
+        android:text="+"/>
 
     <Button
-        android:id="@+id/keypad_button_9"
-        style="@style/keypad_numeric_button"
-        android:text="9" />
+        android:id="@+id/keypad_button_minus"
+        style="@style/keypad_function_button"
+        android:text="-"/>
 
-    <!-- The "CLR" button -->
+    <!-- ====================================== -->
+    <!-- Row 2 of keypad has "C" and "=" button -->
+    <!-- ====================================== -->
 
     <Button
         android:id="@+id/keypad_button_clear"
         style="@style/keypad_function_button"
-        android:text="CLR" />
-
-    <!-- =============== -->
-    <!-- Row 2 of keypad -->
-    <!-- =============== -->
-
-    <!-- The "4" button -->
+        android:text="C"/>
 
     <Button
-        android:id="@+id/keypad_button_4"
-        style="@style/keypad_numeric_button"
-        android:text="4" />
+        android:id="@+id/keypad_button_equals"
+        style="@style/keypad_function_button"
+        android:text="="/>
 
-    <!-- The "5" button -->
+    <!-- ======================================  -->
+    <!-- Row 3 of keypad has "1" and "2" buttons -->
+    <!-- ======================================= -->
 
     <Button
-        android:id="@+id/keypad_button_5"
+        android:id="@+id/keypad_button_1"
         style="@style/keypad_numeric_button"
-        android:text="5" />
-
-    <!-- The "6" button -->
+        android:text="1"/>
 
     <Button
-        android:id="@+id/keypad_button_6"
+        android:id="@+id/keypad_button_2"
         style="@style/keypad_numeric_button"
-        android:text="6" />
+        android:text="2"/>
 
-    <!-- The "OK" button -->
+    <!-- ======================================= -->
+    <!-- Row 3 of keypad has "3" and "4" buttons -->
+    <!-- ======================================= -->
 
     <Button
-        android:id="@+id/keypad_button_ok"
-        style="@style/keypad_function_button"
-        android:layout_columnSpan="1"
-        android:layout_rowSpan="2"
-        android:text="OK" />
-
-    <!-- =============== -->
-    <!-- Row 3 of keypad -->
-    <!-- =============== -->
-
-    <!-- The "1" button -->
-
-    <Button
-        android:id="@+id/keypad_button_1"
+        android:id="@+id/keypad_button_3"
         style="@style/keypad_numeric_button"
-        android:text="1" />
+        android:text="3"/>
 
     <!-- The "2" button -->
 
     <Button
-        android:id="@+id/keypad_button_2"
-        style="@style/keypad_numeric_button"
-        android:text="2" />
-
-    <!-- The "3" button -->
-
-    <Button
-        android:id="@+id/keypad_button_3"
+        android:id="@+id/keypad_button_4"
         style="@style/keypad_numeric_button"
-        android:text="3" />
+        android:text="4"/>
 
 
 </GridLayout>
diff --git a/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadModelTest.java b/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadModelTest.java
index c266af2..d6a61c7 100644
--- a/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadModelTest.java
+++ b/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadModelTest.java
@@ -8,44 +8,44 @@ import static org.junit.Assert.*;
 /**
  * To work on unit tests, switch the Test Artifact in the Build Variants view.
  */
 public class KeypadModelTest {
 
     private CalculatorModel model;
 
     @Before
     public void createNewModel() {
         model = new CalculatorModel();
     }
 
     @Test
     public void modelIsInitializedWithEmptyString() throws Exception {
         assertEquals(model.getRegister(), "");
     }
 
     @Test
     public void appendToEmptyModel() throws Exception {
         model.appendToRegister('5');
         assertEquals(model.getRegister(), "5");
     }
 
     @Test
     public void appendToNonEmptyModel() throws Exception {
         model.appendToRegister('1');
         model.appendToRegister('2');
         assertEquals(model.getRegister(), "12");
     }
 
     @Test
     public void clearEmptyModel() throws Exception {
-        model.clearRegister();
+        model.clearAll();
         assertEquals(model.getRegister(), "");
     }
 
     @Test
     public void clearNonEmptyModel() throws Exception {
         model.appendToRegister('1');
         model.appendToRegister('2');
-        model.clearRegister();
+        model.clearAll();
         assertEquals(model.getRegister(), "");
     }
 }
\ No newline at end of file
diff --git a/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java b/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
index 157b6ab..077098e 100644
--- a/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
+++ b/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
@@ -6,38 +6,38 @@ import org.mockito.Mockito;
 /**
  * Test the CalculatorPresenter, for which we need a mock model and a mock view
  */
 public class KeypadPresenterTest {
 
     @Test
     public void presenterPassesNumericKeyPressesOntoModel() {
         ICalculatorModel mockModel = Mockito.mock(ICalculatorModel.class);
         ICalculatorView mockView = Mockito.mock(ICalculatorView.class);
         ICalculatorPresenter presenter = new CalculatorPresenter(mockView, mockModel);
 
         // When the model.getRegister() is called, return "1"
         Mockito.when(mockModel.getRegister()).thenReturn("1");
         presenter.keyPressed(KeypadKey.KEY_1);
 
         // Verify that presenter called mockModel.appendToRegister('1');
         Mockito.verify(mockModel).appendToRegister('1');
 
         // Verify that presenter called mockView.setDisplay("1");
         Mockito.verify(mockView).setDisplay("1");
     }
 
     @Test
     public void presenterPassesClearKeyPressOntoModel() {
         ICalculatorModel mockModel = Mockito.mock(ICalculatorModel.class);
         ICalculatorView mockView = Mockito.mock(ICalculatorView.class);
         ICalculatorPresenter presenter = new CalculatorPresenter(mockView, mockModel);
         presenter.keyPressed(KeypadKey.KEY_CLEAR);
 
-        // Verify that presenter called mockModel.clearRegister()
-        Mockito.verify(mockModel).clearRegister();
+        // Verify that presenter called mockModel.clearAll()
+        Mockito.verify(mockModel).clearAll();
 
         // Verify that presenter called mockView.clearDisplay();
         Mockito.verify(mockView).clearDisplay();
     }
 
 
 }

commit 2afd645cdbcbd70361f85bd02261a37521066683
Author: rodbailey <rodney.p.bailey@gmail.com>
Date:   Sat Jul 9 18:18:19 2016 +1000

    Commenting plus style changes

diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml
new file mode 100644
index 0000000..2319023
--- /dev/null
+++ b/.idea/codeStyleSettings.xml
@@ -0,0 +1,229 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectCodeStyleSettingsManager">
+    <option name="PER_PROJECT_SETTINGS">
+      <value>
+        <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
+        <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
+        <option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
+          <value />
+        </option>
+        <option name="IMPORT_LAYOUT_TABLE">
+          <value>
+            <package name="android" withSubpackages="true" static="false" />
+            <emptyLine />
+            <package name="com" withSubpackages="true" static="false" />
+            <emptyLine />
+            <package name="junit" withSubpackages="true" static="false" />
+            <emptyLine />
+            <package name="net" withSubpackages="true" static="false" />
+            <emptyLine />
+            <package name="org" withSubpackages="true" static="false" />
+            <emptyLine />
+            <package name="java" withSubpackages="true" static="false" />
+            <emptyLine />
+            <package name="javax" withSubpackages="true" static="false" />
+            <emptyLine />
+            <package name="" withSubpackages="true" static="false" />
+            <emptyLine />
+            <package name="" withSubpackages="true" static="true" />
+            <emptyLine />
+          </value>
+        </option>
+        <option name="RIGHT_MARGIN" value="100" />
+        <AndroidXmlCodeStyleSettings>
+          <option name="USE_CUSTOM_SETTINGS" value="true" />
+        </AndroidXmlCodeStyleSettings>
+        <Objective-C-extensions>
+          <option name="GENERATE_INSTANCE_VARIABLES_FOR_PROPERTIES" value="ASK" />
+          <option name="RELEASE_STYLE" value="IVAR" />
+          <option name="TYPE_QUALIFIERS_PLACEMENT" value="BEFORE" />
+          <file>
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
+          </file>
+          <class>
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
+          </class>
+          <extensions>
+            <pair source="cpp" header="h" />
+            <pair source="c" header="h" />
+          </extensions>
+        </Objective-C-extensions>
+        <XML>
+          <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
+        </XML>
+        <codeStyleSettings language="XML">
+          <option name="FORCE_REARRANGE_MODE" value="1" />
+          <indentOptions>
+            <option name="CONTINUATION_INDENT_SIZE" value="4" />
+          </indentOptions>
+          <arrangement>
+            <rules>
+              <section>
+                <rule>
+                  <match>
+                    <AND>
+                      <NAME>xmlns:android</NAME>
+                      <XML_NAMESPACE>^$</XML_NAMESPACE>
+                    </AND>
+                  </match>
+                </rule>
+              </section>
+              <section>
+                <rule>
+                  <match>
+                    <AND>
+                      <NAME>xmlns:.*</NAME>
+                      <XML_NAMESPACE>^$</XML_NAMESPACE>
+                    </AND>
+                  </match>
+                  <order>BY_NAME</order>
+                </rule>
+              </section>
+              <section>
+                <rule>
+                  <match>
+                    <AND>
+                      <NAME>.*:id</NAME>
+                      <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
+                    </AND>
+                  </match>
+                </rule>
+              </section>
+              <section>
+                <rule>
+                  <match>
+                    <AND>
+                      <NAME>.*:name</NAME>
+                      <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
+                    </AND>
+                  </match>
+                </rule>
+              </section>
+              <section>
+                <rule>
+                  <match>
+                    <AND>
+                      <NAME>name</NAME>
+                      <XML_NAMESPACE>^$</XML_NAMESPACE>
+                    </AND>
+                  </match>
+                </rule>
+              </section>
+              <section>
+                <rule>
+                  <match>
+                    <AND>
+                      <NAME>style</NAME>
+                      <XML_NAMESPACE>^$</XML_NAMESPACE>
+                    </AND>
+                  </match>
+                </rule>
+              </section>
+              <section>
+                <rule>
+                  <match>
+                    <AND>
+                      <NAME>.*</NAME>
+                      <XML_NAMESPACE>^$</XML_NAMESPACE>
+                    </AND>
+                  </match>
+                  <order>BY_NAME</order>
+                </rule>
+              </section>
+              <section>
+                <rule>
+                  <match>
+                    <AND>
+                      <NAME>.*:layout_width</NAME>
+                      <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
+                    </AND>
+                  </match>
+                </rule>
+              </section>
+              <section>
+                <rule>
+                  <match>
+                    <AND>
+                      <NAME>.*:layout_height</NAME>
+                      <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
+                    </AND>
+                  </match>
+                </rule>
+              </section>
+              <section>
+                <rule>
+                  <match>
+                    <AND>
+                      <NAME>.*:layout_.*</NAME>
+                      <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
+                    </AND>
+                  </match>
+                  <order>BY_NAME</order>
+                </rule>
+              </section>
+              <section>
+                <rule>
+                  <match>
+                    <AND>
+                      <NAME>.*:width</NAME>
+                      <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
+                    </AND>
+                  </match>
+                  <order>BY_NAME</order>
+                </rule>
+              </section>
+              <section>
+                <rule>
+                  <match>
+                    <AND>
+                      <NAME>.*:height</NAME>
+                      <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
+                    </AND>
+                  </match>
+                  <order>BY_NAME</order>
+                </rule>
+              </section>
+              <section>
+                <rule>
+                  <match>
+                    <AND>
+                      <NAME>.*</NAME>
+                      <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
+                    </AND>
+                  </match>
+                  <order>BY_NAME</order>
+                </rule>
+              </section>
+              <section>
+                <rule>
+                  <match>
+                    <AND>
+                      <NAME>.*</NAME>
+                      <XML_NAMESPACE>.*</XML_NAMESPACE>
+                    </AND>
+                  </match>
+                  <order>BY_NAME</order>
+                </rule>
+              </section>
+            </rules>
+          </arrangement>
+        </codeStyleSettings>
+      </value>
+    </option>
+    <option name="PREFERRED_PROJECT_CODE_STYLE" value="Rod" />
+  </component>
+</project>
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 5d19981..fbb6828 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,46 +1,46 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="EntryPointsManager">
     <entry_points version="2.0" />
   </component>
   <component name="NullableNotNullManager">
     <option name="myDefaultNullable" value="android.support.annotation.Nullable" />
     <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
     <option name="myNullables">
       <value>
         <list size="4">
           <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
           <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
           <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
           <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
         </list>
       </value>
     </option>
     <option name="myNotNulls">
       <value>
         <list size="4">
           <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
           <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
           <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
           <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
         </list>
       </value>
     </option>
   </component>
   <component name="ProjectLevelVcsManager" settingsEditedManually="false">
     <OptionsSetting value="true" id="Add" />
     <OptionsSetting value="true" id="Remove" />
     <OptionsSetting value="true" id="Checkout" />
     <OptionsSetting value="true" id="Update" />
     <OptionsSetting value="true" id="Status" />
     <OptionsSetting value="true" id="Edit" />
     <ConfirmationsSetting value="0" id="Add" />
     <ConfirmationsSetting value="0" id="Remove" />
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/build/classes" />
   </component>
   <component name="ProjectType">
     <option name="id" value="Android" />
   </component>
 </project>
\ No newline at end of file
diff --git a/Calculator/build.gradle b/Calculator/build.gradle
index e976d8f..5c5df93 100644
--- a/Calculator/build.gradle
+++ b/Calculator/build.gradle
@@ -36,18 +36,31 @@ android {
 
+configurations {
+    internalDebugCompile
+}
+
+configurations.all {
+    resolutionStrategy {
+        force 'com.android.support:support-annotations:23.1.1'
+    }
+}
+
+
 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
     testCompile 'junit:junit:4.12'
     testCompile 'org.mockito:mockito-core:1.9.5'
-    compile 'com.android.support:appcompat-v7:23.0.1'
-    compile 'com.android.support:support-v4:23.0.1'
-
+    compile 'com.android.support:appcompat-v7:23.4.0'
+//    compile 'com.android.support:support-v4:23.4.0'
     compile 'com.jakewharton.timber:timber:4.1.2'
 
     androidTestCompile "com.android.support.test:runner:0.4.1"
     androidTestCompile "com.android.support.test:rules:0.4.1"
-
     androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
     androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.1'
 
     apply plugin: 'realm-android'
+    compile 'de.halfbit:tinybus:3.0.2'
+
+    compile 'com.jakewharton:butterknife:8.1.0'
+    apt 'com.jakewharton:butterknife-compiler:8.1.0'
 }
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorView.java b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorFragment.java
similarity index 74%
rename from Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorView.java
rename to Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorFragment.java
index 1d397d0..20f03a5 100644
--- a/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorView.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorFragment.java
@@ -2,6 +2,4 @@ package com.example.rodbailey.keypad;
 
-import android.content.Context;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
-import android.util.Log;
 import android.view.LayoutInflater;
@@ -15,2 +13,6 @@ import java.util.Map;
 
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import hugo.weaving.DebugLog;
+
 import static com.example.rodbailey.keypad.KeypadKey.KEY_1;
@@ -25,102 +27,96 @@ import static com.example.rodbailey.keypad.KeypadKey.KEY_9;
 import static com.example.rodbailey.keypad.KeypadKey.KEY_CLEAR;
-import static com.example.rodbailey.keypad.KeypadKey.KEY_OK;
+import static com.example.rodbailey.keypad.KeypadKey.KEY_EQUALS;
 
 
 /**
  * View of the keypad. This is a *passive* view - it does nothing itself, it contains no logic of its own.
+ * It simply presents an LCD numeric display at top and a keypad underneath that contains the
+ * digits 1 - 9
  */
-public class CalculatorView extends Fragment implements ICalculatorView {
+public class CalculatorFragment extends Fragment implements ICalculatorView {
+
+    private static final String TAG = CalculatorFragment.class.getSimpleName();
+
+    private final Map<Button, KeypadKey> keys = new HashMap<Button, KeypadKey>();
+
+    private final KeypadClickListener keypadClickListener = new KeypadClickListener();
 
-    private static final String TAG = CalculatorView.class.getSimpleName();
-    private TextView display;
-    private Map<Button, KeypadKey> keys = new HashMap<Button, KeypadKey>();
-    private KeypadClickListener keypadClickListener = new KeypadClickListener();
     private final ICalculatorPresenter keypadPresenter;
 
+    /**
+     * The output display at the top of the keypad
+     */
+    @BindView(R.id.keypad_display)
+    private TextView display;
+
     /**
      * Fragments must have a public empty constructor
      */
-    public CalculatorView() {
+    public CalculatorFragment() {
         keypadPresenter = new CalculatorPresenter(this, new CalculatorModel());
     }
 
     /**
      * Use this factory method to create a new instance of
      * this fragment using the provided parameters.
      *
-     * @return A new instance of fragment CalculatorView.
+     * @return A new instance of fragment CalculatorFragment.
      */
-    public static CalculatorView newInstance() {
-        CalculatorView fragment = new CalculatorView();
+    public static CalculatorFragment newInstance() {
+        CalculatorFragment fragment = new CalculatorFragment();
         return fragment;
     }
 
+    @Override
+    public void flashDisplay() {
+
+    }
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
     }
 
+    @DebugLog
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
         View fragmentView = inflater.inflate(R.layout.keypad_view, container, false);
 
-        Log.d(TAG, "Into onCreateView");
-
-        // The output display at the top of the keypad
-        display = (TextView) fragmentView.findViewById(R.id.keypad_display);
-
-        Log.d(TAG, "R.id.keypad_display is bound to widget " + display);
+        ButterKnife.bind(this, fragmentView);
 
         // Each key in the keypad is in the 'keys' array, so we can identify symbolically which
         // button is clicked on.
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_1), KEY_1);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_2), KEY_2);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_3), KEY_3);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_4), KEY_4);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_5), KEY_5);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_6), KEY_6);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_7), KEY_7);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_8), KEY_8);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_9), KEY_9);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_clear), KEY_CLEAR);
-        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_ok), KEY_OK);
+        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_ok), KEY_EQUALS);
 
         for (Button button : keys.keySet()) {
             button.setOnClickListener(keypadClickListener);
         }
 
-        Log.d(TAG, "Exiting onCreateView");
-
         return fragmentView;
     }
 
-    @Override
-    public void onAttach(Context context) {
-        super.onAttach(context);
-
-    }
-
-    @Override
-    public void onDetach() {
-        super.onDetach();
-    }
-
+    @DebugLog
     @Override
     public void setDisplay(String display) {
         this.display.setText(display);
     }
 
-    @Override
-    public void clearDisplay() {
-        display.setText("");
-    }
-
     private class KeypadClickListener implements View.OnClickListener {
         @Override
         public void onClick(View view) {
             KeypadKey keyClicked = keys.get(view);
             keypadPresenter.keyPressed(keyClicked);
         }
     }
 }
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorPresenter.java b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorPresenter.java
index fd996a0..e6a1340 100644
--- a/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorPresenter.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorPresenter.java
@@ -9,80 +9,80 @@ import static com.example.rodbailey.keypad.util.Log.log;
 /**
  *
  */
 public class CalculatorPresenter implements ICalculatorPresenter {
     private static final String TAG = CalculatorPresenter.class.getSimpleName();
 
     private final ICalculatorModel keypadModel;
 
     private final ICalculatorView keypadView;
 
     /**
      * You have to pass in a model, otherwise how can you tell if the
      * presenter is working or not? You need to have access to the model
      * to tell if the presenter is modifying it correctly, which precludes
      * creating it privately.
      *
      * @param model
      * @param view
      */
     public CalculatorPresenter(ICalculatorView view, ICalculatorModel model) {
         keypadModel = model;
         keypadView = view;
     }
 
     @DebugLog
     @Override
     public void keyPressed(KeypadKey key) {
         Timber.d("keyPressed: %s", key);
 
         // Pass user interaction onto the model
         if (key.isNumeric()) {
             char charToRegister = numericKeyToChar(key);
             keypadModel.appendToRegister(charToRegister);
             // Pass new model contents back up to view
             String newDisplay = keypadModel.getRegister();
             keypadView.setDisplay(newDisplay);
         } else if (key == KeypadKey.KEY_CLEAR) {
             keypadModel.clearRegister();
             keypadView.clearDisplay();
-        } else if (key == KeypadKey.KEY_OK) {
+        } else if (key == KeypadKey.KEY_EQUALS) {
             // Do what?
         }
     }
 
     private char numericKeyToChar(KeypadKey key) {
         char result = ' ';
 
         switch (key) {
             case KEY_1:
                 result = '1';
                 break;
             case KEY_2:
                 result = '2';
                 break;
             case KEY_3:
                 result = '3';
                 break;
             case KEY_4:
                 result = '4';
                 break;
             case KEY_5:
                 result = '5';
                 break;
             case KEY_6:
                 result = '6';
                 break;
             case KEY_7:
                 result = '7';
                 break;
             case KEY_8:
                 result = '8';
                 break;
             case KEY_9:
                 result = '9';
                 break;
         }
 
         return result;
     }
 }
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorModel.java b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorModel.java
index cdcc8ac..f4d0ab5 100644
--- a/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorModel.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorModel.java
@@ -1,13 +1,70 @@
 package com.example.rodbailey.keypad;
 
 /**
- * Contains all the state information for a calculator
+ * Contains all the state information for a calculator. All state is captured in two places:
+ * the "register" and the "memory". The "register" is the number you are currently typing in,
+ * the contents of which is always reflected on the calculator's display. The "memory" is the
+ * running "tally" of the current operation and is the implied second argument to the mathematical
+ * operation being performed. The first argument is the register.</p>
+ * <p>
+ * The ICalculatorModel also contains the business logic for the calculator. It is an integer-only
+ * calculator. Any operation resulting in a fractional number will be rounded to the nearest
+ * integer.
+ * </p>
+ * When a property changes value, an event is broadcast on the event bus. The following property change events
+ * are broadcast:
+ * <ul>
+ *     <li>RegisterPropertyChangedEvent</li>
+ *     <li>MemoryPropertyChangedEvent</li>
+ * </ul>
  */
 public interface ICalculatorModel {
 
-    public void appendToRegister(char value);
-
+    /**
+     * Sets the current register's value to zero. Equivalent to calling #setRegister(0)
+     */
     public void clearRegister();
 
-    public String getRegister();
+    /**
+     * @return The current value of the calculator's memory. This is the off-screen, running
+     * tally and the implied second argument of all binary operations.
+     */
+    public long getMemory();
+
+    /**
+     * @return The current register value.
+     */
+    public long getRegister();
+
+    /**
+     * Performs the mathematical operation: register = memory + register
+     */
+    public void performOperationAdd();
+
+    /**
+     * Performs the mathematical operation: register = round(memory / register).
+     */
+    public void performOperationDivide();
+
+    /**
+     * Performs the mathematical operation: register = memory * register
+     */
+    public void performOperationMultiply();
+
+    /**
+     * Performs the mathematical operation: register = memory - register
+     */
+    public void performOperationSubtract();
+
+    /**
+     * @param value The new memory value
+     */
+    public void setMemory(long value);
+
+    /**
+     * Sets the calculator's register to have the given value.
+     *
+     * @param value New value of register. Zero or greater.
+     */
+    public void setRegister(long value);
 }
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorPresenter.java b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorPresenter.java
index c7ec398..cfac98b 100644
--- a/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorPresenter.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorPresenter.java
@@ -1,5 +1,8 @@
 package com.example.rodbailey.keypad;
 
 /**
- * This interface must be implemented by any party wanting to present a CalculatorView.
+ * This interface must be implemented by any party wanting to present a CalculatorFragment. It
+ * receives messzgs from a corresponding view whenever some significant user event occurs. This
+ * presenter coordinates two parties - an ICalculatorView and an ICalculatorModel.</p>
+ * The following events are received on the event bus:
  */
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorView.java b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorView.java
index c5c56a9..e106f00 100644
--- a/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorView.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorView.java
@@ -1,21 +1,22 @@
 package com.example.rodbailey.keypad;
 
 /**
  * This interface must be implemented by any keypad view. It contains those directives delivered
- * from the IKeypadPresented that instruct the ICalculatorView to make certain changes in its view
+ * from the IKeypadPresenter that instruct the ICalculatorView to make certain changes in its view
  * state.
  */
 public interface ICalculatorView {
 
+    /**
+     * Briefly flashes the display, which means to briefly clear the display then redisplay it's previous
+     * contents.
+     */
+    public void flashDisplay();
+
     /**
      * Displays the given string in the keypad's display area
      *
      * @param display The string to literally display.
      */
     public void setDisplay(String display);
-
-    /**
-     * Empties the keypad's display area
-     */
-    public void clearDisplay();
 }
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/KeypadKey.java b/Calculator/src/main/java/com/example/rodbailey/keypad/KeypadKey.java
index 292f630..432feaf 100644
--- a/Calculator/src/main/java/com/example/rodbailey/keypad/KeypadKey.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/KeypadKey.java
@@ -3,10 +3,29 @@ package com.example.rodbailey.keypad;
 /**
  * Symbolic representation of every key in the ICalculatorView
  */
 public enum KeypadKey {
-    KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_CLEAR, KEY_OK;
+    KEY_1, //
+    KEY_2, //
+    KEY_3, //
+    KEY_4, //
+    KEY_5, //
+    KEY_6, //
+    KEY_7, //
+    KEY_8, //
+    KEY_9, //
+    KEY_CLEAR, //
+    KEY_DIVIDE, //
+    KEY_PLUS, //
+    KEY_MINUS, //
+    KEY_MULTIPLY, //
+    KEY_EQUALS;//
 
     public boolean isNumeric() {
-        return ((this != KEY_CLEAR) && (this != KEY_OK));
+        return ((this == KEY_1) || (this == KEY_2) || (this == KEY_3) || (this == KEY_4) || (this == KEY_5)
+                || (this == KEY_6) || (this == KEY_7) || (this == KEY_9));
+    }
+
+    public boolean isArithmeticOperation() {
+        return ((this == KEY_DIVIDE) || (this == KEY_PLUS) || (this == KEY_MINUS) || (this == KEY_MULTIPLY));
     }
 }
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/MainActivity.java b/Calculator/src/main/java/com/example/rodbailey/keypad/MainActivity.java
index c7b1397..9becfe4 100644
--- a/Calculator/src/main/java/com/example/rodbailey/keypad/MainActivity.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/MainActivity.java
@@ -10,19 +10,21 @@ import timber.log.Timber;
 public class MainActivity extends AppCompatActivity {
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
 
         if (BuildConfig.DEBUG) {
             Timber.plant(new Timber.DebugTree(){
                 @Override
                 protected String createStackElementTag(StackTraceElement element) {
                     return super.createStackElementTag(element) + ":" + element.getLineNumber();
                 }
             });
         } else {
             Timber.plant(new ReleaseTree());
         }
+
+        Timber.i("MainActivity has been created");
     }
 }
diff --git a/Calculator/src/main/res/layout/activity_main.xml b/Calculator/src/main/res/layout/activity_main.xml
index 75965dd..4e23f21 100644
--- a/Calculator/src/main/res/layout/activity_main.xml
+++ b/Calculator/src/main/res/layout/activity_main.xml
@@ -1,19 +1,19 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:paddingBottom="@dimen/activity_vertical_margin"
     android:paddingLeft="@dimen/activity_horizontal_margin"
     android:paddingRight="@dimen/activity_horizontal_margin"
     android:paddingTop="@dimen/activity_vertical_margin"
     tools:context="com.example.rodbailey.keypad.MainActivity">
 
     <fragment
         android:id="@+id/calculator_bob"
-        android:name="com.example.rodbailey.keypad.CalculatorView"
+        android:name="com.example.rodbailey.keypad.CalculatorFragment"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_centerInParent="true"
         tools:layout="@layout/keypad_view" />
 </RelativeLayout>

commit 63f2e15e82e4772647ea48cd2029e8feba885956
Author: rodbailey <rodney.p.bailey@gmail.com>
Date:   Thu Jun 30 19:08:13 2016 +1000

    Package restructure. Added CalculatorAppliction.java.

diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 58992cc..bd34498 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -1,24 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="GradleSettings">
     <option name="linkedExternalProjectsSettings">
       <GradleProjectSettings>
         <option name="distributionType" value="LOCAL" />
         <option name="externalProjectPath" value="$PROJECT_DIR$" />
         <option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.10" />
         <option name="modules">
           <set>
             <option value="$PROJECT_DIR$" />
-            <option value="$PROJECT_DIR$/app" />
+            <option value="$PROJECT_DIR$/Calculator" />
           </set>
         </option>
         <option name="myModules">
           <set>
             <option value="$PROJECT_DIR$" />
-            <option value="$PROJECT_DIR$/app" />
+            <option value="$PROJECT_DIR$/Calculator" />
           </set>
         </option>
       </GradleProjectSettings>
     </option>
   </component>
 </project>
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 8377c54..21e1aec 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -1,9 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ProjectModuleManager">
     <modules>
-      <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
+      <module fileurl="file://$PROJECT_DIR$/Calculator/Calculator.iml" filepath="$PROJECT_DIR$/Calculator/Calculator.iml" />
+      <module fileurl="file://$PROJECT_DIR$/Calculator/app.iml" filepath="$PROJECT_DIR$/Calculator/app.iml" />
       <module fileurl="file://$PROJECT_DIR$/calculator.iml" filepath="$PROJECT_DIR$/calculator.iml" />
     </modules>
   </component>
 </project>
\ No newline at end of file
diff --git a/app/.gitignore b/Calculator/.gitignore
similarity index 100%
rename from app/.gitignore
rename to Calculator/.gitignore
diff --git a/app/build.gradle b/Calculator/build.gradle
similarity index 94%
rename from app/build.gradle
rename to Calculator/build.gradle
index 07d0e15..e976d8f 100644
--- a/app/build.gradle
+++ b/Calculator/build.gradle
@@ -1,2 +1,3 @@
 apply plugin: 'com.android.application'
+apply plugin: 'com.jakewharton.hugo'
 
@@ -36,15 +37,17 @@ android {
 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
     testCompile 'junit:junit:4.12'
     testCompile 'org.mockito:mockito-core:1.9.5'
     compile 'com.android.support:appcompat-v7:23.0.1'
     compile 'com.android.support:support-v4:23.0.1'
 
+    compile 'com.jakewharton.timber:timber:4.1.2'
+
     androidTestCompile "com.android.support.test:runner:0.4.1"
     androidTestCompile "com.android.support.test:rules:0.4.1"
 
     androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
     androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.1'
 
     apply plugin: 'realm-android'
 }
diff --git a/app/proguard-rules.pro b/Calculator/proguard-rules.pro
similarity index 100%
rename from app/proguard-rules.pro
rename to Calculator/proguard-rules.pro
diff --git a/app/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java b/Calculator/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java
similarity index 100%
rename from app/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java
rename to Calculator/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java
diff --git a/app/src/androidTest/java/com/example/rodbailey/keypad/RealmTest.java b/Calculator/src/androidTest/java/com/example/rodbailey/keypad/RealmTest.java
similarity index 98%
rename from app/src/androidTest/java/com/example/rodbailey/keypad/RealmTest.java
rename to Calculator/src/androidTest/java/com/example/rodbailey/keypad/RealmTest.java
index e4962a3..bb44933 100644
--- a/app/src/androidTest/java/com/example/rodbailey/keypad/RealmTest.java
+++ b/Calculator/src/androidTest/java/com/example/rodbailey/keypad/RealmTest.java
@@ -7,2 +7,3 @@ import android.test.suitebuilder.annotation.LargeTest;
 import com.example.rodbailey.keypad.pinservice.Pin;
+import com.example.rodbailey.keypad.util.Log;
 
diff --git a/app/src/main/AndroidManifest.xml b/Calculator/src/main/AndroidManifest.xml
similarity index 91%
rename from app/src/main/AndroidManifest.xml
rename to Calculator/src/main/AndroidManifest.xml
index 8176660..05568a7 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/Calculator/src/main/AndroidManifest.xml
@@ -1,20 +1,21 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.example.rodbailey.keypad">
 
     <application
+        android:name=".app.CalculatorApplication"
         android:allowBackup="true"
         android:icon="@mipmap/ic_launcher"
         android:label="@string/app_name"
         android:supportsRtl="true"
         android:theme="@style/AppTheme">
         <activity android:name="com.example.rodbailey.keypad.MainActivity">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
 
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
     </application>
 
 </manifest>
\ No newline at end of file
diff --git a/app/src/main/java/com/example/rodbailey/keypad/KeypadModel.java b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorModel.java
similarity index 69%
rename from app/src/main/java/com/example/rodbailey/keypad/KeypadModel.java
rename to Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorModel.java
index 1fbc1e2..fc2031f 100644
--- a/app/src/main/java/com/example/rodbailey/keypad/KeypadModel.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorModel.java
@@ -2,27 +2,31 @@ package com.example.rodbailey.keypad;
 
-import static com.example.rodbailey.keypad.Log.log;
+import hugo.weaving.DebugLog;
+
+import static com.example.rodbailey.keypad.util.Log.log;
 
 /**
  * The keypad itself.
  */
-public class KeypadModel implements IKeypadModel {
+public class CalculatorModel implements ICalculatorModel {
 
-    private static final String TAG = KeypadModel.class.getSimpleName();
+    private static final String TAG = CalculatorModel.class.getSimpleName();
 
     private StringBuffer register = new StringBuffer();
 
     public String getRegister() {
         return register.toString();
     }
 
+    @DebugLog
     public void appendToRegister(char value) {
         log(TAG, "append to register value: " + value);
         register.append(value);
         log(TAG, "new register value: \"" + register.toString() + "\"");
     }
 
+    @DebugLog
     public void clearRegister() {
         register.setLength(0);
         log(TAG, "register cleared. new register value: \"" + register.toString() + "\"");
     }
 }
diff --git a/app/src/main/java/com/example/rodbailey/keypad/KeypadPresenter.java b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorPresenter.java
similarity index 79%
rename from app/src/main/java/com/example/rodbailey/keypad/KeypadPresenter.java
rename to Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorPresenter.java
index 7a2af4b..fd996a0 100644
--- a/app/src/main/java/com/example/rodbailey/keypad/KeypadPresenter.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorPresenter.java
@@ -3,80 +3,86 @@ package com.example.rodbailey.keypad;
 
-import static com.example.rodbailey.keypad.Log.log;
+import hugo.weaving.DebugLog;
+import timber.log.Timber;
+
+import static com.example.rodbailey.keypad.util.Log.log;
 
 /**
  *
  */
-public class KeypadPresenter implements IKeypadPresenter {
-    private static final String TAG = KeypadPresenter.class.getSimpleName();
-    private final IKeypadModel keypadModel;
-    private final IKeypadView keypadView;
+public class CalculatorPresenter implements ICalculatorPresenter {
+    private static final String TAG = CalculatorPresenter.class.getSimpleName();
+
+    private final ICalculatorModel keypadModel;
+
+    private final ICalculatorView keypadView;
 
     /**
      * You have to pass in a model, otherwise how can you tell if the
      * presenter is working or not? You need to have access to the model
      * to tell if the presenter is modifying it correctly, which precludes
      * creating it privately.
      *
      * @param model
      * @param view
      */
-    public KeypadPresenter(IKeypadView view, IKeypadModel model) {
+    public CalculatorPresenter(ICalculatorView view, ICalculatorModel model) {
         keypadModel = model;
         keypadView = view;
     }
 
+    @DebugLog
     @Override
     public void keyPressed(KeypadKey key) {
-        log(TAG, "keyPressed: " + key);
+        Timber.d("keyPressed: %s", key);
 
         // Pass user interaction onto the model
         if (key.isNumeric()) {
             char charToRegister = numericKeyToChar(key);
             keypadModel.appendToRegister(charToRegister);
             // Pass new model contents back up to view
             String newDisplay = keypadModel.getRegister();
             keypadView.setDisplay(newDisplay);
         } else if (key == KeypadKey.KEY_CLEAR) {
             keypadModel.clearRegister();
             keypadView.clearDisplay();
         } else if (key == KeypadKey.KEY_OK) {
             // Do what?
         }
     }
 
     private char numericKeyToChar(KeypadKey key) {
         char result = ' ';
 
         switch (key) {
             case KEY_1:
                 result = '1';
                 break;
             case KEY_2:
                 result = '2';
                 break;
             case KEY_3:
                 result = '3';
                 break;
             case KEY_4:
                 result = '4';
                 break;
             case KEY_5:
                 result = '5';
                 break;
             case KEY_6:
                 result = '6';
                 break;
             case KEY_7:
                 result = '7';
                 break;
             case KEY_8:
                 result = '8';
                 break;
             case KEY_9:
                 result = '9';
                 break;
         }
 
         return result;
     }
 }
diff --git a/app/src/main/java/com/example/rodbailey/keypad/KeypadView.java b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorView.java
similarity index 89%
rename from app/src/main/java/com/example/rodbailey/keypad/KeypadView.java
rename to Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorView.java
index 877a489..1d397d0 100644
--- a/app/src/main/java/com/example/rodbailey/keypad/KeypadView.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/CalculatorView.java
@@ -29,98 +29,98 @@ import static com.example.rodbailey.keypad.KeypadKey.KEY_OK;
 /**
  * View of the keypad. This is a *passive* view - it does nothing itself, it contains no logic of its own.
  */
-public class KeypadView extends Fragment implements IKeypadView {
+public class CalculatorView extends Fragment implements ICalculatorView {
 
-    private static final String TAG = KeypadView.class.getSimpleName();
+    private static final String TAG = CalculatorView.class.getSimpleName();
     private TextView display;
     private Map<Button, KeypadKey> keys = new HashMap<Button, KeypadKey>();
     private KeypadClickListener keypadClickListener = new KeypadClickListener();
-    private final IKeypadPresenter keypadPresenter;
+    private final ICalculatorPresenter keypadPresenter;
 
     /**
      * Fragments must have a public empty constructor
      */
-    public KeypadView() {
-        keypadPresenter = new KeypadPresenter(this, new KeypadModel());
+    public CalculatorView() {
+        keypadPresenter = new CalculatorPresenter(this, new CalculatorModel());
     }
 
     /**
      * Use this factory method to create a new instance of
      * this fragment using the provided parameters.
      *
-     * @return A new instance of fragment KeypadView.
+     * @return A new instance of fragment CalculatorView.
      */
-    public static KeypadView newInstance() {
-        KeypadView fragment = new KeypadView();
+    public static CalculatorView newInstance() {
+        CalculatorView fragment = new CalculatorView();
         return fragment;
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
     }
 
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
         View fragmentView = inflater.inflate(R.layout.keypad_view, container, false);
 
         Log.d(TAG, "Into onCreateView");
 
         // The output display at the top of the keypad
         display = (TextView) fragmentView.findViewById(R.id.keypad_display);
 
         Log.d(TAG, "R.id.keypad_display is bound to widget " + display);
 
         // Each key in the keypad is in the 'keys' array, so we can identify symbolically which
         // button is clicked on.
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_1), KEY_1);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_2), KEY_2);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_3), KEY_3);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_4), KEY_4);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_5), KEY_5);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_6), KEY_6);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_7), KEY_7);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_8), KEY_8);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_9), KEY_9);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_clear), KEY_CLEAR);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_ok), KEY_OK);
 
         for (Button button : keys.keySet()) {
             button.setOnClickListener(keypadClickListener);
         }
 
         Log.d(TAG, "Exiting onCreateView");
 
         return fragmentView;
     }
 
     @Override
     public void onAttach(Context context) {
         super.onAttach(context);
 
     }
 
     @Override
     public void onDetach() {
         super.onDetach();
     }
 
     @Override
     public void setDisplay(String display) {
         this.display.setText(display);
     }
 
     @Override
     public void clearDisplay() {
         display.setText("");
     }
 
     private class KeypadClickListener implements View.OnClickListener {
         @Override
         public void onClick(View view) {
             KeypadKey keyClicked = keys.get(view);
             keypadPresenter.keyPressed(keyClicked);
         }
     }
 }
diff --git a/app/src/main/java/com/example/rodbailey/keypad/IKeypadModel.java b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorModel.java
similarity index 64%
rename from app/src/main/java/com/example/rodbailey/keypad/IKeypadModel.java
rename to Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorModel.java
index ec5c4f5..cdcc8ac 100644
--- a/app/src/main/java/com/example/rodbailey/keypad/IKeypadModel.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorModel.java
@@ -1,13 +1,13 @@
 package com.example.rodbailey.keypad;
 
 /**
- * Created by rodbailey on 24/04/2016.
+ * Contains all the state information for a calculator
  */
-public interface IKeypadModel {
+public interface ICalculatorModel {
 
     public void appendToRegister(char value);
 
     public void clearRegister();
 
     public String getRegister();
 }
diff --git a/app/src/main/java/com/example/rodbailey/keypad/IKeypadPresenter.java b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorPresenter.java
similarity index 81%
rename from app/src/main/java/com/example/rodbailey/keypad/IKeypadPresenter.java
rename to Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorPresenter.java
index c99744c..c7ec398 100644
--- a/app/src/main/java/com/example/rodbailey/keypad/IKeypadPresenter.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorPresenter.java
@@ -1,14 +1,14 @@
 package com.example.rodbailey.keypad;
 
 /**
- * This interface must be implemented by any party wanting to present a KeypadView.
+ * This interface must be implemented by any party wanting to present a CalculatorView.
  */
-public interface IKeypadPresenter {
+public interface ICalculatorPresenter {
 
     /**
      * Invoked when a key on the keypad is tapped by the user.
      *
      * @param key The key the user tapped.
      */
     public void keyPressed(KeypadKey key);
 }
diff --git a/app/src/main/java/com/example/rodbailey/keypad/IKeypadView.java b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorView.java
similarity index 76%
rename from app/src/main/java/com/example/rodbailey/keypad/IKeypadView.java
rename to Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorView.java
index 24e8516..c5c56a9 100644
--- a/app/src/main/java/com/example/rodbailey/keypad/IKeypadView.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/ICalculatorView.java
@@ -1,21 +1,21 @@
 package com.example.rodbailey.keypad;
 
 /**
  * This interface must be implemented by any keypad view. It contains those directives delivered
- * from the IKeypadPresented that instruct the IKeypadView to make certain changes in its view
+ * from the IKeypadPresented that instruct the ICalculatorView to make certain changes in its view
  * state.
  */
-public interface IKeypadView {
+public interface ICalculatorView {
 
     /**
      * Displays the given string in the keypad's display area
      *
      * @param display The string to literally display.
      */
     public void setDisplay(String display);
 
     /**
      * Empties the keypad's display area
      */
     public void clearDisplay();
 }
diff --git a/app/src/main/java/com/example/rodbailey/keypad/KeypadKey.java b/Calculator/src/main/java/com/example/rodbailey/keypad/KeypadKey.java
similarity index 80%
rename from app/src/main/java/com/example/rodbailey/keypad/KeypadKey.java
rename to Calculator/src/main/java/com/example/rodbailey/keypad/KeypadKey.java
index 0fd5332..292f630 100644
--- a/app/src/main/java/com/example/rodbailey/keypad/KeypadKey.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/KeypadKey.java
@@ -1,5 +1,5 @@
 package com.example.rodbailey.keypad;
 
 /**
- * Symbolic representation of every key in the IKeypadView
+ * Symbolic representation of every key in the ICalculatorView
  */
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/MainActivity.java b/Calculator/src/main/java/com/example/rodbailey/keypad/MainActivity.java
new file mode 100644
index 0000000..c7b1397
--- /dev/null
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/MainActivity.java
@@ -0,0 +1,28 @@
+package com.example.rodbailey.keypad;
+
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+
+import com.example.rodbailey.keypad.util.ReleaseTree;
+
+import timber.log.Timber;
+
+public class MainActivity extends AppCompatActivity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_main);
+
+        if (BuildConfig.DEBUG) {
+            Timber.plant(new Timber.DebugTree(){
+                @Override
+                protected String createStackElementTag(StackTraceElement element) {
+                    return super.createStackElementTag(element) + ":" + element.getLineNumber();
+                }
+            });
+        } else {
+            Timber.plant(new ReleaseTree());
+        }
+    }
+}
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/app/CalculatorApplication.java b/Calculator/src/main/java/com/example/rodbailey/keypad/app/CalculatorApplication.java
new file mode 100644
index 0000000..be742b5
--- /dev/null
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/app/CalculatorApplication.java
@@ -0,0 +1,20 @@
+package com.example.rodbailey.keypad.app;
+
+import android.app.Application;
+import android.content.Context;
+
+/**
+ * The application representing all of the Calculator app. This class exists solely for the
+ * purposes of providing global access to the Context without having to continually pass it
+ * around.
+ */
+public class CalculatorApplication extends Application {
+
+    public static Context context;
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        context = getApplicationContext();
+    }
+}
diff --git a/app/src/main/java/com/example/rodbailey/keypad/pinservice/FakePinService.java b/Calculator/src/main/java/com/example/rodbailey/keypad/pinservice/FakePinService.java
similarity index 100%
rename from app/src/main/java/com/example/rodbailey/keypad/pinservice/FakePinService.java
rename to Calculator/src/main/java/com/example/rodbailey/keypad/pinservice/FakePinService.java
diff --git a/app/src/main/java/com/example/rodbailey/keypad/pinservice/IPinService.java b/Calculator/src/main/java/com/example/rodbailey/keypad/pinservice/IPinService.java
similarity index 100%
rename from app/src/main/java/com/example/rodbailey/keypad/pinservice/IPinService.java
rename to Calculator/src/main/java/com/example/rodbailey/keypad/pinservice/IPinService.java
diff --git a/app/src/main/java/com/example/rodbailey/keypad/pinservice/Pin.java b/Calculator/src/main/java/com/example/rodbailey/keypad/pinservice/Pin.java
similarity index 100%
rename from app/src/main/java/com/example/rodbailey/keypad/pinservice/Pin.java
rename to Calculator/src/main/java/com/example/rodbailey/keypad/pinservice/Pin.java
diff --git a/app/src/main/java/com/example/rodbailey/keypad/Log.java b/Calculator/src/main/java/com/example/rodbailey/keypad/util/Log.java
similarity index 87%
rename from app/src/main/java/com/example/rodbailey/keypad/Log.java
rename to Calculator/src/main/java/com/example/rodbailey/keypad/util/Log.java
index 64e0284..8e67673 100644
--- a/app/src/main/java/com/example/rodbailey/keypad/Log.java
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/util/Log.java
@@ -1,5 +1,5 @@
-package com.example.rodbailey.keypad;
+package com.example.rodbailey.keypad.util;
 
 /**
  * Facade to logging facility, so you can switch Android's Log in and out
  */
diff --git a/Calculator/src/main/java/com/example/rodbailey/keypad/util/ReleaseTree.java b/Calculator/src/main/java/com/example/rodbailey/keypad/util/ReleaseTree.java
new file mode 100644
index 0000000..f9ed1bc
--- /dev/null
+++ b/Calculator/src/main/java/com/example/rodbailey/keypad/util/ReleaseTree.java
@@ -0,0 +1,24 @@
+package com.example.rodbailey.keypad.util;
+
+import android.util.*;
+import android.util.Log;
+
+import timber.log.Timber;
+
+/**
+ * Created by rodbailey on 29/06/2016.
+ */
+public class ReleaseTree extends Timber.Tree {
+    @Override
+    protected boolean isLoggable(int priority) {
+        return ((priority == android.util.Log.WARN) || (priority == android.util.Log.ERROR) ||
+                (priority == android.util.Log.INFO));
+    }
+
+    @Override
+    protected void log(int priority, String tag, String message, Throwable t) {
+
+    }
+
+
+}
diff --git a/app/src/main/res/layout/activity_main.xml b/Calculator/src/main/res/layout/activity_main.xml
similarity index 92%
rename from app/src/main/res/layout/activity_main.xml
rename to Calculator/src/main/res/layout/activity_main.xml
index 6494076..75965dd 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/Calculator/src/main/res/layout/activity_main.xml
@@ -1,19 +1,19 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:paddingBottom="@dimen/activity_vertical_margin"
     android:paddingLeft="@dimen/activity_horizontal_margin"
     android:paddingRight="@dimen/activity_horizontal_margin"
     android:paddingTop="@dimen/activity_vertical_margin"
     tools:context="com.example.rodbailey.keypad.MainActivity">
 
     <fragment
         android:id="@+id/calculator_bob"
-        android:name="com.example.rodbailey.keypad.KeypadView"
+        android:name="com.example.rodbailey.keypad.CalculatorView"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_centerInParent="true"
         tools:layout="@layout/keypad_view" />
 </RelativeLayout>
diff --git a/app/src/main/res/layout/keypad_view.xml b/Calculator/src/main/res/layout/keypad_view.xml
similarity index 100%
rename from app/src/main/res/layout/keypad_view.xml
rename to Calculator/src/main/res/layout/keypad_view.xml
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/Calculator/src/main/res/mipmap-hdpi/ic_launcher.png
similarity index 100%
rename from app/src/main/res/mipmap-hdpi/ic_launcher.png
rename to Calculator/src/main/res/mipmap-hdpi/ic_launcher.png
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/Calculator/src/main/res/mipmap-mdpi/ic_launcher.png
similarity index 100%
rename from app/src/main/res/mipmap-mdpi/ic_launcher.png
rename to Calculator/src/main/res/mipmap-mdpi/ic_launcher.png
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/Calculator/src/main/res/mipmap-xhdpi/ic_launcher.png
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/ic_launcher.png
rename to Calculator/src/main/res/mipmap-xhdpi/ic_launcher.png
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/Calculator/src/main/res/mipmap-xxhdpi/ic_launcher.png
similarity index 100%
rename from app/src/main/res/mipmap-xxhdpi/ic_launcher.png
rename to Calculator/src/main/res/mipmap-xxhdpi/ic_launcher.png
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/Calculator/src/main/res/mipmap-xxxhdpi/ic_launcher.png
similarity index 100%
rename from app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
rename to Calculator/src/main/res/mipmap-xxxhdpi/ic_launcher.png
diff --git a/app/src/main/res/values-w820dp/dimens.xml b/Calculator/src/main/res/values-w820dp/dimens.xml
similarity index 100%
rename from app/src/main/res/values-w820dp/dimens.xml
rename to Calculator/src/main/res/values-w820dp/dimens.xml
diff --git a/app/src/main/res/values/colors.xml b/Calculator/src/main/res/values/colors.xml
similarity index 100%
rename from app/src/main/res/values/colors.xml
rename to Calculator/src/main/res/values/colors.xml
diff --git a/app/src/main/res/values/dimens.xml b/Calculator/src/main/res/values/dimens.xml
similarity index 100%
rename from app/src/main/res/values/dimens.xml
rename to Calculator/src/main/res/values/dimens.xml
diff --git a/app/src/main/res/values/strings.xml b/Calculator/src/main/res/values/strings.xml
similarity index 100%
rename from app/src/main/res/values/strings.xml
rename to Calculator/src/main/res/values/strings.xml
diff --git a/app/src/main/res/values/styles.xml b/Calculator/src/main/res/values/styles.xml
similarity index 100%
rename from app/src/main/res/values/styles.xml
rename to Calculator/src/main/res/values/styles.xml
diff --git a/app/src/test/java/com/example/rodbailey/keypad/KeypadModelTest.java b/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadModelTest.java
similarity index 93%
rename from app/src/test/java/com/example/rodbailey/keypad/KeypadModelTest.java
rename to Calculator/src/test/java/com/example/rodbailey/keypad/KeypadModelTest.java
index 148eb41..c266af2 100644
--- a/app/src/test/java/com/example/rodbailey/keypad/KeypadModelTest.java
+++ b/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadModelTest.java
@@ -8,44 +8,44 @@ import static org.junit.Assert.*;
 /**
  * To work on unit tests, switch the Test Artifact in the Build Variants view.
  */
 public class KeypadModelTest {
 
-    private KeypadModel model;
+    private CalculatorModel model;
 
     @Before
     public void createNewModel() {
-        model = new KeypadModel();
+        model = new CalculatorModel();
     }
 
     @Test
     public void modelIsInitializedWithEmptyString() throws Exception {
         assertEquals(model.getRegister(), "");
     }
 
     @Test
     public void appendToEmptyModel() throws Exception {
         model.appendToRegister('5');
         assertEquals(model.getRegister(), "5");
     }
 
     @Test
     public void appendToNonEmptyModel() throws Exception {
         model.appendToRegister('1');
         model.appendToRegister('2');
         assertEquals(model.getRegister(), "12");
     }
 
     @Test
     public void clearEmptyModel() throws Exception {
         model.clearRegister();
         assertEquals(model.getRegister(), "");
     }
 
     @Test
     public void clearNonEmptyModel() throws Exception {
         model.appendToRegister('1');
         model.appendToRegister('2');
         model.clearRegister();
         assertEquals(model.getRegister(), "");
     }
 }
\ No newline at end of file
diff --git a/app/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java b/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
similarity index 64%
rename from app/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
rename to Calculator/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
index ab571b6..157b6ab 100644
--- a/app/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
+++ b/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
@@ -4,40 +4,40 @@ import org.junit.Test;
 import org.mockito.Mockito;
 
 /**
- * Test the KeypadPresenter, for which we need a mock model and a mock view
+ * Test the CalculatorPresenter, for which we need a mock model and a mock view
  */
 public class KeypadPresenterTest {
 
     @Test
     public void presenterPassesNumericKeyPressesOntoModel() {
-        IKeypadModel mockModel = Mockito.mock(IKeypadModel.class);
-        IKeypadView mockView = Mockito.mock(IKeypadView.class);
-        IKeypadPresenter presenter = new KeypadPresenter(mockView, mockModel);
+        ICalculatorModel mockModel = Mockito.mock(ICalculatorModel.class);
+        ICalculatorView mockView = Mockito.mock(ICalculatorView.class);
+        ICalculatorPresenter presenter = new CalculatorPresenter(mockView, mockModel);
 
         // When the model.getRegister() is called, return "1"
         Mockito.when(mockModel.getRegister()).thenReturn("1");
         presenter.keyPressed(KeypadKey.KEY_1);
 
         // Verify that presenter called mockModel.appendToRegister('1');
         Mockito.verify(mockModel).appendToRegister('1');
 
         // Verify that presenter called mockView.setDisplay("1");
         Mockito.verify(mockView).setDisplay("1");
     }
 
     @Test
     public void presenterPassesClearKeyPressOntoModel() {
-        IKeypadModel mockModel = Mockito.mock(IKeypadModel.class);
-        IKeypadView mockView = Mockito.mock(IKeypadView.class);
-        IKeypadPresenter presenter = new KeypadPresenter(mockView, mockModel);
+        ICalculatorModel mockModel = Mockito.mock(ICalculatorModel.class);
+        ICalculatorView mockView = Mockito.mock(ICalculatorView.class);
+        ICalculatorPresenter presenter = new CalculatorPresenter(mockView, mockModel);
         presenter.keyPressed(KeypadKey.KEY_CLEAR);
 
         // Verify that presenter called mockModel.clearRegister()
         Mockito.verify(mockModel).clearRegister();
 
         // Verify that presenter called mockView.clearDisplay();
         Mockito.verify(mockView).clearDisplay();
     }
 
 
 }
diff --git a/app/src/test/java/com/example/rodbailey/keypad/KeypadTestSuite.java b/Calculator/src/test/java/com/example/rodbailey/keypad/KeypadTestSuite.java
similarity index 100%
rename from app/src/test/java/com/example/rodbailey/keypad/KeypadTestSuite.java
rename to Calculator/src/test/java/com/example/rodbailey/keypad/KeypadTestSuite.java
diff --git a/app/src/main/java/com/example/rodbailey/keypad/MainActivity.java b/app/src/main/java/com/example/rodbailey/keypad/MainActivity.java
deleted file mode 100644
index 41a2c69..0000000
--- a/app/src/main/java/com/example/rodbailey/keypad/MainActivity.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.example.rodbailey.keypad;
-
-import android.support.v7.app.AppCompatActivity;
-import android.os.Bundle;
-
-public class MainActivity extends AppCompatActivity {
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_main);
-    }
-}
diff --git a/build.gradle b/build.gradle
index 61f6a91..d179812 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,20 +3,23 @@
 // Configures the build script classpath
 buildscript {
     repositories {
         jcenter()
+        mavenCentral()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.1.0'
+        classpath 'com.android.tools.build:gradle:2.1.2'
         classpath "io.realm:realm-gradle-plugin:0.90.0"
+        classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
 
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
     }
 }
 
 // Configures this project and all of its sub-projects
 allprojects {
     repositories {
         jcenter()
+        mavenCentral()
     }
 }
diff --git a/settings.gradle b/settings.gradle
index e7b4def..770f483 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':app'
+include ':Calculator'

commit 21b9ff01767e0b9ba1c0a140e095fd1527b203e4
Author: rodbailey <rodney.p.bailey@gmail.com>
Date:   Wed May 11 00:01:21 2016 +1000

    Learnt some more about Groovy and Gradle

diff --git a/app/build.gradle b/app/build.gradle
index dfa36ba..07d0e15 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -3,30 +3,32 @@ apply plugin: 'com.android.application'
 android {
-    compileSdkVersion 23
+    // Below I have put back in the brackets that Groovy makes optional
+    // just to convince myself I know something about Groovy.
+    compileSdkVersion(23)
     buildToolsVersion "23.0.3"
 
     defaultConfig {
         applicationId "com.example.rodbailey.keypad"
         minSdkVersion 15
         targetSdkVersion 23
         versionCode 1
         versionName "1.0"
 
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
     buildTypes {
         release {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
     }
 
     // If you need to add more flavors, consider using flavor dimensions.
     productFlavors {
         mock {
             applicationIdSuffix = ".mock"
         }
         prod {
 
         }
     }
 }
diff --git a/build.gradle b/build.gradle
index e47db28..61f6a91 100644
--- a/build.gradle
+++ b/build.gradle
@@ -2,2 +2,3 @@
 
+// Configures the build script classpath
 buildscript {
@@ -15,2 +16,3 @@ buildscript {
 
+// Configures this project and all of its sub-projects
 allprojects {
@@ -22,3 +24,5 @@ allprojects {
 task clean(type: Delete) {
+    println '==> Beginning task clean'
     delete rootProject.buildDir
+    println '==> Finished task clean'
 }

commit 31b4b7c9eedb19ed7124689c9d5428e9dc836f90
Author: rodbailey <rodney.p.bailey@gmail.com>
Date:   Sat May 7 18:20:42 2016 +1000

    Split out Realm tests into separate class RealmTest.java

diff --git a/app/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java b/app/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java
index 7a7285f..0e1ca56 100644
--- a/app/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java
+++ b/app/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java
@@ -10,8 +10,2 @@ import android.test.suitebuilder.annotation.LargeTest;
 
-import com.example.rodbailey.keypad.pinservice.Pin;
-
-import junit.framework.Assert;
-
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Rule;
@@ -20,117 +14,43 @@ import org.junit.runner.RunWith;
 
-import io.realm.Realm;
-import io.realm.RealmConfiguration;
-import io.realm.RealmQuery;
-import io.realm.RealmResults;
-
 /**
  * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
  */
 @RunWith(AndroidJUnit4.class)
 @LargeTest
 public class KeypadTest {
 
     private static final String TAG = KeypadTest.class.getSimpleName();
 
     @Rule
     public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<MainActivity>(MainActivity.class);
 
-    public RealmConfiguration config;
-
-    public Realm realm;
-
-    @Before
-    public void before() {
-        config = new RealmConfiguration.Builder(mActivityRule.getActivity()).build();
-        realm = Realm.getInstance(config);
-        emptyRealmDatabase();
-    }
-
-    @After
-    public void after() {
-        realm.close();
-    }
-
-    private void emptyRealmDatabase() {
-        realm.beginTransaction();
-        RealmResults<Pin> allPins = realm.where(Pin.class).findAll();
-        allPins.deleteAllFromRealm();
-        realm.commitTransaction();
-    }
-
-    private void addPinToRealmDatabase() {
-        // Default realm database is /data/user/0/com.example.rodbailey.keypad/files/default.realm
-        // Due to symbolic links, /data/data/com.example.rodbailey.keypad/files/default.realm
-        realm.beginTransaction();
-        Pin pin = realm.createObject(Pin.class);
-        pin.setId(1);
-        pin.setName("John Smith");
-        pin.setNumericCode("1234");
-        realm.commitTransaction();
-    }
-
-    @Test
-    public void testReadRealmDatabase() {
-        addPinToRealmDatabase();
-
-        Pin retrievedPin = realm.where(Pin.class).findFirst();
-        Assert.assertNotNull(retrievedPin);
-        Assert.assertEquals(retrievedPin.getId(), 1);
-        Assert.assertEquals(retrievedPin.getName(), "John Smith");
-        Assert.assertEquals(retrievedPin.getNumericCode(), "1234");
-        Log.log(TAG, "retrieved Pin=" + retrievedPin);
-    }
-
-    @Test
-    public void testQueryRealmDatabase() {
-        addPinToRealmDatabase();
-        
-        RealmQuery<Pin> query = realm.where(Pin.class);
-        query.equalTo("name", "John Smith");
-        RealmResults<Pin> results = query.findAll();
-        Assert.assertNotNull(results);
-        Assert.assertEquals(1, results.size());
-
-        Pin queryPin = results.first();
-        Assert.assertEquals(queryPin.getId(), 1);
-        Assert.assertEquals(queryPin.getName(), "John Smith");
-        Assert.assertEquals(queryPin.getNumericCode(), "1234");
-        Log.log(TAG, "queried Pin=" + queryPin);
-    }
-
-    @Test
-    public void testComplexQueryRealmDatabase() {
-
-    }
-
-    /*
 
     @Test
     public void testClickingNumber1KeyPuts1OnScreen() {
         // Click the "1" button
         Espresso.onView(ViewMatchers.withId(R.id.keypad_button_1)).perform(ViewActions.click());
 
         // Check there is a "1" on the screen
         Espresso.onView(ViewMatchers.withId(R.id.keypad_display)).check(ViewAssertions.matches(ViewMatchers.withText("1")));
     }
 
     @Test
     public void testClickingNumbers1and2Puts12OnScreen() {
         // Click the "1" button then the "2" button
         Espresso.onView(ViewMatchers.withId(R.id.keypad_button_1)).perform(ViewActions.click());
         Espresso.onView(ViewMatchers.withId(R.id.keypad_button_2)).perform(ViewActions.click());
 
         // Check there is a "12" on the screen
         Espresso.onView(ViewMatchers.withId(R.id.keypad_display)).check(ViewAssertions.matches(ViewMatchers.withText("12")));
     }
 
     @Test
     public void testClearButtonEmptiesDisplay() {
         // Click the "3" button
         Espresso.onView(ViewMatchers.withId(R.id.keypad_button_3)).perform(ViewActions.click());
         // Click the "Clear" button
         Espresso.onView(ViewMatchers.withId(R.id.keypad_button_clear)).perform(ViewActions.click());
         // Check the screen is empty string
         Espresso.onView(ViewMatchers.withId(R.id.keypad_display)).check(ViewAssertions.matches(ViewMatchers.withText("")));
-    } */
+    }
 }
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/example/rodbailey/keypad/RealmTest.java b/app/src/androidTest/java/com/example/rodbailey/keypad/RealmTest.java
new file mode 100644
index 0000000..e4962a3
--- /dev/null
+++ b/app/src/androidTest/java/com/example/rodbailey/keypad/RealmTest.java
@@ -0,0 +1,138 @@
+package com.example.rodbailey.keypad;
+
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+import android.test.suitebuilder.annotation.LargeTest;
+
+import com.example.rodbailey.keypad.pinservice.Pin;
+
+import junit.framework.Assert;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import io.realm.Realm;
+import io.realm.RealmConfiguration;
+import io.realm.RealmQuery;
+import io.realm.RealmResults;
+
+/**
+ * Instrumented test of storing Pin instances in a Realm database.
+ */
+@RunWith(AndroidJUnit4.class)
+@LargeTest
+public class RealmTest {
+
+    private static final String TAG = RealmTest.class.getSimpleName();
+
+    @Rule
+    public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<MainActivity>(MainActivity.class);
+
+    public RealmConfiguration config;
+
+    public Realm realm;
+
+    /**
+     * Remove all Pin records from database before each @Test is run. Note need for "deleteRealmIfMigrationNeeded"
+     * when I moved this code from KeypadTest to the new RealmTest class.
+     */
+    @Before
+    public void before() {
+        Log.log(TAG, "Into before");
+        config = new RealmConfiguration.Builder(mActivityRule.getActivity()).deleteRealmIfMigrationNeeded().build();
+        realm = Realm.getInstance(config);
+        emptyRealmDatabase();
+        Log.log(TAG, "Exiting before with realm=" + realm);
+    }
+
+    /**
+     * Close the realm database connection after each @Test is run
+     */
+    @After
+    public void after() {
+        Log.log(TAG, "Into after with realm=" + realm);
+        realm.close();
+    }
+
+    /**
+     * Utility method to delete all Pin records from the database
+     */
+    private void emptyRealmDatabase() {
+        realm.beginTransaction();
+        RealmResults<Pin> allPins = realm.where(Pin.class).findAll();
+        allPins.deleteAllFromRealm();
+        realm.commitTransaction();
+    }
+
+    /**
+     * Utility method to add two Pin records to the database, with:
+     * id = 1, name = John Smith, numericCode = 1234
+     * and
+     * id = 2, name = Jane Doe, numericCode = 5678
+     */
+    private void addPinsToRealmDatabase() {
+        // Default realm database is /data/user/0/com.example.rodbailey.keypad/files/default.realm
+        // Due to symbolic links, /data/data/com.example.rodbailey.keypad/files/default.realm
+        realm.beginTransaction();
+
+        Pin pin1 = realm.createObject(Pin.class);
+        pin1.setId(1);
+        pin1.setName("John Smith");
+        pin1.setNumericCode("1234");
+
+        Pin pin2 = realm.createObject(Pin.class);
+        pin2.setId(2);
+        pin2.setName("Jane Doe");
+        pin2.setNumericCode("5678");
+
+        realm.commitTransaction();
+    }
+
+
+
+    /**
+     * Test retrieval of the first Pin instance from the database
+     */
+    @Test
+    public void testReadRealmDatabase() {
+        addPinsToRealmDatabase();
+
+        Pin retrievedPin = realm.where(Pin.class).findFirst();
+        Assert.assertNotNull(retrievedPin);
+        Assert.assertEquals(retrievedPin.getId(), 1);
+        Assert.assertEquals(retrievedPin.getName(), "John Smith");
+        Assert.assertEquals(retrievedPin.getNumericCode(), "1234");
+        Log.log(TAG, "retrieved Pin=" + retrievedPin);
+    }
+
+    /**
+     * Test retrieval using a simple "finaAll" query. Find all Pins where name == "John Smith"
+     */
+    @Test
+    public void testQueryRealmDatabase() {
+        addPinsToRealmDatabase();
+
+        RealmQuery<Pin> query = realm.where(Pin.class);
+        query.equalTo("name", "John Smith");
+        RealmResults<Pin> results = query.findAll();
+        Assert.assertNotNull(results);
+        Assert.assertEquals(1, results.size());
+
+        // Pin at location 0, has id 1
+        Pin queryPin = results.first();
+        Assert.assertEquals(queryPin.getId(), 1);
+        Assert.assertEquals(queryPin.getName(), "John Smith");
+        Assert.assertEquals(queryPin.getNumericCode(), "1234");
+    }
+
+    @Test
+    public void testIterateOverResults() {
+        RealmResults<Pin> results = realm.where(Pin.class).findAll();
+        for (Pin result : results) {
+            Log.log(TAG, "Iterated result=" + result);
+        }
+    }
+}
diff --git a/app/src/main/java/com/example/rodbailey/keypad/pinservice/Pin.java b/app/src/main/java/com/example/rodbailey/keypad/pinservice/Pin.java
index cefdd95..05fab03 100644
--- a/app/src/main/java/com/example/rodbailey/keypad/pinservice/Pin.java
+++ b/app/src/main/java/com/example/rodbailey/keypad/pinservice/Pin.java
@@ -3,50 +3,55 @@ package com.example.rodbailey.keypad.pinservice;
 import io.realm.RealmObject;
+import io.realm.annotations.PrimaryKey;
+import io.realm.annotations.Required;
 
 /**
  * Represents the PIN (numeric code) for a particular person's account or apartment.
  */
 public class Pin extends RealmObject {
     /**
      * String of digit characters of unprescribed length
      */
+    @Required
     private String numericCode;
 
     /**
      * Name of the owner of the PIN-protected thing
      */
+    @Required
     private String name;
 
     /**
      * Primary key of the Pin record
      */
+    @PrimaryKey
     private long id;
 
     public String getNumericCode() {
         return numericCode;
     }
 
     public void setNumericCode(String numericCode) {
         this.numericCode = numericCode;
     }
 
     public String getName() {
         return name;
     }
 
     public void setName(String name) {
         this.name = name;
     }
 
     public long getId() {
         return id;
     }
 
     public void setId(long id) {
         this.id = id;
     }
 
     @Override
     public String toString() {
         return String.format("id=%d,name=%s,numericCode=%s", id, name, numericCode);
     }
 }

commit c9a182dbcf4a3f660f7929d2f111a29cde270926
Author: rodbailey <rodney.p.bailey@gmail.com>
Date:   Fri May 6 21:24:12 2016 +1000

    More Realm tests

diff --git a/app/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java b/app/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java
index 7dbf419..7a7285f 100644
--- a/app/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java
+++ b/app/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java
@@ -12,2 +12,6 @@ import com.example.rodbailey.keypad.pinservice.Pin;
 
+import junit.framework.Assert;
+
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Rule;
@@ -18,75 +22,115 @@ import io.realm.Realm;
 import io.realm.RealmConfiguration;
+import io.realm.RealmQuery;
+import io.realm.RealmResults;
 
 /**
  * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
  */
 @RunWith(AndroidJUnit4.class)
 @LargeTest
 public class KeypadTest {
 
     private static final String TAG = KeypadTest.class.getSimpleName();
 
     @Rule
     public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<MainActivity>(MainActivity.class);
 
-    @Test
-    public void testCreateRealmDatabase() {
-        // Default realm database is /data/user/0/com.example.rodbailey.keypad/files/default.realm
-        // Due to symbolic links, /data/data/com.example.rodbailey.keypad/files/default.realm
-        Log.log(TAG, "--------------------");
-        Log.log(TAG, "Realm absolute database directory is: " + mActivityRule.getActivity().getFilesDir().getAbsolutePath());
+    public RealmConfiguration config;
+
+    public Realm realm;
 
-        RealmConfiguration config = new RealmConfiguration.Builder(mActivityRule.getActivity()).build();
-        Realm realm = Realm.getInstance(config);
+    @Before
+    public void before() {
+        config = new RealmConfiguration.Builder(mActivityRule.getActivity()).build();
+        realm = Realm.getInstance(config);
+        emptyRealmDatabase();
+    }
 
-        Log.log(TAG, "Performing CREATE for a Pin John Smith, 1234");
+    @After
+    public void after() {
+        realm.close();
+    }
 
+    private void emptyRealmDatabase() {
+        realm.beginTransaction();
+        RealmResults<Pin> allPins = realm.where(Pin.class).findAll();
+        allPins.deleteAllFromRealm();
+        realm.commitTransaction();
+    }
+
+    private void addPinToRealmDatabase() {
+        // Default realm database is /data/user/0/com.example.rodbailey.keypad/files/default.realm
+        // Due to symbolic links, /data/data/com.example.rodbailey.keypad/files/default.realm
         realm.beginTransaction();
         Pin pin = realm.createObject(Pin.class);
         pin.setId(1);
         pin.setName("John Smith");
         pin.setNumericCode("1234");
         realm.commitTransaction();
+    }
 
-
-        Log.log(TAG, "Created new Pin: 1,John Smith,1234");
+    @Test
+    public void testReadRealmDatabase() {
+        addPinToRealmDatabase();
 
         Pin retrievedPin = realm.where(Pin.class).findFirst();
+        Assert.assertNotNull(retrievedPin);
+        Assert.assertEquals(retrievedPin.getId(), 1);
+        Assert.assertEquals(retrievedPin.getName(), "John Smith");
+        Assert.assertEquals(retrievedPin.getNumericCode(), "1234");
         Log.log(TAG, "retrieved Pin=" + retrievedPin);
-        Log.log(TAG, "--------------------");
+    }
 
+    @Test
+    public void testQueryRealmDatabase() {
+        addPinToRealmDatabase();
+        
+        RealmQuery<Pin> query = realm.where(Pin.class);
+        query.equalTo("name", "John Smith");
+        RealmResults<Pin> results = query.findAll();
+        Assert.assertNotNull(results);
+        Assert.assertEquals(1, results.size());
+
+        Pin queryPin = results.first();
+        Assert.assertEquals(queryPin.getId(), 1);
+        Assert.assertEquals(queryPin.getName(), "John Smith");
+        Assert.assertEquals(queryPin.getNumericCode(), "1234");
+        Log.log(TAG, "queried Pin=" + queryPin);
+    }
+
+    @Test
+    public void testComplexQueryRealmDatabase() {
 
-        realm.close();
     }
 
     /*
 
     @Test
     public void testClickingNumber1KeyPuts1OnScreen() {
         // Click the "1" button
         Espresso.onView(ViewMatchers.withId(R.id.keypad_button_1)).perform(ViewActions.click());
 
         // Check there is a "1" on the screen
         Espresso.onView(ViewMatchers.withId(R.id.keypad_display)).check(ViewAssertions.matches(ViewMatchers.withText("1")));
     }
 
     @Test
     public void testClickingNumbers1and2Puts12OnScreen() {
         // Click the "1" button then the "2" button
         Espresso.onView(ViewMatchers.withId(R.id.keypad_button_1)).perform(ViewActions.click());
         Espresso.onView(ViewMatchers.withId(R.id.keypad_button_2)).perform(ViewActions.click());
 
         // Check there is a "12" on the screen
         Espresso.onView(ViewMatchers.withId(R.id.keypad_display)).check(ViewAssertions.matches(ViewMatchers.withText("12")));
     }
 
     @Test
     public void testClearButtonEmptiesDisplay() {
         // Click the "3" button
         Espresso.onView(ViewMatchers.withId(R.id.keypad_button_3)).perform(ViewActions.click());
         // Click the "Clear" button
         Espresso.onView(ViewMatchers.withId(R.id.keypad_button_clear)).perform(ViewActions.click());
         // Check the screen is empty string
         Espresso.onView(ViewMatchers.withId(R.id.keypad_display)).check(ViewAssertions.matches(ViewMatchers.withText("")));
     } */
 }
\ No newline at end of file

commit 53d501ed2f672edda28f019d96057594e5f3528c
Author: rodbailey <rodney.p.bailey@gmail.com>
Date:   Thu May 5 22:19:23 2016 +1000

    Started experimenting with Realm

diff --git a/.idea/misc.xml b/.idea/misc.xml
index fbb6828..5d19981 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,46 +1,46 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="EntryPointsManager">
     <entry_points version="2.0" />
   </component>
   <component name="NullableNotNullManager">
     <option name="myDefaultNullable" value="android.support.annotation.Nullable" />
     <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
     <option name="myNullables">
       <value>
         <list size="4">
           <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
           <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
           <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
           <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
         </list>
       </value>
     </option>
     <option name="myNotNulls">
       <value>
         <list size="4">
           <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
           <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
           <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
           <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
         </list>
       </value>
     </option>
   </component>
   <component name="ProjectLevelVcsManager" settingsEditedManually="false">
     <OptionsSetting value="true" id="Add" />
     <OptionsSetting value="true" id="Remove" />
     <OptionsSetting value="true" id="Checkout" />
     <OptionsSetting value="true" id="Update" />
     <OptionsSetting value="true" id="Status" />
     <OptionsSetting value="true" id="Edit" />
     <ConfirmationsSetting value="0" id="Add" />
     <ConfirmationsSetting value="0" id="Remove" />
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/build/classes" />
   </component>
   <component name="ProjectType">
     <option name="id" value="Android" />
   </component>
 </project>
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 62abe82..dfa36ba 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -34,13 +34,15 @@ android {
 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
     testCompile 'junit:junit:4.12'
     testCompile 'org.mockito:mockito-core:1.9.5'
     compile 'com.android.support:appcompat-v7:23.0.1'
     compile 'com.android.support:support-v4:23.0.1'
 
     androidTestCompile "com.android.support.test:runner:0.4.1"
     androidTestCompile "com.android.support.test:rules:0.4.1"
 
     androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
     androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.1'
+
+    apply plugin: 'realm-android'
 }
diff --git a/app/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java b/app/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java
index 15d5de5..7dbf419 100644
--- a/app/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java
+++ b/app/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java
@@ -10,2 +10,4 @@ import android.test.suitebuilder.annotation.LargeTest;
 
+import com.example.rodbailey.keypad.pinservice.Pin;
+
 import org.junit.Rule;
@@ -13,42 +15,78 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import io.realm.Realm;
+import io.realm.RealmConfiguration;
+
 /**
  * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
  */
 @RunWith(AndroidJUnit4.class)
 @LargeTest
 public class KeypadTest {
 
+    private static final String TAG = KeypadTest.class.getSimpleName();
+
     @Rule
     public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<MainActivity>(MainActivity.class);
 
+    @Test
+    public void testCreateRealmDatabase() {
+        // Default realm database is /data/user/0/com.example.rodbailey.keypad/files/default.realm
+        // Due to symbolic links, /data/data/com.example.rodbailey.keypad/files/default.realm
+        Log.log(TAG, "--------------------");
+        Log.log(TAG, "Realm absolute database directory is: " + mActivityRule.getActivity().getFilesDir().getAbsolutePath());
+
+        RealmConfiguration config = new RealmConfiguration.Builder(mActivityRule.getActivity()).build();
+        Realm realm = Realm.getInstance(config);
+
+        Log.log(TAG, "Performing CREATE for a Pin John Smith, 1234");
+
+        realm.beginTransaction();
+        Pin pin = realm.createObject(Pin.class);
+        pin.setId(1);
+        pin.setName("John Smith");
+        pin.setNumericCode("1234");
+        realm.commitTransaction();
+
+
+        Log.log(TAG, "Created new Pin: 1,John Smith,1234");
+
+        Pin retrievedPin = realm.where(Pin.class).findFirst();
+        Log.log(TAG, "retrieved Pin=" + retrievedPin);
+        Log.log(TAG, "--------------------");
+
+
+        realm.close();
+    }
+
+    /*
 
     @Test
     public void testClickingNumber1KeyPuts1OnScreen() {
         // Click the "1" button
         Espresso.onView(ViewMatchers.withId(R.id.keypad_button_1)).perform(ViewActions.click());
 
         // Check there is a "1" on the screen
         Espresso.onView(ViewMatchers.withId(R.id.keypad_display)).check(ViewAssertions.matches(ViewMatchers.withText("1")));
     }
 
     @Test
     public void testClickingNumbers1and2Puts12OnScreen() {
         // Click the "1" button then the "2" button
         Espresso.onView(ViewMatchers.withId(R.id.keypad_button_1)).perform(ViewActions.click());
         Espresso.onView(ViewMatchers.withId(R.id.keypad_button_2)).perform(ViewActions.click());
 
         // Check there is a "12" on the screen
         Espresso.onView(ViewMatchers.withId(R.id.keypad_display)).check(ViewAssertions.matches(ViewMatchers.withText("12")));
     }
 
     @Test
     public void testClearButtonEmptiesDisplay() {
         // Click the "3" button
         Espresso.onView(ViewMatchers.withId(R.id.keypad_button_3)).perform(ViewActions.click());
         // Click the "Clear" button
         Espresso.onView(ViewMatchers.withId(R.id.keypad_button_clear)).perform(ViewActions.click());
         // Check the screen is empty string
         Espresso.onView(ViewMatchers.withId(R.id.keypad_display)).check(ViewAssertions.matches(ViewMatchers.withText("")));
-    }
+    } */
 }
\ No newline at end of file
diff --git a/app/src/main/java/com/example/rodbailey/keypad/pinservice/FakePinService.java b/app/src/main/java/com/example/rodbailey/keypad/pinservice/FakePinService.java
new file mode 100644
index 0000000..4c40231
--- /dev/null
+++ b/app/src/main/java/com/example/rodbailey/keypad/pinservice/FakePinService.java
@@ -0,0 +1,29 @@
+package com.example.rodbailey.keypad.pinservice;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Fake implementation of the IPinService. Database of PINs is seeded with some hard coded PINs
+ * that are stored in memory.
+ */
+public class FakePinService implements IPinService {
+
+    Set<Pin> fakePins = new HashSet<Pin>();
+
+    public FakePinService() {
+//        fakePins.add(new Pin("1234", "John Smith"));
+    }
+
+
+    @Override
+    public Set<Pin> getAllPins() throws IOException {
+        return null;
+    }
+
+    @Override
+    public Pin getPinByNumericCode(String numericCode) throws IOException {
+        return null;
+    }
+}
diff --git a/app/src/main/java/com/example/rodbailey/keypad/pinservice/IPinService.java b/app/src/main/java/com/example/rodbailey/keypad/pinservice/IPinService.java
index 371d0a0..c1cefd7 100644
--- a/app/src/main/java/com/example/rodbailey/keypad/pinservice/IPinService.java
+++ b/app/src/main/java/com/example/rodbailey/keypad/pinservice/IPinService.java
@@ -3,23 +3,23 @@ package com.example.rodbailey.keypad.pinservice;
 import java.io.IOException;
-import java.util.List;
+import java.util.Set;
 
 /**
  * Provides a facade which higher levels use to access PIN number information.
  * This interface supports only read-only access to the database of PIN info.
  */
 public interface IPinService {
     /**
      * @return All currently defined PIN records. May be empty but is never null.
      * @throws IOException
      */
-    List<Pin> getAllPins() throws IOException;
+    Set<Pin> getAllPins() throws IOException;
 
     /**
      * @param numericCode Numeric code of the PIN record to be retrieved.
      * @return A Pin P such that P.numericCode.equals(numericCode), or null if no such Pin is
      * found in the databasE.
      * @throws IOException
      */
     Pin getPinByNumericCode(String numericCode) throws IOException;
 
 }
diff --git a/app/src/main/java/com/example/rodbailey/keypad/pinservice/Pin.java b/app/src/main/java/com/example/rodbailey/keypad/pinservice/Pin.java
index e39d7a7..cefdd95 100644
--- a/app/src/main/java/com/example/rodbailey/keypad/pinservice/Pin.java
+++ b/app/src/main/java/com/example/rodbailey/keypad/pinservice/Pin.java
@@ -1,12 +1,52 @@
 package com.example.rodbailey.keypad.pinservice;
 
+import io.realm.RealmObject;
+
 /**
  * Represents the PIN (numeric code) for a particular person's account or apartment.
  */
-public class Pin {
-    /** String of digit characters of unprescribed length */
-    String numericCode;
+public class Pin extends RealmObject {
+    /**
+     * String of digit characters of unprescribed length
+     */
+    private String numericCode;
+
+    /**
+     * Name of the owner of the PIN-protected thing
+     */
+    private String name;
+
+    /**
+     * Primary key of the Pin record
+     */
+    private long id;
+
+    public String getNumericCode() {
+        return numericCode;
+    }
+
+    public void setNumericCode(String numericCode) {
+        this.numericCode = numericCode;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
 
-    /** Name of the owner of the PIN-protected thing */
-    String name;
+    @Override
+    public String toString() {
+        return String.format("id=%d,name=%s,numericCode=%s", id, name, numericCode);
+    }
 }
diff --git a/build.gradle b/build.gradle
index aa9f6a0..e47db28 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,12 +3,12 @@
 buildscript {
     repositories {
         jcenter()
     }
     dependencies {
         classpath 'com.android.tools.build:gradle:2.1.0'
-
+        classpath "io.realm:realm-gradle-plugin:0.90.0"
 
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
     }
 }

commit 5c077d48f5e160c731fefd14c0475b95596f73c8
Author: rodbailey <rodney.p.bailey@gmail.com>
Date:   Thu Apr 28 23:43:23 2016 +1000

    Added IPInService

diff --git a/.idea/misc.xml b/.idea/misc.xml
index b78652a..fbb6828 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,19 +1,46 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
+  <component name="EntryPointsManager">
+    <entry_points version="2.0" />
+  </component>
+  <component name="NullableNotNullManager">
+    <option name="myDefaultNullable" value="android.support.annotation.Nullable" />
+    <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
+    <option name="myNullables">
+      <value>
+        <list size="4">
+          <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
+          <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
+          <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
+          <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
+        </list>
+      </value>
+    </option>
+    <option name="myNotNulls">
+      <value>
+        <list size="4">
+          <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
+          <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
+          <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
+          <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
+        </list>
+      </value>
+    </option>
+  </component>
   <component name="ProjectLevelVcsManager" settingsEditedManually="false">
     <OptionsSetting value="true" id="Add" />
     <OptionsSetting value="true" id="Remove" />
     <OptionsSetting value="true" id="Checkout" />
     <OptionsSetting value="true" id="Update" />
     <OptionsSetting value="true" id="Status" />
     <OptionsSetting value="true" id="Edit" />
     <ConfirmationsSetting value="0" id="Add" />
     <ConfirmationsSetting value="0" id="Remove" />
   </component>
   <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/build/classes" />
   </component>
   <component name="ProjectType">
     <option name="id" value="Android" />
   </component>
 </project>
\ No newline at end of file
diff --git a/app/src/main/java/com/example/rodbailey/keypad/pinservice/IPinService.java b/app/src/main/java/com/example/rodbailey/keypad/pinservice/IPinService.java
new file mode 100644
index 0000000..371d0a0
--- /dev/null
+++ b/app/src/main/java/com/example/rodbailey/keypad/pinservice/IPinService.java
@@ -0,0 +1,25 @@
+package com.example.rodbailey.keypad.pinservice;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Provides a facade which higher levels use to access PIN number information.
+ * This interface supports only read-only access to the database of PIN info.
+ */
+public interface IPinService {
+    /**
+     * @return All currently defined PIN records. May be empty but is never null.
+     * @throws IOException
+     */
+    List<Pin> getAllPins() throws IOException;
+
+    /**
+     * @param numericCode Numeric code of the PIN record to be retrieved.
+     * @return A Pin P such that P.numericCode.equals(numericCode), or null if no such Pin is
+     * found in the databasE.
+     * @throws IOException
+     */
+    Pin getPinByNumericCode(String numericCode) throws IOException;
+
+}
diff --git a/app/src/main/java/com/example/rodbailey/keypad/pinservice/Pin.java b/app/src/main/java/com/example/rodbailey/keypad/pinservice/Pin.java
new file mode 100644
index 0000000..e39d7a7
--- /dev/null
+++ b/app/src/main/java/com/example/rodbailey/keypad/pinservice/Pin.java
@@ -0,0 +1,12 @@
+package com.example.rodbailey.keypad.pinservice;
+
+/**
+ * Represents the PIN (numeric code) for a particular person's account or apartment.
+ */
+public class Pin {
+    /** String of digit characters of unprescribed length */
+    String numericCode;
+
+    /** Name of the owner of the PIN-protected thing */
+    String name;
+}

commit f76519f18fceb784cbf38452f876a06ddb71fbed
Author: rodbailey <rodney.p.bailey@gmail.com>
Date:   Thu Apr 28 22:10:46 2016 +1000

    Initial checkin for previously unversioned files.

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c6cbe56
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+*.iml
+.gradle
+/local.properties
+/.idea/workspace.xml
+/.idea/libraries
+.DS_Store
+/build
+/captures
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..afa6020
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+calculator
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..96cc43e
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <resourceExtensions />
+    <wildcardResourcePatterns>
+      <entry name="!?*.java" />
+      <entry name="!?*.form" />
+      <entry name="!?*.class" />
+      <entry name="!?*.groovy" />
+      <entry name="!?*.scala" />
+      <entry name="!?*.flex" />
+      <entry name="!?*.kt" />
+      <entry name="!?*.clj" />
+      <entry name="!?*.aj" />
+    </wildcardResourcePatterns>
+    <annotationProcessing>
+      <profile default="true" name="Default" enabled="false">
+        <processorPath useClasspath="true" />
+      </profile>
+    </annotationProcessing>
+  </component>
+</project>
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+<component name="CopyrightManager">
+  <settings default="" />
+</component>
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..97626ba
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding">
+    <file url="PROJECT" charset="UTF-8" />
+  </component>
+</project>
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..58992cc
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="GradleSettings">
+    <option name="linkedExternalProjectsSettings">
+      <GradleProjectSettings>
+        <option name="distributionType" value="LOCAL" />
+        <option name="externalProjectPath" value="$PROJECT_DIR$" />
+        <option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.10" />
+        <option name="modules">
+          <set>
+            <option value="$PROJECT_DIR$" />
+            <option value="$PROJECT_DIR$/app" />
+          </set>
+        </option>
+        <option name="myModules">
+          <set>
+            <option value="$PROJECT_DIR$" />
+            <option value="$PROJECT_DIR$/app" />
+          </set>
+        </option>
+      </GradleProjectSettings>
+    </option>
+  </component>
+</project>
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..b78652a
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectLevelVcsManager" settingsEditedManually="false">
+    <OptionsSetting value="true" id="Add" />
+    <OptionsSetting value="true" id="Remove" />
+    <OptionsSetting value="true" id="Checkout" />
+    <OptionsSetting value="true" id="Update" />
+    <OptionsSetting value="true" id="Status" />
+    <OptionsSetting value="true" id="Edit" />
+    <ConfirmationsSetting value="0" id="Add" />
+    <ConfirmationsSetting value="0" id="Remove" />
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/build/classes" />
+  </component>
+  <component name="ProjectType">
+    <option name="id" value="Android" />
+  </component>
+</project>
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..8377c54
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
+      <module fileurl="file://$PROJECT_DIR$/calculator.iml" filepath="$PROJECT_DIR$/calculator.iml" />
+    </modules>
+  </component>
+</project>
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 0000000..7f68460
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="RunConfigurationProducerService">
+    <option name="ignoredProducers">
+      <set>
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
+      </set>
+    </option>
+  </component>
+</project>
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..aa9f6a0
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,24 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+    repositories {
+        jcenter()
+    }
+    dependencies {
+        classpath 'com.android.tools.build:gradle:2.1.0'
+
+
+        // NOTE: Do not place your application dependencies here; they belong
+        // in the individual module build.gradle files
+    }
+}
+
+allprojects {
+    repositories {
+        jcenter()
+    }
+}
+
+task clean(type: Delete) {
+    delete rootProject.buildDir
+}
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..1d3591c
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,18 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..13372ae
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..122a0dc
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Dec 28 10:00:20 PST 2015
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..9d82f78
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..8a0b282
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..e7b4def
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+include ':app'

commit ec70805ed115a430aac23032604bbc45cffdadaa
Author: rodbailey <rodney.p.bailey@gmail.com>
Date:   Mon Apr 25 21:34:46 2016 +1000

    Added Espresso test

diff --git a/app/build.gradle b/app/build.gradle
index fcd2aba..62abe82 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -3,18 +3,30 @@ apply plugin: 'com.android.application'
 android {
     compileSdkVersion 23
     buildToolsVersion "23.0.3"
 
     defaultConfig {
         applicationId "com.example.rodbailey.keypad"
         minSdkVersion 15
         targetSdkVersion 23
         versionCode 1
         versionName "1.0"
+
+        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
     buildTypes {
         release {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
     }
+
+    // If you need to add more flavors, consider using flavor dimensions.
+    productFlavors {
+        mock {
+            applicationIdSuffix = ".mock"
+        }
+        prod {
+
+        }
+    }
 }
@@ -22,7 +34,13 @@ android {
 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
     testCompile 'junit:junit:4.12'
     testCompile 'org.mockito:mockito-core:1.9.5'
-    compile 'com.android.support:appcompat-v7:23.3.0'
-    compile 'com.android.support:support-v4:23.3.0'
+    compile 'com.android.support:appcompat-v7:23.0.1'
+    compile 'com.android.support:support-v4:23.0.1'
+
+    androidTestCompile "com.android.support.test:runner:0.4.1"
+    androidTestCompile "com.android.support.test:rules:0.4.1"
+
+    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
+    androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.1'
 }
diff --git a/app/src/androidTest/java/com/example/rodbailey/keypad/ApplicationTest.java b/app/src/androidTest/java/com/example/rodbailey/keypad/ApplicationTest.java
deleted file mode 100644
index 466058c..0000000
--- a/app/src/androidTest/java/com/example/rodbailey/keypad/ApplicationTest.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.example.rodbailey.keypad;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
- */
-public class ApplicationTest extends ApplicationTestCase<Application> {
-    public ApplicationTest() {
-        super(Application.class);
-    }
-}
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java b/app/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java
new file mode 100644
index 0000000..15d5de5
--- /dev/null
+++ b/app/src/androidTest/java/com/example/rodbailey/keypad/KeypadTest.java
@@ -0,0 +1,54 @@
+package com.example.rodbailey.keypad;
+
+import android.support.test.espresso.Espresso;
+import android.support.test.espresso.action.ViewActions;
+import android.support.test.espresso.assertion.ViewAssertions;
+import android.support.test.espresso.matcher.ViewMatchers;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+import android.test.suitebuilder.annotation.LargeTest;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
+ */
+@RunWith(AndroidJUnit4.class)
+@LargeTest
+public class KeypadTest {
+
+    @Rule
+    public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<MainActivity>(MainActivity.class);
+
+
+    @Test
+    public void testClickingNumber1KeyPuts1OnScreen() {
+        // Click the "1" button
+        Espresso.onView(ViewMatchers.withId(R.id.keypad_button_1)).perform(ViewActions.click());
+
+        // Check there is a "1" on the screen
+        Espresso.onView(ViewMatchers.withId(R.id.keypad_display)).check(ViewAssertions.matches(ViewMatchers.withText("1")));
+    }
+
+    @Test
+    public void testClickingNumbers1and2Puts12OnScreen() {
+        // Click the "1" button then the "2" button
+        Espresso.onView(ViewMatchers.withId(R.id.keypad_button_1)).perform(ViewActions.click());
+        Espresso.onView(ViewMatchers.withId(R.id.keypad_button_2)).perform(ViewActions.click());
+
+        // Check there is a "12" on the screen
+        Espresso.onView(ViewMatchers.withId(R.id.keypad_display)).check(ViewAssertions.matches(ViewMatchers.withText("12")));
+    }
+
+    @Test
+    public void testClearButtonEmptiesDisplay() {
+        // Click the "3" button
+        Espresso.onView(ViewMatchers.withId(R.id.keypad_button_3)).perform(ViewActions.click());
+        // Click the "Clear" button
+        Espresso.onView(ViewMatchers.withId(R.id.keypad_button_clear)).perform(ViewActions.click());
+        // Check the screen is empty string
+        Espresso.onView(ViewMatchers.withId(R.id.keypad_display)).check(ViewAssertions.matches(ViewMatchers.withText("")));
+    }
+}
\ No newline at end of file

commit ab2b8cbf0e7dcf88a783c4064807169fb05325df
Author: rodbailey <rodney.p.bailey@gmail.com>
Date:   Sun Apr 24 20:18:55 2016 +1000

    Improved presenter test with more Mockito

diff --git a/app/src/main/java/com/example/rodbailey/keypad/KeypadPresenter.java b/app/src/main/java/com/example/rodbailey/keypad/KeypadPresenter.java
index bff42dc..7a2af4b 100644
--- a/app/src/main/java/com/example/rodbailey/keypad/KeypadPresenter.java
+++ b/app/src/main/java/com/example/rodbailey/keypad/KeypadPresenter.java
@@ -6,77 +6,77 @@ import static com.example.rodbailey.keypad.Log.log;
 /**
  *
  */
 public class KeypadPresenter implements IKeypadPresenter {
     private static final String TAG = KeypadPresenter.class.getSimpleName();
     private final IKeypadModel keypadModel;
     private final IKeypadView keypadView;
 
     /**
      * You have to pass in a model, otherwise how can you tell if the
      * presenter is working or not? You need to have access to the model
      * to tell if the presenter is modifying it correctly, which precludes
      * creating it privately.
      *
      * @param model
      * @param view
      */
     public KeypadPresenter(IKeypadView view, IKeypadModel model) {
         keypadModel = model;
         keypadView = view;
     }
 
     @Override
     public void keyPressed(KeypadKey key) {
         log(TAG, "keyPressed: " + key);
 
         // Pass user interaction onto the model
         if (key.isNumeric()) {
             char charToRegister = numericKeyToChar(key);
             keypadModel.appendToRegister(charToRegister);
+            // Pass new model contents back up to view
+            String newDisplay = keypadModel.getRegister();
+            keypadView.setDisplay(newDisplay);
         } else if (key == KeypadKey.KEY_CLEAR) {
             keypadModel.clearRegister();
+            keypadView.clearDisplay();
         } else if (key == KeypadKey.KEY_OK) {
             // Do what?
         }
-
-        // Pass new model contents back up to view
-        String newDisplay = keypadModel.getRegister();
-        keypadView.setDisplay(newDisplay);
     }
 
     private char numericKeyToChar(KeypadKey key) {
         char result = ' ';
 
         switch (key) {
             case KEY_1:
                 result = '1';
                 break;
             case KEY_2:
                 result = '2';
                 break;
             case KEY_3:
                 result = '3';
                 break;
             case KEY_4:
                 result = '4';
                 break;
             case KEY_5:
                 result = '5';
                 break;
             case KEY_6:
                 result = '6';
                 break;
             case KEY_7:
                 result = '7';
                 break;
             case KEY_8:
                 result = '8';
                 break;
             case KEY_9:
                 result = '9';
                 break;
         }
 
         return result;
     }
 }
diff --git a/app/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java b/app/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
index 1875fd9..ab571b6 100644
--- a/app/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
+++ b/app/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
@@ -6,30 +6,38 @@ import org.mockito.Mockito;
 /**
  * Test the KeypadPresenter, for which we need a mock model and a mock view
  */
 public class KeypadPresenterTest {
 
     @Test
     public void presenterPassesNumericKeyPressesOntoModel() {
         IKeypadModel mockModel = Mockito.mock(IKeypadModel.class);
         IKeypadView mockView = Mockito.mock(IKeypadView.class);
         IKeypadPresenter presenter = new KeypadPresenter(mockView, mockModel);
+
+        // When the model.getRegister() is called, return "1"
+        Mockito.when(mockModel.getRegister()).thenReturn("1");
         presenter.keyPressed(KeypadKey.KEY_1);
 
         // Verify that presenter called mockModel.appendToRegister('1');
         Mockito.verify(mockModel).appendToRegister('1');
+
+        // Verify that presenter called mockView.setDisplay("1");
+        Mockito.verify(mockView).setDisplay("1");
     }
 
     @Test
     public void presenterPassesClearKeyPressOntoModel() {
-
         IKeypadModel mockModel = Mockito.mock(IKeypadModel.class);
         IKeypadView mockView = Mockito.mock(IKeypadView.class);
         IKeypadPresenter presenter = new KeypadPresenter(mockView, mockModel);
         presenter.keyPressed(KeypadKey.KEY_CLEAR);
 
         // Verify that presenter called mockModel.clearRegister()
         Mockito.verify(mockModel).clearRegister();
+
+        // Verify that presenter called mockView.clearDisplay();
+        Mockito.verify(mockView).clearDisplay();
     }
 
 
 }

commit 61d7b9fb89c0e6fbcec16b4bc8c9c180a30b591d
Author: rodbailey <rodney.p.bailey@gmail.com>
Date:   Sun Apr 24 19:58:41 2016 +1000

    Update to use Mockito

diff --git a/app/build.gradle b/app/build.gradle
index 3a07d61..fcd2aba 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -22,6 +22,7 @@ android {
 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
     testCompile 'junit:junit:4.12'
+    testCompile 'org.mockito:mockito-core:1.9.5'
     compile 'com.android.support:appcompat-v7:23.3.0'
     compile 'com.android.support:support-v4:23.3.0'
 }
diff --git a/app/src/main/java/com/example/rodbailey/keypad/IKeypadModel.java b/app/src/main/java/com/example/rodbailey/keypad/IKeypadModel.java
index 6aff28b..ec5c4f5 100644
--- a/app/src/main/java/com/example/rodbailey/keypad/IKeypadModel.java
+++ b/app/src/main/java/com/example/rodbailey/keypad/IKeypadModel.java
@@ -3,15 +3,11 @@ package com.example.rodbailey.keypad;
 /**
  * Created by rodbailey on 24/04/2016.
  */
 public interface IKeypadModel {
 
     public void appendToRegister(char value);
 
     public void clearRegister();
 
     public String getRegister();
-
-    public interface IKeypadModelResultHandler {
-        public void onResult(Object result);
-    }
 }
diff --git a/app/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java b/app/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
index 698e90d..1875fd9 100644
--- a/app/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
+++ b/app/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
@@ -2,99 +2,34 @@ package com.example.rodbailey.keypad;
 
-import org.junit.Before;
 import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.mockito.Mockito;
 
 /**
  * Test the KeypadPresenter, for which we need a mock model and a mock view
  */
 public class KeypadPresenterTest {
 
-    private boolean expectedMethodCalled;
-
-    @Before
-    public void beforeEachTest() {
-        expectedMethodCalled = false;
-    }
-
     @Test
     public void presenterPassesNumericKeyPressesOntoModel() {
-        IKeypadModel mockModel = new IKeypadModel() {
-            @Override
-            public void appendToRegister(char value) {
-                expectedMethodCalled = true;
-                assertEquals('1', value);
-            }
-
-            @Override
-            public void clearRegister() {
-
-            }
-
-            @Override
-            public String getRegister() {
-                return "";
-            }
-        };
-        IKeypadView mockView = new MockKeypadView();
+        IKeypadModel mockModel = Mockito.mock(IKeypadModel.class);
+        IKeypadView mockView = Mockito.mock(IKeypadView.class);
         IKeypadPresenter presenter = new KeypadPresenter(mockView, mockModel);
         presenter.keyPressed(KeypadKey.KEY_1);
-        assertTrue(expectedMethodCalled);
+
+        // Verify that presenter called mockModel.appendToRegister('1');
+        Mockito.verify(mockModel).appendToRegister('1');
     }
 
     @Test
     public void presenterPassesClearKeyPressOntoModel() {
-        IKeypadModel mockModel = new IKeypadModel() {
-            @Override
-            public void appendToRegister(char value) {
-
-            }
-
-            @Override
-            public void clearRegister() {
-                expectedMethodCalled = true;
-            }
 
-            @Override
-            public String getRegister() {
-                return "";
-            }
-        };
-        IKeypadView mockView = new MockKeypadView();
+        IKeypadModel mockModel = Mockito.mock(IKeypadModel.class);
+        IKeypadView mockView = Mockito.mock(IKeypadView.class);
         IKeypadPresenter presenter = new KeypadPresenter(mockView, mockModel);
         presenter.keyPressed(KeypadKey.KEY_CLEAR);
-        assertEquals("", mockModel.getRegister());
-    }
-
-    private class MockKeypadView implements IKeypadView {
-        private String mockDisplay;
-
-        @Override
-        public void clearDisplay() {
-
-        }
-
-        @Override
-        public void setDisplay(String display) {
 
-        }
+        // Verify that presenter called mockModel.clearRegister()
+        Mockito.verify(mockModel).clearRegister();
     }
 
-    private class MockKeypadModel implements IKeypadModel {
-        @Override
-        public void clearRegister() {
 
-        }
-
-        @Override
-        public String getRegister() {
-            return "";
-        }
-
-        @Override
-        public void appendToRegister(char value) {
-
-        }
-    }
 }

commit f5f094c683da138ae4c154d47d66b58f02e9b93b
Author: rodbailey <rodney.p.bailey@gmail.com>
Date:   Sun Apr 24 16:09:58 2016 +1000

    Update from codelabs example.

diff --git a/app/src/main/java/com/example/rodbailey/keypad/IKeypadModel.java b/app/src/main/java/com/example/rodbailey/keypad/IKeypadModel.java
new file mode 100644
index 0000000..6aff28b
--- /dev/null
+++ b/app/src/main/java/com/example/rodbailey/keypad/IKeypadModel.java
@@ -0,0 +1,17 @@
+package com.example.rodbailey.keypad;
+
+/**
+ * Created by rodbailey on 24/04/2016.
+ */
+public interface IKeypadModel {
+
+    public void appendToRegister(char value);
+
+    public void clearRegister();
+
+    public String getRegister();
+
+    public interface IKeypadModelResultHandler {
+        public void onResult(Object result);
+    }
+}
diff --git a/app/src/main/java/com/example/rodbailey/keypad/KeypadModel.java b/app/src/main/java/com/example/rodbailey/keypad/KeypadModel.java
index b1c77c6..1fbc1e2 100644
--- a/app/src/main/java/com/example/rodbailey/keypad/KeypadModel.java
+++ b/app/src/main/java/com/example/rodbailey/keypad/KeypadModel.java
@@ -1,32 +1,28 @@
 package com.example.rodbailey.keypad;
 
+import static com.example.rodbailey.keypad.Log.log;
+
 /**
  * The keypad itself.
  */
-public class KeypadModel {
+public class KeypadModel implements IKeypadModel {
 
     private static final String TAG = KeypadModel.class.getSimpleName();
 
     private StringBuffer register = new StringBuffer();
 
-    public KeypadModel() {
-
-    }
-
     public String getRegister() {
         return register.toString();
     }
 
     public void appendToRegister(char value) {
-        System.out.println("append to register value: " + value);
-
+        log(TAG, "append to register value: " + value);
         register.append(value);
-
-        System.out.println("new register value: \"" + register.toString() + "\"");
+        log(TAG, "new register value: \"" + register.toString() + "\"");
     }
 
     public void clearRegister() {
         register.setLength(0);
-        System.out.println("register cleared. new register value: \"" + register.toString() + "\"");
+        log(TAG, "register cleared. new register value: \"" + register.toString() + "\"");
     }
 }
diff --git a/app/src/main/java/com/example/rodbailey/keypad/KeypadPresenter.java b/app/src/main/java/com/example/rodbailey/keypad/KeypadPresenter.java
index 879ef55..bff42dc 100644
--- a/app/src/main/java/com/example/rodbailey/keypad/KeypadPresenter.java
+++ b/app/src/main/java/com/example/rodbailey/keypad/KeypadPresenter.java
@@ -2,66 +2,81 @@ package com.example.rodbailey.keypad;
 
-import android.util.Log;
+
+import static com.example.rodbailey.keypad.Log.log;
 
 /**
  *
  */
 public class KeypadPresenter implements IKeypadPresenter {
     private static final String TAG = KeypadPresenter.class.getSimpleName();
-    private final KeypadModel keypadModel;
+    private final IKeypadModel keypadModel;
+    private final IKeypadView keypadView;
 
-    public KeypadPresenter() {
-        keypadModel = new KeypadModel();
+    /**
+     * You have to pass in a model, otherwise how can you tell if the
+     * presenter is working or not? You need to have access to the model
+     * to tell if the presenter is modifying it correctly, which precludes
+     * creating it privately.
+     *
+     * @param model
+     * @param view
+     */
+    public KeypadPresenter(IKeypadView view, IKeypadModel model) {
+        keypadModel = model;
+        keypadView = view;
     }
 
     @Override
     public void keyPressed(KeypadKey key) {
-        Log.d(TAG, "keyPressed: " + key);
+        log(TAG, "keyPressed: " + key);
+
+        // Pass user interaction onto the model
         if (key.isNumeric()) {
             char charToRegister = numericKeyToChar(key);
             keypadModel.appendToRegister(charToRegister);
-        }
-        else if (key == KeypadKey.KEY_CLEAR) {
+        } else if (key == KeypadKey.KEY_CLEAR) {
             keypadModel.clearRegister();
-        }
-        else if (key == KeypadKey.KEY_OK) {
+        } else if (key == KeypadKey.KEY_OK) {
             // Do what?
         }
 
+        // Pass new model contents back up to view
+        String newDisplay = keypadModel.getRegister();
+        keypadView.setDisplay(newDisplay);
     }
 
     private char numericKeyToChar(KeypadKey key) {
         char result = ' ';
 
         switch (key) {
             case KEY_1:
                 result = '1';
                 break;
             case KEY_2:
                 result = '2';
                 break;
             case KEY_3:
                 result = '3';
                 break;
             case KEY_4:
                 result = '4';
                 break;
             case KEY_5:
                 result = '5';
                 break;
             case KEY_6:
                 result = '6';
                 break;
             case KEY_7:
                 result = '7';
                 break;
             case KEY_8:
                 result = '8';
                 break;
             case KEY_9:
                 result = '9';
                 break;
         }
 
         return result;
     }
 }
diff --git a/app/src/main/java/com/example/rodbailey/keypad/KeypadView.java b/app/src/main/java/com/example/rodbailey/keypad/KeypadView.java
index acab3a4..877a489 100644
--- a/app/src/main/java/com/example/rodbailey/keypad/KeypadView.java
+++ b/app/src/main/java/com/example/rodbailey/keypad/KeypadView.java
@@ -29,98 +29,98 @@ import static com.example.rodbailey.keypad.KeypadKey.KEY_OK;
 /**
  * View of the keypad. This is a *passive* view - it does nothing itself, it contains no logic of its own.
  */
 public class KeypadView extends Fragment implements IKeypadView {
 
     private static final String TAG = KeypadView.class.getSimpleName();
     private TextView display;
     private Map<Button, KeypadKey> keys = new HashMap<Button, KeypadKey>();
     private KeypadClickListener keypadClickListener = new KeypadClickListener();
     private final IKeypadPresenter keypadPresenter;
 
     /**
      * Fragments must have a public empty constructor
      */
     public KeypadView() {
-        keypadPresenter = new KeypadPresenter();
+        keypadPresenter = new KeypadPresenter(this, new KeypadModel());
     }
 
     /**
      * Use this factory method to create a new instance of
      * this fragment using the provided parameters.
      *
      * @return A new instance of fragment KeypadView.
      */
     public static KeypadView newInstance() {
         KeypadView fragment = new KeypadView();
         return fragment;
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
     }
 
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
         View fragmentView = inflater.inflate(R.layout.keypad_view, container, false);
 
         Log.d(TAG, "Into onCreateView");
 
         // The output display at the top of the keypad
         display = (TextView) fragmentView.findViewById(R.id.keypad_display);
 
         Log.d(TAG, "R.id.keypad_display is bound to widget " + display);
 
         // Each key in the keypad is in the 'keys' array, so we can identify symbolically which
         // button is clicked on.
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_1), KEY_1);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_2), KEY_2);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_3), KEY_3);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_4), KEY_4);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_5), KEY_5);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_6), KEY_6);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_7), KEY_7);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_8), KEY_8);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_9), KEY_9);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_clear), KEY_CLEAR);
         keys.put((Button) fragmentView.findViewById(R.id.keypad_button_ok), KEY_OK);
 
         for (Button button : keys.keySet()) {
             button.setOnClickListener(keypadClickListener);
         }
 
         Log.d(TAG, "Exiting onCreateView");
 
         return fragmentView;
     }
 
     @Override
     public void onAttach(Context context) {
         super.onAttach(context);
 
     }
 
     @Override
     public void onDetach() {
         super.onDetach();
     }
 
     @Override
     public void setDisplay(String display) {
         this.display.setText(display);
     }
 
     @Override
     public void clearDisplay() {
         display.setText("");
     }
 
     private class KeypadClickListener implements View.OnClickListener {
         @Override
         public void onClick(View view) {
             KeypadKey keyClicked = keys.get(view);
             keypadPresenter.keyPressed(keyClicked);
         }
     }
 }
diff --git a/app/src/main/java/com/example/rodbailey/keypad/Log.java b/app/src/main/java/com/example/rodbailey/keypad/Log.java
new file mode 100644
index 0000000..64e0284
--- /dev/null
+++ b/app/src/main/java/com/example/rodbailey/keypad/Log.java
@@ -0,0 +1,15 @@
+package com.example.rodbailey.keypad;
+
+/**
+ * Facade to logging facility, so you can switch Android's Log in and out
+ */
+public class Log {
+
+    public static void log(String tag, String msg) {
+        System.out.println(tag + ":" + msg);
+    }
+
+    public static void log(String msg) {
+        System.out.println(msg);
+    }
+}
diff --git a/app/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java b/app/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
new file mode 100644
index 0000000..698e90d
--- /dev/null
+++ b/app/src/test/java/com/example/rodbailey/keypad/KeypadPresenterTest.java
@@ -0,0 +1,100 @@
+package com.example.rodbailey.keypad;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test the KeypadPresenter, for which we need a mock model and a mock view
+ */
+public class KeypadPresenterTest {
+
+    private boolean expectedMethodCalled;
+
+    @Before
+    public void beforeEachTest() {
+        expectedMethodCalled = false;
+    }
+
+    @Test
+    public void presenterPassesNumericKeyPressesOntoModel() {
+        IKeypadModel mockModel = new IKeypadModel() {
+            @Override
+            public void appendToRegister(char value) {
+                expectedMethodCalled = true;
+                assertEquals('1', value);
+            }
+
+            @Override
+            public void clearRegister() {
+
+            }
+
+            @Override
+            public String getRegister() {
+                return "";
+            }
+        };
+        IKeypadView mockView = new MockKeypadView();
+        IKeypadPresenter presenter = new KeypadPresenter(mockView, mockModel);
+        presenter.keyPressed(KeypadKey.KEY_1);
+        assertTrue(expectedMethodCalled);
+    }
+
+    @Test
+    public void presenterPassesClearKeyPressOntoModel() {
+        IKeypadModel mockModel = new IKeypadModel() {
+            @Override
+            public void appendToRegister(char value) {
+
+            }
+
+            @Override
+            public void clearRegister() {
+                expectedMethodCalled = true;
+            }
+
+            @Override
+            public String getRegister() {
+                return "";
+            }
+        };
+        IKeypadView mockView = new MockKeypadView();
+        IKeypadPresenter presenter = new KeypadPresenter(mockView, mockModel);
+        presenter.keyPressed(KeypadKey.KEY_CLEAR);
+        assertEquals("", mockModel.getRegister());
+    }
+
+    private class MockKeypadView implements IKeypadView {
+        private String mockDisplay;
+
+        @Override
+        public void clearDisplay() {
+
+        }
+
+        @Override
+        public void setDisplay(String display) {
+
+        }
+    }
+
+    private class MockKeypadModel implements IKeypadModel {
+        @Override
+        public void clearRegister() {
+
+        }
+
+        @Override
+        public String getRegister() {
+            return "";
+        }
+
+        @Override
+        public void appendToRegister(char value) {
+
+        }
+    }
+}
diff --git a/app/src/test/java/com/example/rodbailey/keypad/KeypadTestSuite.java b/app/src/test/java/com/example/rodbailey/keypad/KeypadTestSuite.java
new file mode 100644
index 0000000..8ad6493
--- /dev/null
+++ b/app/src/test/java/com/example/rodbailey/keypad/KeypadTestSuite.java
@@ -0,0 +1,13 @@
+package com.example.rodbailey.keypad;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+        KeypadModelTest.class,
+        KeypadPresenterTest.class
+})
+public class KeypadTestSuite {
+}

commit 90080a5c7bf313871eb2e9b5fe82e79aaf28701c
Author: rodbailey <rodney.p.bailey@gmail.com>
Date:   Sat Apr 23 21:56:26 2016 +1000

    Initial checkin to local repo

diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>
\ No newline at end of file
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..3a07d61
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,27 @@
+apply plugin: 'com.android.application'
+
+android {
+    compileSdkVersion 23
+    buildToolsVersion "23.0.3"
+
+    defaultConfig {
+        applicationId "com.example.rodbailey.keypad"
+        minSdkVersion 15
+        targetSdkVersion 23
+        versionCode 1
+        versionName "1.0"
+    }
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+        }
+    }
+}
+
+dependencies {
+    compile fileTree(dir: 'libs', include: ['*.jar'])
+    testCompile 'junit:junit:4.12'
+    compile 'com.android.support:appcompat-v7:23.3.0'
+    compile 'com.android.support:support-v4:23.3.0'
+}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..9043fc8
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /Users/rodbailey/Library/Android/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
diff --git a/app/src/androidTest/java/com/example/rodbailey/keypad/ApplicationTest.java b/app/src/androidTest/java/com/example/rodbailey/keypad/ApplicationTest.java
new file mode 100644
index 0000000..466058c
--- /dev/null
+++ b/app/src/androidTest/java/com/example/rodbailey/keypad/ApplicationTest.java
@@ -0,0 +1,13 @@
+package com.example.rodbailey.keypad;
+
+import android.app.Application;
+import android.test.ApplicationTestCase;
+
+/**
+ * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
+ */
+public class ApplicationTest extends ApplicationTestCase<Application> {
+    public ApplicationTest() {
+        super(Application.class);
+    }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..8176660
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.example.rodbailey.keypad">
+
+    <application
+        android:allowBackup="true"
+        android:icon="@mipmap/ic_launcher"
+        android:label="@string/app_name"
+        android:supportsRtl="true"
+        android:theme="@style/AppTheme">
+        <activity android:name="com.example.rodbailey.keypad.MainActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>
\ No newline at end of file
diff --git a/app/src/main/java/com/example/rodbailey/keypad/IKeypadPresenter.java b/app/src/main/java/com/example/rodbailey/keypad/IKeypadPresenter.java
new file mode 100644
index 0000000..c99744c
--- /dev/null
+++ b/app/src/main/java/com/example/rodbailey/keypad/IKeypadPresenter.java
@@ -0,0 +1,14 @@
+package com.example.rodbailey.keypad;
+
+/**
+ * This interface must be implemented by any party wanting to present a KeypadView.
+ */
+public interface IKeypadPresenter {
+
+    /**
+     * Invoked when a key on the keypad is tapped by the user.
+     *
+     * @param key The key the user tapped.
+     */
+    public void keyPressed(KeypadKey key);
+}
diff --git a/app/src/main/java/com/example/rodbailey/keypad/IKeypadView.java b/app/src/main/java/com/example/rodbailey/keypad/IKeypadView.java
new file mode 100644
index 0000000..24e8516
--- /dev/null
+++ b/app/src/main/java/com/example/rodbailey/keypad/IKeypadView.java
@@ -0,0 +1,21 @@
+package com.example.rodbailey.keypad;
+
+/**
+ * This interface must be implemented by any keypad view. It contains those directives delivered
+ * from the IKeypadPresented that instruct the IKeypadView to make certain changes in its view
+ * state.
+ */
+public interface IKeypadView {
+
+    /**
+     * Displays the given string in the keypad's display area
+     *
+     * @param display The string to literally display.
+     */
+    public void setDisplay(String display);
+
+    /**
+     * Empties the keypad's display area
+     */
+    public void clearDisplay();
+}
diff --git a/app/src/main/java/com/example/rodbailey/keypad/KeypadKey.java b/app/src/main/java/com/example/rodbailey/keypad/KeypadKey.java
new file mode 100644
index 0000000..0fd5332
--- /dev/null
+++ b/app/src/main/java/com/example/rodbailey/keypad/KeypadKey.java
@@ -0,0 +1,12 @@
+package com.example.rodbailey.keypad;
+
+/**
+ * Symbolic representation of every key in the IKeypadView
+ */
+public enum KeypadKey {
+    KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_CLEAR, KEY_OK;
+
+    public boolean isNumeric() {
+        return ((this != KEY_CLEAR) && (this != KEY_OK));
+    }
+}
diff --git a/app/src/main/java/com/example/rodbailey/keypad/KeypadModel.java b/app/src/main/java/com/example/rodbailey/keypad/KeypadModel.java
new file mode 100644
index 0000000..b1c77c6
--- /dev/null
+++ b/app/src/main/java/com/example/rodbailey/keypad/KeypadModel.java
@@ -0,0 +1,32 @@
+package com.example.rodbailey.keypad;
+
+/**
+ * The keypad itself.
+ */
+public class KeypadModel {
+
+    private static final String TAG = KeypadModel.class.getSimpleName();
+
+    private StringBuffer register = new StringBuffer();
+
+    public KeypadModel() {
+
+    }
+
+    public String getRegister() {
+        return register.toString();
+    }
+
+    public void appendToRegister(char value) {
+        System.out.println("append to register value: " + value);
+
+        register.append(value);
+
+        System.out.println("new register value: \"" + register.toString() + "\"");
+    }
+
+    public void clearRegister() {
+        register.setLength(0);
+        System.out.println("register cleared. new register value: \"" + register.toString() + "\"");
+    }
+}
diff --git a/app/src/main/java/com/example/rodbailey/keypad/KeypadPresenter.java b/app/src/main/java/com/example/rodbailey/keypad/KeypadPresenter.java
new file mode 100644
index 0000000..879ef55
--- /dev/null
+++ b/app/src/main/java/com/example/rodbailey/keypad/KeypadPresenter.java
@@ -0,0 +1,67 @@
+package com.example.rodbailey.keypad;
+
+import android.util.Log;
+
+/**
+ *
+ */
+public class KeypadPresenter implements IKeypadPresenter {
+    private static final String TAG = KeypadPresenter.class.getSimpleName();
+    private final KeypadModel keypadModel;
+
+    public KeypadPresenter() {
+        keypadModel = new KeypadModel();
+    }
+
+    @Override
+    public void keyPressed(KeypadKey key) {
+        Log.d(TAG, "keyPressed: " + key);
+        if (key.isNumeric()) {
+            char charToRegister = numericKeyToChar(key);
+            keypadModel.appendToRegister(charToRegister);
+        }
+        else if (key == KeypadKey.KEY_CLEAR) {
+            keypadModel.clearRegister();
+        }
+        else if (key == KeypadKey.KEY_OK) {
+            // Do what?
+        }
+
+    }
+
+    private char numericKeyToChar(KeypadKey key) {
+        char result = ' ';
+
+        switch (key) {
+            case KEY_1:
+                result = '1';
+                break;
+            case KEY_2:
+                result = '2';
+                break;
+            case KEY_3:
+                result = '3';
+                break;
+            case KEY_4:
+                result = '4';
+                break;
+            case KEY_5:
+                result = '5';
+                break;
+            case KEY_6:
+                result = '6';
+                break;
+            case KEY_7:
+                result = '7';
+                break;
+            case KEY_8:
+                result = '8';
+                break;
+            case KEY_9:
+                result = '9';
+                break;
+        }
+
+        return result;
+    }
+}
diff --git a/app/src/main/java/com/example/rodbailey/keypad/KeypadView.java b/app/src/main/java/com/example/rodbailey/keypad/KeypadView.java
new file mode 100644
index 0000000..acab3a4
--- /dev/null
+++ b/app/src/main/java/com/example/rodbailey/keypad/KeypadView.java
@@ -0,0 +1,126 @@
+package com.example.rodbailey.keypad;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.TextView;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static com.example.rodbailey.keypad.KeypadKey.KEY_1;
+import static com.example.rodbailey.keypad.KeypadKey.KEY_2;
+import static com.example.rodbailey.keypad.KeypadKey.KEY_3;
+import static com.example.rodbailey.keypad.KeypadKey.KEY_4;
+import static com.example.rodbailey.keypad.KeypadKey.KEY_5;
+import static com.example.rodbailey.keypad.KeypadKey.KEY_6;
+import static com.example.rodbailey.keypad.KeypadKey.KEY_7;
+import static com.example.rodbailey.keypad.KeypadKey.KEY_8;
+import static com.example.rodbailey.keypad.KeypadKey.KEY_9;
+import static com.example.rodbailey.keypad.KeypadKey.KEY_CLEAR;
+import static com.example.rodbailey.keypad.KeypadKey.KEY_OK;
+
+
+/**
+ * View of the keypad. This is a *passive* view - it does nothing itself, it contains no logic of its own.
+ */
+public class KeypadView extends Fragment implements IKeypadView {
+
+    private static final String TAG = KeypadView.class.getSimpleName();
+    private TextView display;
+    private Map<Button, KeypadKey> keys = new HashMap<Button, KeypadKey>();
+    private KeypadClickListener keypadClickListener = new KeypadClickListener();
+    private final IKeypadPresenter keypadPresenter;
+
+    /**
+     * Fragments must have a public empty constructor
+     */
+    public KeypadView() {
+        keypadPresenter = new KeypadPresenter();
+    }
+
+    /**
+     * Use this factory method to create a new instance of
+     * this fragment using the provided parameters.
+     *
+     * @return A new instance of fragment KeypadView.
+     */
+    public static KeypadView newInstance() {
+        KeypadView fragment = new KeypadView();
+        return fragment;
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                             Bundle savedInstanceState) {
+        View fragmentView = inflater.inflate(R.layout.keypad_view, container, false);
+
+        Log.d(TAG, "Into onCreateView");
+
+        // The output display at the top of the keypad
+        display = (TextView) fragmentView.findViewById(R.id.keypad_display);
+
+        Log.d(TAG, "R.id.keypad_display is bound to widget " + display);
+
+        // Each key in the keypad is in the 'keys' array, so we can identify symbolically which
+        // button is clicked on.
+        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_1), KEY_1);
+        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_2), KEY_2);
+        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_3), KEY_3);
+        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_4), KEY_4);
+        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_5), KEY_5);
+        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_6), KEY_6);
+        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_7), KEY_7);
+        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_8), KEY_8);
+        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_9), KEY_9);
+        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_clear), KEY_CLEAR);
+        keys.put((Button) fragmentView.findViewById(R.id.keypad_button_ok), KEY_OK);
+
+        for (Button button : keys.keySet()) {
+            button.setOnClickListener(keypadClickListener);
+        }
+
+        Log.d(TAG, "Exiting onCreateView");
+
+        return fragmentView;
+    }
+
+    @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+
+    }
+
+    @Override
+    public void onDetach() {
+        super.onDetach();
+    }
+
+    @Override
+    public void setDisplay(String display) {
+        this.display.setText(display);
+    }
+
+    @Override
+    public void clearDisplay() {
+        display.setText("");
+    }
+
+    private class KeypadClickListener implements View.OnClickListener {
+        @Override
+        public void onClick(View view) {
+            KeypadKey keyClicked = keys.get(view);
+            keypadPresenter.keyPressed(keyClicked);
+        }
+    }
+}
diff --git a/app/src/main/java/com/example/rodbailey/keypad/MainActivity.java b/app/src/main/java/com/example/rodbailey/keypad/MainActivity.java
new file mode 100644
index 0000000..41a2c69
--- /dev/null
+++ b/app/src/main/java/com/example/rodbailey/keypad/MainActivity.java
@@ -0,0 +1,13 @@
+package com.example.rodbailey.keypad;
+
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+
+public class MainActivity extends AppCompatActivity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_main);
+    }
+}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..6494076
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    tools:context="com.example.rodbailey.keypad.MainActivity">
+
+    <fragment
+        android:id="@+id/calculator_bob"
+        android:name="com.example.rodbailey.keypad.KeypadView"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerInParent="true"
+        tools:layout="@layout/keypad_view" />
+</RelativeLayout>
diff --git a/app/src/main/res/layout/keypad_view.xml b/app/src/main/res/layout/keypad_view.xml
new file mode 100644
index 0000000..7ec78d1
--- /dev/null
+++ b/app/src/main/res/layout/keypad_view.xml
@@ -0,0 +1,114 @@
+<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:background="#ccc"
+    android:columnCount="4"
+    android:rowCount="4"
+    android:useDefaultMargins="true">
+
+    <!-- ============================ -->
+    <!-- The keypad's LED display -->
+    <!-- ============================ -->
+
+    <TextView
+        android:id="@+id/keypad_display"
+        android:background="#0ef"
+        android:layout_height="80dp"
+        android:layout_gravity="fill_horizontal"
+        android:gravity="right|bottom"
+        android:layout_columnSpan="4"
+        android:textSize="54sp"/>
+
+    <!-- =============== -->
+    <!-- Row 1 of keypad -->
+    <!-- =============== -->
+
+    <!-- The "7" button -->
+
+    <Button
+        android:id="@+id/keypad_button_7"
+        style="@style/keypad_numeric_button"
+        android:text="7" />
+
+    <!-- The "8" button -->
+
+    <Button
+        android:id="@+id/keypad_button_8"
+        style="@style/keypad_numeric_button"
+        android:text="8" />
+
+    <!-- The "9" button -->
+
+    <Button
+        android:id="@+id/keypad_button_9"
+        style="@style/keypad_numeric_button"
+        android:text="9" />
+
+    <!-- The "CLR" button -->
+
+    <Button
+        android:id="@+id/keypad_button_clear"
+        style="@style/keypad_function_button"
+        android:text="CLR" />
+
+    <!-- =============== -->
+    <!-- Row 2 of keypad -->
+    <!-- =============== -->
+
+    <!-- The "4" button -->
+
+    <Button
+        android:id="@+id/keypad_button_4"
+        style="@style/keypad_numeric_button"
+        android:text="4" />
+
+    <!-- The "5" button -->
+
+    <Button
+        android:id="@+id/keypad_button_5"
+        style="@style/keypad_numeric_button"
+        android:text="5" />
+
+    <!-- The "6" button -->
+
+    <Button
+        android:id="@+id/keypad_button_6"
+        style="@style/keypad_numeric_button"
+        android:text="6" />
+
+    <!-- The "OK" button -->
+
+    <Button
+        android:id="@+id/keypad_button_ok"
+        style="@style/keypad_function_button"
+        android:layout_columnSpan="1"
+        android:layout_rowSpan="2"
+        android:text="OK" />
+
+    <!-- =============== -->
+    <!-- Row 3 of keypad -->
+    <!-- =============== -->
+
+    <!-- The "1" button -->
+
+    <Button
+        android:id="@+id/keypad_button_1"
+        style="@style/keypad_numeric_button"
+        android:text="1" />
+
+    <!-- The "2" button -->
+
+    <Button
+        android:id="@+id/keypad_button_2"
+        style="@style/keypad_numeric_button"
+        android:text="2" />
+
+    <!-- The "3" button -->
+
+    <Button
+        android:id="@+id/keypad_button_3"
+        style="@style/keypad_numeric_button"
+        android:text="3" />
+
+
+</GridLayout>
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..cde69bc
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..c133a0c
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..bfa42f0
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..324e72c
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..aee44e1
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml
new file mode 100644
index 0000000..63fc816
--- /dev/null
+++ b/app/src/main/res/values-w820dp/dimens.xml
@@ -0,0 +1,6 @@
+<resources>
+    <!-- Example customization of dimensions originally defined in res/values/dimens.xml
+         (such as screen margins) for screens with more than 820dp of available width. This
+         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
+    <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..3ab3e9c
--- /dev/null
+++ b/app/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <color name="colorPrimary">#3F51B5</color>
+    <color name="colorPrimaryDark">#303F9F</color>
+    <color name="colorAccent">#FF4081</color>
+</resources>
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..02d4637
--- /dev/null
+++ b/app/src/main/res/values/dimens.xml
@@ -0,0 +1,6 @@
+<resources>
+    <!-- Default screen margins, per the Android Design guidelines. -->
+    <dimen name="activity_horizontal_margin">16dp</dimen>
+    <dimen name="activity_vertical_margin">16dp</dimen>
+
+</resources>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..d86fead
--- /dev/null
+++ b/app/src/main/res/values/strings.xml
@@ -0,0 +1,6 @@
+<resources>
+    <string name="app_name">Keypad</string>
+
+    <!-- TODO: Remove or change this placeholder text -->
+    <string name="hello_blank_fragment">Hello blank fragment</string>
+</resources>
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..7959dbd
--- /dev/null
+++ b/app/src/main/res/values/styles.xml
@@ -0,0 +1,32 @@
+<resources>
+
+    <!-- Base application theme. -->
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+        <!-- Customize your theme here. -->
+        <item name="colorPrimary">@color/colorPrimary</item>
+        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+        <item name="colorAccent">@color/colorAccent</item>
+    </style>
+
+    <style name="keypad_numeric_button">
+        <item name="android:background">#ffffff</item>
+        <item name="android:textStyle">normal</item>
+        <item name="android:textSize">20sp</item>
+        <item name="android:layout_width">60dp</item>
+        <item name="android:layout_height">60dp</item>
+        <item name="android:gravity">center</item>
+        <item name="android:clickable">true</item>
+    </style>
+
+    <style name="keypad_function_button">
+        <item name="android:background">#ffffff</item>
+        <item name="android:textSize">16sp</item>
+        <item name="android:textStyle">normal</item>
+        <item name="android:layout_width">60dp</item>
+        <item name="android:layout_gravity">fill_vertical</item>
+        <item name="android:gravity">fill_vertical|center_horizontal</item>
+        <item name="android:textAllCaps">true</item>
+        <item name="android:clickable">true</item>
+    </style>
+
+</resources>
diff --git a/app/src/test/java/com/example/rodbailey/keypad/KeypadModelTest.java b/app/src/test/java/com/example/rodbailey/keypad/KeypadModelTest.java
new file mode 100644
index 0000000..148eb41
--- /dev/null
+++ b/app/src/test/java/com/example/rodbailey/keypad/KeypadModelTest.java
@@ -0,0 +1,51 @@
+package com.example.rodbailey.keypad;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * To work on unit tests, switch the Test Artifact in the Build Variants view.
+ */
+public class KeypadModelTest {
+
+    private KeypadModel model;
+
+    @Before
+    public void createNewModel() {
+        model = new KeypadModel();
+    }
+
+    @Test
+    public void modelIsInitializedWithEmptyString() throws Exception {
+        assertEquals(model.getRegister(), "");
+    }
+
+    @Test
+    public void appendToEmptyModel() throws Exception {
+        model.appendToRegister('5');
+        assertEquals(model.getRegister(), "5");
+    }
+
+    @Test
+    public void appendToNonEmptyModel() throws Exception {
+        model.appendToRegister('1');
+        model.appendToRegister('2');
+        assertEquals(model.getRegister(), "12");
+    }
+
+    @Test
+    public void clearEmptyModel() throws Exception {
+        model.clearRegister();
+        assertEquals(model.getRegister(), "");
+    }
+
+    @Test
+    public void clearNonEmptyModel() throws Exception {
+        model.appendToRegister('1');
+        model.appendToRegister('2');
+        model.clearRegister();
+        assertEquals(model.getRegister(), "");
+    }
+}
\ No newline at end of file
