Scaffolding

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page

Answer:

100
585

(Remember to subtract the 15 cent service charge.)

Scaffolding

If this class were to be used in an actual bank, it would need a great deal more testing. Usually testing involves placing statements that write out information to the terminal as the program is being run. Thoughtful placement of these statements can greatly ease software development. These statements (and other statements intended to be used for testing and program development) are sometimes called scaffolding. They are put in place as the program is being written and tested, and are removed when testing is finished. This is similar to the scaffolding used when a building is being constructed. Well-placed scaffolding greatly aids the carpenters, roofers, painters and other trades that work on the building. Programmers should do the same for themselves.

class CheckingAccount
{
  // instance variables
  String accountNumber;
  String accountHolder;
  int    balance;

  //constructors
  . . . .

  // methods
  . . . .

  void display()
  {
    System.out.println(  );
  }
}

The statements that write out the state of a CheckingAccount object are somewhat awkward:

System.out.println( account1.accountNumber + " " +
    account1.accountHolder + " " + account1.getBalance() );

It would aid in testing if a CheckingAccount itself could be asked to do this. This is a display method which can be added to the class, as seen above.

QUESTION 18:

Write a complete display() method.