Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigDecimal;
- import java.math.BigInteger;
- import java.util.Vector;
- public class Bankomat {
- private static Vector<Account> accounts = new Vector<>(10);
- private static Account loggedInAccountOwner;
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- }
- private void initializeBankomatData() {
- // Create 5 random generated accounts
- accounts.add(new Account(new BigInteger("1000000001"), "Jak Kowalski", new BigDecimal("35.10")));
- accounts.add(new Account(new BigInteger("1000000002"), "Jak Nowak", new BigDecimal("56.60")));
- accounts.add(new Account(new BigInteger("1000000003"), "Henryk Sosna", new BigDecimal("572.25")));
- accounts.add(new Account(new BigInteger("1000000004"), "Aleksander Kosogłowy", new BigDecimal("134.30")));
- accounts.add(new Account(new BigInteger("1000000005"), "Mohinder Sarash", new BigDecimal("999900.00")));
- }
- private static boolean login(Account accountTryingToLogOn) {
- if (verifyAccountOwner(accountTryingToLogOn)) {
- // success
- loggedInAccountOwner = accountTryingToLogOn;
- return true;
- } else {
- // fail, wrong login details (account number or pin) or account doesnt exist at all.
- loggedInAccountOwner = null;
- return false;
- }
- }
- private static boolean verifyAccountOwner(Account accToVerify) {
- for (Account account : accounts) {
- if (account.getAccountNumber().equals(accToVerify.getAccountNumber())) { // if
- // that
- // accout
- // number
- // exist...
- if (account.getPin() == accToVerify.getPin()) { // if pin is
- // correct..
- return true; // ..mean that account exist.
- }
- }
- return false;
- }
- return false; // Mean that account doesnt exist in data base.
- }
- private static void logout() {
- loggedInAccountOwner = null;
- }
- private static BigDecimal getAccoutnBallance() {
- return loggedInAccountOwner.getBallance();
- }
- }
Add Comment
Please, Sign In to add comment