Program 2: GringottsAccount

PurposeA common task is to write software that integrates with previously written code. In this assignment, you are given a Driver program and must add a GringottsAccount class to make the Driver program work. This assignment will also help you gain experience with mathematical equations.
Getting Started
  • Create a BlueJ project named Program2.
  • Add a class named Driver and then copy this code into it.
  • Create a class named GringottsAccount. You will need to develop this class from scratch such that it integrates properly with the Driver class.
GringottsAccount Methods
  • The constructor method header should be public GringottsAccount(String inOwner, int inGalleons, int inSickles, int inKnuts). You may assume that an account will not be initialized with more than one million (1000000) Galleons, one million Sickles and one million Knuts.
  • The reader method public int getGalleons() should return the number of Galleons in the account.
  • The reader method public int getSickles() should return the number of Sickles in the account.
  • The reader method public int getKnuts() should return the number of Knuts in the account.
  • The reader method public String getOwner() should return the name of the owner of the account.
  • The method public void convertToGalleons should convert the money in the account to the maximum number of Galleons. As a reminder, there are 17 Sickles in a Galleon and 29 Knuts in a Sickle.
  • The method public void convertToSickles() should convert the money in the account to the maximum number of Sickles.
  • The method public void convertToKnuts() should convert the money in the account to the maximum number of Knuts.
Sample OutputWhen the above program is run after you have supplied the missing GringottsAccount, this output should be produced for Ron Weasley. The first chunk of information shows the original account information. The second chunk shows what Ron's account looks like after it is converted to the maximum number of Galleons. The third chunk shows what Ron's account looks like after it is converted to the maximum number of Knuts. The fourth chunk shows what Ron's account looks like after it is converted to the maximum number of Sickles.Grading - 100 points
  • 10 points - the GringottsAccount instance variables galleonssickles and knuts are all of type int. The GringottsAccount instance variable owner is of type String.
  • 10 points - the GringottsAccount constructor is correct.
  • 5 points - the reader methods getOwnergetGalleonsgetSickles and getKnuts are correct
  • 20 points - the method convertToGalleons is correct (5 points will be lost for each failed test case)
  • 20 points - the method convertToSickles is correct (5 points will be lost for each failed test case)
  • 15 points - the method convertToKnuts is correct (5 points will be lost for each failed test case)
  • 10 points - the GringottsAccount class is commented appropriately
  • 10 points - Good programming and object-oriented programming principles are used throughout the GringottsAccount class
Powered by