Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package just;
- public class Account {
- private double balance ;
- private static int accounts;
- private int account_no;
- public Account () {
- balance=0;
- account_no = ++accounts;
- }
- /***
- * this is b = to intialize the balance of the Account .
- * @param b
- */
- public Account ( double b) {
- balance=b;
- account_no=++accounts;
- }
- /***
- *
- * @param b : to set a new balance to the Account .
- */
- public void setbalance(double b) {
- balance=b;
- }
- /**
- *
- * @return the balance of the Account .
- */
- public double getbalance() {
- return balance;
- }
- /**
- * returns the number of accounts in the Bank .
- * @return
- */
- public int getno_accounts(){
- return account_no;
- }
- /***
- * to take money from the Account .
- * @param money
- */
- public void withdraw(double money) {//getmoney
- if (money<balance&&money>0)
- balance-=money;
- else {
- System.out.println("sorry you only have "+getbalance());
- }
- }
- /**
- * to add money to the Account .
- * @param money
- */
- public void deposite (double money) {
- balance+=money;
- }
- /**
- * override to To_String fuunction to print the details of the account .
- */
- public String toString () {
- return String.format("The account number is: " + account_no + " \nthe account balance is "+balance);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement