Here I am trying to have my 'cash' variable from the Player method be included in an equation in my wagerBet() method. Currently Eclipse is telling me that variable 'cash' cannot 'make a static reference to the non-static field cash'. I tried looking for explanations as to what this problem means but I'm just getting explanations that use even more programming terminology I don't understand being that I'm a rookie at this stuff.
class Player {
private ArrayList<Card>hand;
private double cash, bet;
public Player(double theCash)
{
cash = theCash; //'cash' variable here
hand = new ArrayList<Card>();
}
public static double wagerBet()
{
Scanner in = new Scanner(System.in);
System.out.print("Wager a bet: ");
double bet = in.nextDouble();
cash = cash - bet; // needs to be transferred here
System.out.println("You wagered " + bet + ". " + "Now you have " + cash + " cash left.");
return bet;
}
public void rewardBet(double bet)
{
cash = cash + (bet * 2); //cash and bet variable needs to be transferred here as well
System.out.println("You now have " + cash + "cash.");
}
Any suggestions?