Ζάρια

import gr.aueb.dds.BIO;

/*
 * Dice thrower
 * Demonstrates random number, functions, character graphics
 */
class Dice {

        /*
         * Calculate a random dice throw and display it as follows:
         * 1-3:
         *        #            #
         *   #                 #
         *             #       #
         * 4-6:
         * #   #   #   #     #    #
         *           #       #    #
         * #   #   #   #     #    #
         */
        static void dice() {
                int n = (int)(Math.random() * 6) + 1;

                BIO.println("[" + n + "]");
                BIO.println();
                // Top row
                // Left
                if (n == 2 || n >= 4) BIO.print("* "); else BIO.print("  ");
                // Middle
                if (n == 3) BIO.print("* "); else BIO.print("  ");
                // Right
                if (n >= 4) BIO.println("* "); else BIO.println("  ");

                // Middle row
                // Left
                if (n == 6) BIO.print("* "); else BIO.print("  ");
                // Middle
                if (n % 2 == 1) BIO.print("* "); else BIO.print("  ");
                // Right
                if (n == 6) BIO.println("* "); else BIO.println("  ");

                // Bottom row
                // Left
                if (n >= 4) BIO.print("* "); else BIO.print("  ");
                // Middle
                if (n == 3) BIO.print("* "); else BIO.print("  ");
                // Right
                if (n == 2 || n >= 4) BIO.println("* "); else BIO.println("  ");
                BIO.println();
        }

        /*
         * Clear the screen by displaying 25 empty lines
         */
        static void clearScreen() {
                int i;

                i = 0;
                while (i < 25) {
                        BIO.println();
                        i++;
                }
        }

        public static void main(String args[]) {
                int code;

                while ((code = BIO.readChar()) != -1) {
                        clearScreen();
                        dice();
                        BIO.println();
                        BIO.println();
                        BIO.println();
                        dice();
                        BIO.println();
                }
        }
}