mirror of
https://github.com/gwenhael-le-moine/c-urs_-toil-s.git
synced 2024-11-16 19:48:26 +01:00
beautify debugDisplay
This commit is contained in:
parent
4e433bbbdc
commit
e1c92e4475
1 changed files with 13 additions and 3 deletions
|
@ -1,5 +1,8 @@
|
|||
package com.cycojesus;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Star {
|
||||
private int HEIGHT = 9;
|
||||
private int WIDTH = 16;
|
||||
|
@ -60,7 +63,7 @@ public class Star {
|
|||
}
|
||||
|
||||
// METHODS
|
||||
private int countGifts( ) {
|
||||
private int countGifts( ) { // FIXME: naïve approach, improvable
|
||||
int giftsCounter = 0;
|
||||
for ( int i = 0 ; i < HEIGHT * WIDTH ; i++ ) {
|
||||
if ( this.level.charAt( i ) == 'x' ) {
|
||||
|
@ -146,6 +149,13 @@ public class Star {
|
|||
|
||||
// DEBUG FACILITIES
|
||||
public void debugDisplay( ) {
|
||||
Map<Character, String> symbols = new HashMap<Character, String>();
|
||||
symbols.put( BALL, "()" );
|
||||
symbols.put( CUBE, "[]" );
|
||||
symbols.put( GIFT, "<>" );
|
||||
symbols.put( VOID, " " );
|
||||
symbols.put( WALL, "##" );
|
||||
|
||||
int[] positionBall = getPosition( BALL );
|
||||
int[] positionCube = getPosition( CUBE );
|
||||
System.out.println ( BALL + "("+positionBall[0]+";"+positionBall[1]+")" );
|
||||
|
@ -155,7 +165,7 @@ public class Star {
|
|||
System.out.println ( ( areWeDoneYet() ) ? "YOU WON" : "not won yet." );
|
||||
for ( int i = 0 ; i < HEIGHT ; i++ ) {
|
||||
for ( int j = 0 ; j < WIDTH ; j++ ) {
|
||||
System.out.print( this.level.charAt( ( i * WIDTH ) + j ) );
|
||||
System.out.print( symbols.get( this.level.charAt( ( i * WIDTH ) + j ) ) );
|
||||
}
|
||||
System.out.println( "" );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue