Mystery Man's Montage

Home
Free PhotoShop CS3 Beta
Blank page
Turing Colours
Turing code
Animations
Links
Blank page

Enter subhead content here

/*This Program is a game that will let you pick from a menue, horses for a horse race
*/
class tester
{
 static int currentPlayer = 1;
 
 static int player1Horse1;
 static int player1Horse2;
 static int player2Horse1;
 static int player2Horse2;
 static int player3Horse1;
 static int player3Horse2;
 static int player4Horse1;
 static int player4Horse2;
 static int player5Horse1;
 static int player5Horse2;
 static int player6Horse1;
 static int player6Horse2;
 
 static int horse1Position;
 static int horse2Position;
 static int horse3Position;
 static int horse4Position;
 static int horse5Position;
 static int horse6Position;
 
 static int die1;
 static int die2;
 static int die3;
 static int die4;
 static int die5;
 static int numPlayer;
 
 public static void main(String[]args)
 {
  numPlayer = howManyPlayers();
  pickHorses();
  do
  {
   rollDice();
   score(player1Horse1);
   score(player1Horse2);
   score(player2Horse1);
   score(player2Horse2);
   score(player3Horse1);
   score(player3Horse2);
   score(player4Horse1);
   score(player4Horse2);
   score(player5Horse1);
   score(player5Horse2);
   score(player6Horse1);
   score(player6Horse2);
   showSocre(horse1Position);
   showSocre(horse2Position);
   showSocre(horse3Position);
   showSocre(horse4Position);
   showSocre(horse5Position);
   showSocre(horse6Position);
   
  }
  while(horse1Position <= 100 && horse2Position <= 100 && horse3Position <= 100 && horse4Position <= 100 && horse5Position <= 100 && horse6Position <= 100);
  
 }
 public static int howManyPlayers()
 {
  System.out.print("How many players are there(6 max): ");
  int numPlayer = In.readInt();
  if(numPlayer < 6 && numPlayer > 0)
   return numPlayer;
  else
   return 6;
 }
 
 public static void changePlayer()
 {
  if(currentPlayer < numPlayer)
  {
   currentPlayer++;
  }
  else
  {
   currentPlayer = 1;
  }
 }
 
 public static void pickHorses()
 {
  boolean done = false;
  do
  {
   System.out.println("1.  LuckyShuus");
   System.out.println("2.  SamySham");
   System.out.println("3.  JustAhead");
   System.out.println("4.  Ketchup");
   System.out.println("5.  StinkyWindmill");
   System.out.println("6.  RandomO'Connor");
   System.out.println("Player " + currentPlayer + " pick 2 horses (1-6)");
   
   if(currentPlayer == 1)
   {
    player1Horse1 = In.readInt();
    player1Horse2 = In.readInt();
   }
   else if(currentPlayer == 2)
   {
    player2Horse1 = In.readInt();
    player2Horse2 = In.readInt();
   }
   else if(currentPlayer == 3)
   {
    player3Horse1 = In.readInt();
    player3Horse2 = In.readInt();
   }
   else if(currentPlayer == 4)
   {
    player4Horse1 = In.readInt();
    player4Horse2 = In.readInt();
   }
   else if(currentPlayer == 5)
   {
    player5Horse1 = In.readInt();
    player5Horse2 = In.readInt();
   }
   else if(currentPlayer == 6)
   {
    player6Horse1 = In.readInt();
    player6Horse2 = In.readInt();
    done = true;
    }
   changePlayer();
  }
  while(!done);
  currentPlayer = 1;
  
 }
 
 public static void rollDice()
 {
  System.out.println(die1 = Dice.roll());
  System.out.println(die2 = Dice.roll());
  System.out.println(die3 = Dice.roll());
  System.out.println(die4 = Dice.roll());
  System.out.println(die5 = Dice.roll());
 }
 public static void score(int horse)
 {
  if(die1 = horse)
  {
   checkHorseScore(horse);
  }
  if(die2 = horse)
  {
   checkHorseScore(horse);
  }
  if(die3 = horse)
  {
   checkHorseScore(horse);
  }
  if(die4 = horse)
  {
   checkHorseScore(horse);
  }
  if(die5 = horse)
  {
   checkHorseScore(horse);
  }
    
 }
 
 public static void checkHorseScore(int horse)
 {
  if(horse = 1)
   horse1Position++;
  else if(horse = 2)
   horse2Position++;
  else if(horse = 3)
   horse3Position++;
  else if(horse = 4)
   horse4Position++;
  else if(horse = 5)
   horse5Position++;
  else
   horse6Position++;
 }
 
 public static void showSocre(int horsePosition)
 {
  for(int i = 0; i < 101; i++)
  {
   if(i == horsePosition)
   {
    system.out.print("-");
   }
   else
   {
    system.out.print("*");
   }
  }
  system.out.println();
 }
}

Enter supporting content here