Android Open Source - droidgol Game Printer






From Project

Back to project page droidgol.

License

The source code is released under:

MIT License

If you think the Android project droidgol listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.rubyspa.droidgol;
// w w  w  .  ja v  a2s .com
import android.util.Pair;

public class GamePrinter {
    public static String print(final Game game) {
        StringBuilder gamePrintout = new StringBuilder();
        Pair<Integer,Integer> dimensions = game.dimensions();
        for (int y = 1; y <= dimensions.second; y++) {
            for (int x = 1; x <= dimensions.first; x++) {
                if (game.stateAt(Pair.create(x, y)) == Boolean.TRUE)
                    gamePrintout.append('o');
                else
                    gamePrintout.append(' ');
            }
            if (y < dimensions.second) gamePrintout.append('\n');
        }
        return gamePrintout.toString();
    }
}




Java Source Code List

org.rubyspa.droidgol.GameActivity.java
org.rubyspa.droidgol.GamePrinter.java
org.rubyspa.droidgol.Game.java
org.rubyspa.droidgol.Rules.java