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
Fibonacci Recursive C#
2.2 gz
puzzle piezas
sdfghjikujyhtgrfedwcdf
Found many section of times intersect.
Dotnet Q-3
Linq-Where-Condition on a collection of anonymous types
w
Binary search tree - Pre-order Traversal
dateTime parsing