AccountTest Class to Use Class Account
Class AccountTest
(Fig. B.10) creates two Account
objects (lines 10–11) and initializes them with 50.00
and -7.53
, respectively. Lines 14–17 output the balance in each Account
by calling the Account
’s getBalance
method. When method getBalance
is called for account1
from line 15, the value of account1
’s balance is returned from line 27 of Fig. B.9 and displayed by the System.out.printf
statement (Fig. B.10, lines 14–15). Similarly, when method getBalance
is called for account2
from line 17, the value of the account2
’s balance is returned from line 27 of Fig. B.9 and displayed by the System.out.printf
statement (Fig. B.10, lines 16–17). The balance of account2
is 0.00
, because the constructor ensured that ...
Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.