/** This class models a standard 6-sided die. */ public class Die { // fields protected int sideUp; /** Constructor */ public Die() { this.sideUp = 1; } /** roll the die */ public void roll() { this.sideUp = (int) (Math.random() * 6) + 1; } /** return the side that is up * @return the side that is up */ public int getSideUp() { return this.sideUp; } @Override public String toString() { return Integer.toString( this.sideUp ); } // public static void main( String[] args ) { // int num_dice; // if (args.length < 1) { // System.out.println( "USAGE: java Die " ); // System.out.println( " default # of dice is 3" ); // num_dice = 3; // } // else { // num_dice = Integer.parseInt(args[0]); // } // Die[] dice; // dice = new Die[num_dice]; // for (int i = 0; i < num_dice; i++) { // dice[i] = new Integer(4); // dice[i].roll(); // } // for (int i = 0; i < num_dice; i++) { // System.out.print( dice[i].getSideUp() + " " ); // } // System.out.println(); // // } // end // public static void main( String[] args ) { // if (args.length < 2) { // System.out.println( "Usage: java Die " ); // return; // } // int height, width; // height = Integer.parseInt(args[0]); // width = Integer.parseInt(args[1]); // Die[][] dice; // dice = new Die[height][width]; // for (int i = 0; i < height; i++) { // for (int j = 0; j < width; j++ ) { // dice[i][j] = new Die(); // dice[i][j].roll(); // } // } // for (int i = 0; i < height; i++) { // for (int j = 0; j < width; j++ ) { // System.out.print( dice[i][j].getSideUp() + " " ); // } // System.out.println(); // } // // } public static void main( String[] args ) { int[][] funky; funky = new int[3][]; funky[0] = new int[3]; funky[1] = new int[2]; funky[2] = new int[4]; funky[0][0] = 1; funky[0][1] = 2; funky[0][2] = 3; funky[1][0] = 4; funky[1][1] = 5; funky[2][0] = 6; funky[2][1] = 7; funky[2][2] = 8; funky[2][3] = 9; } } // end class