/** * TestProgram is used as the test driver for Program 1 in CS 160. * Do not make any changes to this program. * * @author John Paxton * @version September 18, 2008 */ public class TestProgram { public static void main (String [] args) { GringottsAccount harrysAccount; // Harry Potter's Gringott's Account GringottsAccount hermionesAccount; // Hermione Granger's Account GringottsAccount ronsAccount; // Ron Weasley's Account // Create an account owned by Harry Potter that has // 555 Galleons, 444 Sickles and 333 Knuts. harrysAccount = new GringottsAccount("Harry Potter", 555, 444, 333); // Print information regarding Harry's account. harrysAccount.printAccount(); // Convert Harry's entire account to Knuts. There // are 17 Sickles in a Galleon and 29 Knuts in a Sickle. harrysAccount.convertToKnuts(); harrysAccount.printAccount(); // Convert Harry's account back so that it uses as many Galleons // as possible. The remaining money should use as many Sickles // as possible. harrysAccount.convertToGalleons(); harrysAccount.printAccount(); // Create an account owned by Hermione Granger. The number // of initial galleons, sickles and knuts should all be 0. hermionesAccount = new GringottsAccount("Hermione Granger"); hermionesAccount.printAccount(); // Change the number of Galleons that Hermione has to 150. hermionesAccount.setGalleons(150); // Change the number of Sickles that Hermione has to 100. hermionesAccount.setSickles(100); // Change the number of Knuts that Hermione has to 200. hermionesAccount.setKnuts(200); hermionesAccount.printAccount(); // Make a deposit of 1 Galleon, 2 Sickles and 3 Knuts into // Hermione's account. hermionesAccount.makeDeposit(1, 2, 3); hermionesAccount.printAccount(); ronsAccount = new GringottsAccount("Ron Weasley"); // This will give Ron a negative account balance. That is OK. ronsAccount.makeDeposit(-1, 0, 0); ronsAccount.printAccount(); ronsAccount.convertToKnuts(); ronsAccount.printAccount(); ronsAccount.convertToGalleons(); ronsAccount.printAccount(); } }