Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SavingsAccount {
- //data members
- // are the basic characteristics of the object
- private double interest;
- private double balance;
- //method members
- //are the functionalities of the object
- //constructors These methods create (instantiate) an instance of the object
- /**
- * Default constructor sets the packageWeight to 0 and the miles to 0
- */
- public SavingsAccount(){
- interest = 0;
- balance = 0;
- }
- /**
- * full constructor sets the interest and the balance according to the parameters
- * @param interest is the interest rate
- * @param balance is the account balance
- */
- public SavingsAccount(double interest, double balance){
- this.interest = interest;
- this.balance = balance;
- }
- //getters
- /**
- * this method returns the interest
- * @return the interest
- */
- public double getinterest(){
- return interest;
- }
- /**
- * this method returns the account balance
- * @return the balance
- */
- public double getbalance(){
- return balance;
- }
- //setters
- /**
- * This method resets the interest and account balance according to the parameter
- * @param value will be set as the new value
- */
- public void setinterest( double value ) {
- this.interest = value;
- }
- public void setbalance( double value ) {
- this.balance = value;
- }
- //toString method
- public String toString(){
- String str;
- str = ("\tInterest - " + interest
- + "\tBalance - " + balance);
- return str;
- }
- //all other object specific methods
- public double deposit(){
- double deposit = 0;
- return balance += deposit;
- }
- public double withdrawal(){
- double withdrawal = 0;
- return balance -= withdrawal;
- }
- public double newBalance() {
- return balance += ((interest/12)*balance);
- }
- }//end class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement