Thank you Norm for your help I finally figured it out I just had to take the public off of the total class and add it to the coin class java document. I've cleaned it up some and posting it below. Thank you for your patience with all the noob questions. Lot of reading, testing and googling. If you see anything I can clean up please message me I gonna close this up as solved.
//************************************************************************************
// Main.java Author: Robert Gonzalez
//
// 3 coin game where money won from heads side up flip coin value is added to winnings
//************************************************************************************
public class Main {
public static void main(String[] args)
{
Coin nickel = new Coin(); // creates nickel coin instance
Coin dime = new Coin(); // creates dime coin instance
Coin quarter = new Coin(); // creates quarter coin instance
Total balance = new Total(); // creates balance total instance that will hold winnings.
/*
/Prints out the name and rules of the game.
*/
System.out.println("3 coin toss game");
System.out.println("Flip all 3 coins Heads you win coin value");
System.out.println("Tails you win nothing.");
System.out.println("Flip until you reach or go over a dollar");
System.out.println("Get exactly one dollar and win!");
System.out.println("\n");
int totalWon = 0; // starts the game initializes the balance to 0.
do
{
//The nickel coin is tossed
nickel.toss();
//Gets the face side up value and prints to screen.
System.out.print("Nickel toss shows: " + nickel.getSideUp() + "\n");
//Sets amount of coin and if toss is won banks value into the balance.
balance.sum(nickel.getResults(5));
//The dime coin is tossed.
dime.toss();
//Gets the face side up value and prints to screen.
System.out.print("Dime toss shows: " + dime.getSideUp() + "\n");
//Sets amount of coin and if toss is won banks value into the balance.
balance.sum(dime.getResults(10));
//The quarter coin is tossed.
quarter.toss();
//Gets the face side up value and prints to screen.
System.out.print("Quarter toss shows: " + quarter.getSideUp() + "\n");
//Sets amount of coin and if toss is won banks value into the balance.
balance.sum(quarter.getResults(25));
//Returns total balance won.
totalWon = balance.sum(0);
System.out.println("You've won a total of " + totalWon + " cents.\n");
}while (totalWon < 100); //Continues games until balance has reached over 1 dollar.
if (totalWon == 100)
{
//Prints out winning statement to screen.
System.out.println("Your total was exactly 1 dollar.");
System.out.println("You Win!!!");
}
else
{
//Prints out losing statement to screen.
System.out.println("Your total was over 1 dollar.");
System.out.println("Sorry You Lose .");
}
}
}
import java.util.Random;
public class Coin {
//fields//
private int face;
String sideUp;
int balance;
//constructor//
public Coin(){
}
/* METHODS
/
/Toss will simulate toss of coin
*/
public void toss()
{
face = (int) (Math.random() * 2) + 1;
}
/*
/getSideUP will set value of face side of coin
*/
public String getSideUp()
{
if (face == 1)
{
sideUp = "Heads";
balance = 1;
}
else
{
sideUp = "Tails";
balance = 0;
}
return sideUp;
}
/* getResults sends back amount won from coin toss. */
public int getResults(int won)
{
int winnings;
winnings = balance * won;
return winnings;
}
}
/* The Total class creates an account that banks amounts from the winning tosses and returns that amount. */
class Total
{
int balance2 = 0;
public int sum(int money)
{
balance2 += money;
return balance2;
}
}