So I've looked for answers to how to pass values from one method to another in a class. The problem is that they all suggest a major re-write and I am new to Java and was advised not to use some of the suggestions. Anyone know a quick way?
Trying to pass the value of bet around so that it can get to potAmount() for the calculation.
Code:
import java.util.Scanner;
public class BlackJack {
Scanner scan = new Scanner (System.in);
int potG = 100;
int potT;
int bet;
public void betAmount() {
System.out.println("Enter your bet amount: ");
bet = scan.nextInt();
if (bet > potG)
betAmount();
if (bet == 0)
endGame();
}
public void potAmount() {
potT = potG + bet;
System.out.println("Your current pot is " + potT);
betAmount();
}
public void triplePot() {
System.out.println("You win TRIPLE your bet");
bet = bet * 3;
potAmount();
}
public void win() {
System.out.println("You win double your bet.");
bet = bet * 2;
potAmount();
}
public void lose() {
System.out.println("You lose your bet.");
bet = bet * -1;
potAmount();
}
public void endGame() {
System.out.println("You end the game with a pot of " + potG);
}
}
Thank you for any help or suggestions.