Created
February 4, 2018 10:12
-
-
Save annibuliful/767ca56a4882f1d511daa67bc1926ae0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BankAccount { | |
public double balance; | |
public BankAccount(){ | |
this.balance = 0; | |
} | |
public void deposit(double deposit){ | |
this.balance = this.balance + deposit; | |
} | |
public void withdraw(double withdraw){ | |
this.balance = this.balance - withdraw; | |
} | |
public double getBalance(){ | |
return this.balance; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BankAccountTester { | |
public static void main(String[] args){ | |
BankAccount account = new BankAccount(); | |
account.deposit(1000); | |
account.withdraw(500); | |
account.withdraw(400); | |
System.out.println(account.getBalance()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment