Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
CheckingAccount
/** A checking account that charges transaction fees. */ public class CheckingAccount:BankAccount { //Overrides the toString method in Object class public string ToString() { return base.ToString() + "[transactionCount= " + transactionCount + "]"; } //Overrides the compareTo method in the super BankAccount class public int CompareTo(object anObject) { if (anObject is SavingsAccount) return 1; else return base.CompareTo(anObject); } /** Constructs a checking account with a given balance. */ public CheckingAccount(double initialBalance) { // Construct superclass base (initialBalance); // Initialize transaction count transactionCount = 0; } public override deposit(double amount) { transactionCount++; // Now add amount to balance base.deposit(amount); } public override withdraw(double amount) { transactionCount++; // Now subtract amount from balance base.withdraw(amount); } /** Deducts the accumulated fees and resets the transaction count. */ public override deductFees() { if (transactionCount > FREE_TRANSACTIONS) { double fees = TRANSACTION_FEE * (transactionCount - FREE_TRANSACTIONS); base.withdraw(fees); } transactionCount = 0; } private int transactionCount; private static final int FREE_TRANSACTIONS = 3; private static final double TRANSACTION_FEE = 2.0; }
run
|
edit
|
history
|
help
0
WhereEnumerator
What is the best way to iterate over a Dictionary in C#?
Triangle
shorten file paths in a commandline using regex
sdfghjuyhtgrfedsdf
Unix time stamp
LeftAndRightShiftStrings
Event .net guidelines
1.3 Basics: interfaces
Code1