|
Computer Science (CSCI)
Department |
|||
|
|||
More on Methods
(Example code and figures from Computing Concepts with Java Essentials,
3rd edition, by Cay Horstmann.
Visit www.wiley.com/college/horstmann
for information on the current edition of this excellent text.)
public void transfer(double amount, BankAccount other) |
public void deposit(double amount) |
Example:
void transfer(double amount, double otherBalance) |
double savingsBalance = 1000; |
/**
Deposits money into this account.
@param amount the amount of money to deposit
(Precondition: amount >= 0)
*/
/**
Deposits money into this account.
(Postcondition: getBalance() >= 0)
@param amount the amount of money to deposit
(Precondition: amount >= 0)
*/
class Numeric
{
public static boolean approxEqual(double x, double y)
|
if (Numeric.approxEqual(a, b)) . . . |
public class Coin |
|
Exercise - write a test class to exercise these classes
|