If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

public static void main(String[] args)
{
Personi sandwichMan = new Personi();
SandwichMachine theMachine = new SandwichMachine();
SandwichMachine.setPrices(120,140);
SandwichMachine.setCreditLimit(wallet);
sandwichMan.makeInitialSandwiches(theMachine);
numberOfSandwichesEaten = sandwichMan.checkForSale(theMachine);
// The prices have been set and the machine has been filled

showContents(sandwichMan, theMachine);

Personi hungryStudent = new Personi();
printThis ("\nA student has just walked up to the machine......");
printThis ("He wants a cheese sandwich and has the correct change (140
pence)");
pauseForAShortMoment();
hungryStudent.buySandwich("cheese", 140, theMachine);
// A new person, hungryStudent has been created and he has purchased a
cheese sandwich (he had the right money)

showContents(sandwichMan, theMachine);

printThis ("\nThe sandwich was nice, but it didn't satisfy the hungry
student......");
printThis ("He wants another cheese sandwich, but, this time only puts
in 135 pence");
pauseForAShortMoment();
hungryStudent.buySandwich("cheese", 135, theMachine);
// The student has just put in too little money for the sandwich, the
error is displayed, and the money returned.

printThis ("\nThat Student must have a serious eating disorder......");
printThis ("He wants another egg sandwich for himself, and puts in a two
pound coin");
pauseForAShortMoment();
hungryStudent.buySandwich("egg", 200, theMachine);
// The student has just put in too much money for the egg sandwich, so
his change is returned.

showContents(sandwichMan, theMachine);

printThis ("\nWho'd believe it, the greedy student is back for another
egg......");
printThis ("He puts in the correct change, but .... there's no egg left
in the machine ....");
pauseForAShortMoment();
hungryStudent.buySandwich("egg", 120, theMachine);

public static void showContents(Personi tempBloke, SandwichMachine
tempMachine)
{
tempBloke.printThis("\nLets check the machine, what is in it at the
moment?....");
tempBloke.printThis(showNumberOfCheese(tempMachine)+ " Cheese Sandwiches
left in the Machine");
tempBloke.printThis(showNumberOfEgg(tempMachine)+ " Egg Sandwiches left
in the Machine");
tempBloke.printThis("Therefore, the total number of sandwiches in the
machine is " + (showNumberOfCheese(tempMachine) +
showNumberOfEgg(tempMachine) + " sandwiches"));
tempBloke.printThis("and .....");
tempBloke.printThis("There is "+ showMoneyLeft(tempMachine) + " Pence
left in the Machine");
numberOfSandwichesEaten = checkForSale(tempMachine);
tempBloke.printThis(numberOfSandwichesEaten + " Sandwiches have been
eaten since it was last filled");
}

Re: displaying System out in an applet

Tom,
Sorry I haven't been able to answer your other question.

If you are running your applet from the command line - it will go to your
command window.

If you are running your applet in IE with the default JVM (Bad thing) go
to View/Java Console and it will show up in the console. You might have
to go to internet options to get it to show up in the menu.

If you are using the Java Plugin, go to Start/Settings/Control Panel/Java
Plugin. On the Basic tab select Show Java Console.