Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Write a description of class BankAccount here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class BankAccount
- {
- private double balance;
- public String accountHolder;
- public String accountNumber;
- public BankAccount () //constructor
- {
- balance = 0; //initialize to 0
- accountHolder = "";
- accountNumber = "";
- }
- //you should name all methods with lowercase
- //void = no return value
- //depositAmount is the amount to be deposited
- public void deposit (double depositAmount)
- {
- balance = balance + depositAmount; //old balance + deposit amount
- }
- //updates balance if withdraw value is less than balance, otherwise return 0 if not enough money in balance
- public double withdraw (double withdrawAmount)
- {
- if (balance >= withdrawAmount)
- {
- balance = balance - withdrawAmount; //old balance - withdraw amount
- return withdrawAmount;
- }
- else
- return 0;
- }
- public void printStatement ()
- {
- System.out.println("Your balance is " +balance);
- }
- public double getBalance()
- {
- return balance;
- }
- }
- //initalize the l and w to 1
- //getlength set length setwidth
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement