-
Notifications
You must be signed in to change notification settings - Fork 67
Pull request for final part of project #30
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| *.class | ||
| .idea/ | ||
| .project | ||
| JavaLife.iml | ||
| out/ | ||
|
|
||
| # Mobile Tools for Java (J2ME) | ||
| .mtj.tmp/ | ||
|
|
||
| # Package Files # | ||
| *.jar | ||
| *.war | ||
| *.ear | ||
|
|
||
| # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
| hs_err_pid* |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,7 +115,7 @@ public World iterate() { | |
| */ | ||
|
|
||
| public String toString() { | ||
| String toReturn = " "; | ||
| /*String toReturn = " "; | ||
| for (int j= 0; j < _size; j++) { | ||
| toReturn += String.valueOf(j % 10); | ||
| } | ||
|
|
@@ -127,7 +127,22 @@ public String toString() { | |
| } | ||
| toReturn += "\n"; | ||
| } | ||
| return toReturn; | ||
| return toReturn;// this code is bad, and you should feel bad */ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made deliberately inefficient, so I don't feel too bad. I think I did a good job of making it poorly written! |
||
|
|
||
| StringBuilder sb = new StringBuilder(" "); | ||
| for(int j=0; j<_size; j++){ | ||
| sb.append(j % 10); | ||
| } | ||
| sb.append("\n"); | ||
| for(int j=0; j<_size; j++){ | ||
| sb.append(j%10).append(" "); | ||
| for(int k=0; k<_size; k++){ | ||
| sb.append(_world[j][k].getStateRep()); | ||
| } | ||
| sb.append("\n"); | ||
| } | ||
| return sb.toString(); | ||
|
|
||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /** | ||
| * Created by steven on 3/31/15. | ||
| */ | ||
|
|
||
| package com.laboon; | ||
|
|
||
| import static org.junit.Assert.*; | ||
| import static org.mockito.Mockito.*; | ||
|
|
||
|
|
||
| public class WorldTest { | ||
|
|
||
| @Test | ||
| public void testZero(){ | ||
| World testWorld = new World(0,25,25); | ||
| String out = testWorld.toString(); | ||
| assertEquals(" \n", out); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSeed(){ | ||
| World testWorld = new World(2,25,25); | ||
| String out = testWorld.toString(); | ||
| String expected = " 01\n0 ..\n1 .."; | ||
| assertEquals(expected, out); | ||
| } | ||
|
|
||
| @Test | ||
| public void testDead(){ | ||
| World testWorld = new World(2, 25, 0); | ||
| String out = testWorld.toString(); | ||
| String expected = " 01\n0 ..\n1 .."; | ||
| assertEquals(expected, out); | ||
| } | ||
|
|
||
| @Test | ||
| public void testAlive(){ | ||
| World testWorld = new World(2,25,100); | ||
| String out = testWorld.toString(); | ||
| String expected = "01\n0 XX\n1 XX" | ||
| assertEquals(expected, out); | ||
| } | ||
|
|
||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could check some larger sizes, more edge cases, more complex worlds, etc. But overall pretty good. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
????