public class BankAccountStaticVersion
{
/**
* instance Variables, sometimes classed "fields"
* or "private data members"
*/
private static int accountNumber = 0;
private static String accountName = "no name";
private static double balance = 0.0; // e.g. 1.27 means $1.27
private static double interestRate = 0.0;
/**
* @param newAccountNumber The new number for the account
* /
public static void setAccountnumber(int newAccountnumber)
{
accountNumber = newAccountNumber;
}
/**
* @return The account number
*/
public static int getAccountNumber()
{
return accountNumber;
}
/**
* @return The account balance
*/
public static double getBalance()
{
return balance;
}
/**
* @param amount To be added to the balance
*/
public static void deposit(double amount)
{
balance = balance + amount;
}
/**
* @param amount to be subtracted from the balance
*
* @return to updated account balance
*/
public static double withdraw(double amount)
{
balance = balance - amount;
return balance;
}
/**
* @param newName The new name for the acocunt
*/
public static void setAccountName(String newName)
{
accountName = newName;
}
/**
* @return The name for the account
*/
public static String getAccountName()
{
return accountName;
}
/**
* @param newInterestRate New interest rate
*/
public static void setInterestRate(double newInterestRate)
{
interestRate = newInterestRate;
}
/**
* @return The interest rate
*/
public static double getInterestRate()
{
return interestRate;
}
} // class BankAccount ( static version )
This post has been edited by modi123_1: 16 April 2015 - 08:12 PM
Reason for edit:: please use the code tag button in the editor

New Topic/Question
Reply


MultiQuote





|