import java.util.*; //Contains Math.random() import javax.swing.*; public class objHorse { private int chosenHorseNum = 0, winningHorseNum = 0, playerMoneyPot = 0, bankMoneyPot = 0; private String winningHorseName = ""; //Constructs the object with the parameters starting amounts public objHorse(int playerMoneyPot, int bankMoneyPot) { //Sets the variables belonging to this class with the values in the variables passed to the constructor this.playerMoneyPot = playerMoneyPot; this.bankMoneyPot = bankMoneyPot; } public void setChosenHorse(JComboBox cboxHorse) //Method for setting the chosen horse { //Finds the currently selected item in the combo box if (cboxHorse.getSelectedItem() == "Lucky") { chosenHorseNum = 1; } else if (cboxHorse.getSelectedItem() == "Big Bob") { chosenHorseNum = 2; } else if (cboxHorse.getSelectedItem() == "Wailing Flames") { chosenHorseNum = 3; } else { chosenHorseNum = 4; } } //End method setChosenHorse() public void calcWinningHorse() //Method for setting the winning horse { winningHorseNum = 1 + (int) (Math.random() * 4); //Random number between 1 and 4 switch(winningHorseNum) //Test the possible horse numbers { case 1: winningHorseName = "Lucky"; break; case 2: winningHorseName = "Big Bob"; break; case 3: winningHorseName = "Wailing Flames"; break; default: winningHorseName = "Summer"; break; } } //End method calcWinningHorse() public void calcRacingResults(int betAmount) //Method for checking if you chose the winning horse { if (chosenHorseNum == winningHorseNum) //If they match { playerMoneyPot += betAmount; //Add the bet amount to the player's pot bankMoneyPot -= betAmount; //Take away the bet amount from the bank's pot } else { playerMoneyPot -= betAmount; bankMoneyPot += betAmount; } } //End method calcRacingResults() public int getPlayerMoneyPot() //Method for getting the amount in the player's pot { return playerMoneyPot; } public int getBankMoneyPot() //Method for getting the amount in the bank's pot { return bankMoneyPot; } public String getWinningHorseName() //Method for getting the name of the horse that won { return winningHorseName; } }