Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unit 1 assessment #10

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/main/java/nyc/c4q/InitialActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

public class InitialActivity extends Activity {

Button buttonPlus;
Button buttonMinus;
TextView tvCounter;


public int counter = 0;
public SharedPreferences preferences = null;
public final static String TAG = "C4QTAG";
Expand All @@ -34,5 +39,29 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_initial);
preferences = getPreferences(Context.MODE_PRIVATE);

tvCounter = (TextView) findViewById(R.id.tvCounter);

buttonPlus = (Button)findViewById(R.id.buttonPlus);
buttonPlus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
counter++;
String number = String.valueOf(counter);
tvCounter.setText(number);
}
});
buttonMinus = (Button)findViewById(R.id.buttonMinus);
buttonMinus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
counter--;
String number = String.valueOf(counter);
tvCounter.setText(number);
}
});
}

}


8 changes: 7 additions & 1 deletion src/main/java/nyc/c4q/SubFunClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
/**
* Created by amyquispe on 5/19/15.
*/
public class SubFunClass {
public class SubFunClass extends SuperFunClass {
public SubFunClass(){
SubFunClass funObject = new SubFunClass();
}
}

// @Test
// public void test01SubFunClassInheritsFromSuperFunClass() throws Exception {
// SubFunClass funObject = new SubFunClass();
// assertThat(funObject, instanceOf(SuperFunClass.class));
59 changes: 53 additions & 6 deletions src/main/res/layout/activity_initial.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,63 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="nyc.c4q.InitialActivity"
android:id="@+id/activity_initial">

<TextView
android:id="@+id/text"
<LinearLayout
android:orientation="horizontal"
android:id="@+id/counterLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="InitialActivity"
android:layout_height="0dp"
android:layout_weight="2"
>

<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="@+id/counterButtonsLayout"
android:layout_weight="1">
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/buttonPlus"
android:text="+"
android:layout_weight="1"/>
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/buttonMinus"
android:text="-"
android:layout_weight="1"/>
</LinearLayout>

<TextView
android:id="@+id/tvCounter"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="0"
android:layout_weight="1"/>



</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="@+id/buttonTileActivity"
android:text="TileActivity"
android:layout_weight="1"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="@+id/buttonEmpty"
android:text="Empty"
android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>

2 changes: 1 addition & 1 deletion src/test/java/nyc/c4q/Unit1AssessmentTestsAndroid.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void test02ButtonPlusShouldIncreaseTvCounter() throws Exception {
Button buttonPlus = (Button) Helpers.findViewByIdString(activity, "buttonPlus");
TextView tvCounter = (TextView) Helpers.findViewByIdString(activity, "tvCounter");

assertNotNull("TextView(@+id/buttonPlus) should not be null", buttonPlus);
assertNotNull("Button(@+id/buttonPlus) should not be null", buttonPlus);
assertNotNull("TextView(@+id/tvCounter) should not be null", tvCounter);

assertEquals(0, Integer.parseInt((String) tvCounter.getText()));
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/nyc/c4q/Unit1AssessmentTestsJava.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

Expand Down Expand Up @@ -42,9 +43,9 @@ public void test03AbstractAwesomeClassImplementsAwesomeInterface() throws Except
@Test
public void test04AwesomeContainerContainsAwesomeObject() throws Exception{
Collection myList = AwesomeContainer.createAwesomeContainer();
assertEquals(myList.getClass(), List.class);
assertEquals(myList.getClass(), ArrayList.class);
AwesomeContainer.addAwesomeObject(myList);
assertEquals(((List) myList).get(0).getClass(), AwesomeInterface.class);
assertEquals(((ArrayList) myList).get(0).getClass(), ConcreteAwesomeClass.class);
}

}