File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -18,4 +18,19 @@ public boolean isFieldEmpty(int x, int y){
1818 return this .meadow [x ][y ] == null ;
1919 }
2020
21+
22+ public void printBoard (){
23+ for (int iX = 0 ; iX < xSize ; iX ++){
24+ for (int iY = 0 ; iY < ySize ; iY ++){
25+
26+ if (this .isFieldEmpty (iX , iY )){
27+ System .out .print (this .meadowEmoji );
28+ } else {
29+ // not implemented yet
30+ }
31+
32+ }
33+ System .out .println ("" );
34+ }
35+ }
2136}
Original file line number Diff line number Diff line change 1+ import org .junit .After ;
12import org .junit .Test ;
23import org .junit .Before ;
4+
5+ import java .io .ByteArrayOutputStream ;
6+ import java .io .PrintStream ;
7+
38import static org .junit .Assert .*;
49
510public class TestMeadowBord {
611
712 MeadowBoard board ;
13+ ByteArrayOutputStream outContent ;
14+ PrintStream originalOut ;
815
916 @ Before
1017 public void setup (){
1118 this .board = new MeadowBoard (10 , 12 );
19+ this .outContent = new ByteArrayOutputStream ();
20+ this .originalOut = System .out ;
21+ System .setOut (new PrintStream (this .outContent ));
22+ }
23+
24+ @ After
25+ public void teardown (){
26+ System .setOut (this .originalOut );
1227 }
1328
1429 @ Test
@@ -23,4 +38,13 @@ public void testIsEmptyWhenEmpty(){
2338 assertTrue (this .board .isFieldEmpty (0 , 0 ));
2439 }
2540
41+ @ Test
42+ public void testPrintBoardLineEmpty (){
43+ this .board .printBoard ();
44+ assertTrue (this .outContent
45+ .toString ()
46+ .contains ("\uD83D \uDFE9 \uD83D \uDFE9 \uD83D \uDFE9 \uD83D \uDFE9 \uD83D \uDFE9 \uD83D \uDFE9 \uD83D " +
47+ "\uDFE9 \uD83D \uDFE9 \uD83D \uDFE9 \uD83D \uDFE9 \uD83D \uDFE9 \uD83D \uDFE9 " ));
48+ }
49+
2650}
You can’t perform that action at this time.
0 commit comments