Seu SlideShare está sendo baixado. ×

Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio

1 de 2 Anúncio

# dominos game program- and determine each data after each domino is pla.docx

dominos game program. and determine each data after each domino is played.1) the total amount of dots.2) the running total of all the dots played.3) if the running total is divisible by 5 without any remainder. and make it idiot proof please. Thanks
Solution
program :
public class domino
{
public static void main(String args[])
{
ArrayList<int []> tiles = new ArrayList<int []>();
Random gen = new Random();
for(int i=0;i<7;i++)
{
for(int j=0;j<7;j++)
{
System.out.print(\"(\"+ i + \", \" + j + \") \");
}
System.out.println();
}
int [][] player1_tiles = new int[7][49];
int [][] player2_tiles = new int[7][49];
int [] tile1 = null;
int [] tile2 = null;
for(int i=0;i<player1_tiles.length;i++)
{
tile1 = tiles.get(gen.nextInt(tiles.size()));
tile2 = tiles.get(gen.nextInt(tiles.size()));
tiles.remove(tile1);
tiles.remove(tile2);
player1_tiles[i] = tile1;
player2_tiles[i] = tile2;
}
System.out.println(\"\ Tile\\tPlayer 1\\tPlayer 2\");
for(int i=0;i<player1_tiles.length;i++)
{
System.out.print((i+1) +\": \\t \");
for(int j=0;j<player1_tiles[i].length;j++)
{
System.out.print(player1_tiles[i][j] + \" \");
}
System.out.print(\"\\t\\t\");
for(int j=0;j<player2_tiles[i].length;j++)
{
System.out.print(player2_tiles[i][j] + \" \");
}
System.out.println();
}
System.out.println();
if(tile1[0]>tile2[1] && tile1[1]>tile2[1])
{
System.out.println(\"player 1 drops first\");
}
else{
System.out.println(\"player 2 drops first\");
}
}
}
.

dominos game program. and determine each data after each domino is played.1) the total amount of dots.2) the running total of all the dots played.3) if the running total is divisible by 5 without any remainder. and make it idiot proof please. Thanks
Solution
program :
public class domino
{
public static void main(String args[])
{
ArrayList<int []> tiles = new ArrayList<int []>();
Random gen = new Random();
for(int i=0;i<7;i++)
{
for(int j=0;j<7;j++)
{
System.out.print(\"(\"+ i + \", \" + j + \") \");
}
System.out.println();
}
int [][] player1_tiles = new int[7][49];
int [][] player2_tiles = new int[7][49];
int [] tile1 = null;
int [] tile2 = null;
for(int i=0;i<player1_tiles.length;i++)
{
tile1 = tiles.get(gen.nextInt(tiles.size()));
tile2 = tiles.get(gen.nextInt(tiles.size()));
tiles.remove(tile1);
tiles.remove(tile2);
player1_tiles[i] = tile1;
player2_tiles[i] = tile2;
}
System.out.println(\"\ Tile\\tPlayer 1\\tPlayer 2\");
for(int i=0;i<player1_tiles.length;i++)
{
System.out.print((i+1) +\": \\t \");
for(int j=0;j<player1_tiles[i].length;j++)
{
System.out.print(player1_tiles[i][j] + \" \");
}
System.out.print(\"\\t\\t\");
for(int j=0;j<player2_tiles[i].length;j++)
{
System.out.print(player2_tiles[i][j] + \" \");
}
System.out.println();
}
System.out.println();
if(tile1[0]>tile2[1] && tile1[1]>tile2[1])
{
System.out.println(\"player 1 drops first\");
}
else{
System.out.println(\"player 2 drops first\");
}
}
}
.

Anúncio
Anúncio