
10.2.1 Inherited Members of a Class
As shown in Example 10.1, our BankAccount class has two instance vari-
ables, the balance, which is a double (line 11), and a constant DecimalFor-
mat object that we will use for formatting the balance as money (lines
9–10). We provide two constructors. The default constructor (lines 13–19)
sets the balance instance variable to 0.0. The overloaded constructor (lines
21–27) takes a starting balance and passes that parameter to the deposit
method (lines 37–47), which adds any non-negative starting balance to the
balance. If the starting balance is less than 0.0, the deposit method prints an
error message and leaves ...