-
Notifications
You must be signed in to change notification settings - Fork 65
Backend Alpha Version #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
PParfenov
wants to merge
4
commits into
Zipcoder:master
Choose a base branch
from
PParfenov:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| <mxfile userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36" version="7.5.8" editor="www.draw.io" type="github"><diagram id="ecaec085-76ac-b8d3-91e6-9eb226e6dbba" name="Page-1">7V3ZbuM4Fv2aAOmHBKJ2PzpLTReQqg46GdTMo2IxthBZNCQ5S3/9kCKphaRs2aaUoIaNAjqiKWo55y68pO49c67X7//Ko83qB4phemZb8fuZc3Nm27bnuvh/pOWDtgDPDmjLMk9i1tY0PCT/QNZosdZtEsOi07FEKC2TTbdxgbIMLspOW5Tn6K3b7Rml3atuoiWUGh4WUSq3/kricsVagWU1P/wJk+WKXTr02A9P0eJlmaNtxq53ZjvP1X/053XEx2L9i1UUo7dWk3N75lznCJX0r/X7NUzJy+WvjZ73refX+r5zmJVDTrDpCa9RumWPPl8s8O2X7PbKD/5KirdknUYZPrp6Rln5wH4B+DhKk2WG/17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XF3Na3WQx6MiU3xkGkm62FxYHgL7iOED8aXGbVFaqU8KXQT7ANvjBlBsxW9N271J+tJeizDZ8YfG9mTKCrm51QK6uBQjeDcSbanqAxLwKBa0NJ6wu1gS+APaw48H4S4MMcobLdPY82qx8ohqTH/wA=</diagram></mxfile> |
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
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.zipcode.macrolabs.atm; | ||
|
|
||
| import com.zipcode.macrolabs.atm.navigation.BankAccountManager; | ||
|
|
||
| public class Main { | ||
|
|
||
| public static void main(String[] args) { | ||
|
|
||
| BankAccountManager bankAccountManager = new BankAccountManager(); | ||
| bankAccountManager.run(); | ||
|
|
||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package com.zipcode.macrolabs.atm; | ||
|
|
||
| import java.util.Random; | ||
|
|
||
| public class RandomUtils { | ||
|
|
||
| private static final Random random = new Random(); | ||
|
|
||
| public static Float createFloat(float min, float max) { | ||
| return random.nextFloat() * (max - min) + min; | ||
| } | ||
|
|
||
| public static Integer createInteger(Integer min, Integer max) { | ||
| return createFloat(min, max).intValue(); | ||
| } | ||
|
|
||
| public static Boolean createBoolean(Integer skew){ | ||
| int seed = createInteger(0, 100); | ||
| if (skew > seed){ | ||
| return true; | ||
| } else { return false; } | ||
| } | ||
|
|
||
| public static Character createCharacter(char min, char max) { | ||
| return (char) createInteger((int) min, (int) max).intValue(); | ||
| } | ||
|
|
||
| public static String createString(char min, char max, int stringLength) { | ||
| StringBuffer sb = new StringBuffer(); | ||
| for (int i = 0; i < stringLength; i++) { | ||
| sb.append(createCharacter(min, max)); | ||
| } | ||
| return sb.toString(); | ||
| } | ||
|
|
||
| public static String createID(int idLength){ | ||
| String id = ""; | ||
| for (int i = 0; i < idLength; i++) { | ||
| id += i; | ||
| } | ||
| return id; | ||
| } | ||
|
|
||
| } |
117 changes: 117 additions & 0 deletions
117
src/main/java/com/zipcode/macrolabs/atm/bankaccount/Account.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| package com.zipcode.macrolabs.atm.bankaccount; | ||
|
|
||
| import com.zipcode.macrolabs.atm.exceptions.BalanceTooLowException; | ||
| import com.zipcode.macrolabs.atm.exceptions.TransactionAmountIsZeroException; | ||
| import com.zipcode.macrolabs.atm.transaction.Transaction; | ||
| import com.zipcode.macrolabs.atm.transaction.TransactionFactory; | ||
| import com.zipcode.macrolabs.atm.transaction.TransactionType; | ||
| import com.zipcode.macrolabs.atm.user.User; | ||
|
|
||
| import java.nio.file.attribute.UserDefinedFileAttributeView; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public abstract class Account { | ||
|
|
||
| protected String accountID; | ||
| protected AccountType accountType; | ||
| private double accountBalance = 0.00d; | ||
| private List<User> accountUsers = new ArrayList<User>(); | ||
| private AccountStatus accountStatus = AccountStatus.ACTIVE; | ||
| private List<Transaction> accountTransactionHistory = new ArrayList<Transaction>(); | ||
|
|
||
| @Override | ||
| public String toString(){ | ||
| String accountInfo = String.format("Account - ID: %s | Type: %s | Balance: %,.2f | Status: %s | Users: %s ", | ||
| this.getAccountID(), this.getAccountType(), this.getBalance(), | ||
| this.getAccountStatus(), this.getAccountUsers()); | ||
| return accountInfo; | ||
| } | ||
|
|
||
| public double getBalance() { | ||
| return this.accountBalance; | ||
| } | ||
|
|
||
| public void setBalance(double accountBalance) { | ||
| this.accountBalance = accountBalance; | ||
| } | ||
|
|
||
| public void setAccountID(int accountID) { | ||
| this.accountID = String.format( "%0" + AccountFactory.ACCOUNT_ID_LENGTH + "d", accountID); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 me gusta |
||
| } | ||
|
|
||
| public String getAccountID() { | ||
| return this.accountID; | ||
| } | ||
|
|
||
| public void addUser(User user) { | ||
| accountUsers.add(user); | ||
| } | ||
|
|
||
| public AccountStatus getAccountStatus() { | ||
| return accountStatus; | ||
| } | ||
|
|
||
|
|
||
| public void addTransactionToHistory(Transaction transaction){ | ||
| this.getTransactionHistory().add(transaction); | ||
| } | ||
|
|
||
| public Transaction withdrawAndMakeTransaction(double amount) throws TransactionAmountIsZeroException, BalanceTooLowException { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice use of |
||
|
|
||
| if(amount >= 0.001) { | ||
| if (this.accountBalance >= amount) { | ||
| this.accountBalance -= amount; | ||
| Transaction newTransaction = TransactionFactory.createNewWithdrawal(amount, this); | ||
| addTransactionToHistory(newTransaction); | ||
| return newTransaction; | ||
| } else { throw new BalanceTooLowException(); } | ||
| } else { throw new TransactionAmountIsZeroException(); } | ||
|
|
||
| } | ||
|
|
||
| public Transaction depositAndMakeTransaction(double amount) throws TransactionAmountIsZeroException { | ||
|
|
||
| if(amount >= 0.001) { | ||
| this.accountBalance += amount; | ||
| Transaction newTransaction = TransactionFactory.createNewDeposit(amount, this); | ||
| addTransactionToHistory(newTransaction); | ||
| return newTransaction; | ||
| } else { throw new TransactionAmountIsZeroException(); } | ||
|
|
||
| } | ||
|
|
||
| public Transaction transferAndMakeTransaction(double amount, Account destinationAccount) throws TransactionAmountIsZeroException, BalanceTooLowException { | ||
| if(amount >= 0.001) { | ||
| if (this.accountBalance >= amount) { | ||
| this.accountBalance -= amount; | ||
| destinationAccount.accountBalance += amount; | ||
| Transaction newTransaction = TransactionFactory.createNewTransfer(amount, this, destinationAccount); | ||
| addTransactionToHistory(newTransaction); | ||
| return newTransaction; | ||
| } else { throw new BalanceTooLowException(); } | ||
| } else { throw new TransactionAmountIsZeroException(); } | ||
| } | ||
|
|
||
| public abstract AccountType getAccountType(); | ||
|
|
||
| public void setAccountStatus(AccountStatus accountStatus){ | ||
| this.accountStatus = accountStatus; | ||
| } | ||
|
|
||
| public ArrayList<User> getAccountUsers() { | ||
| return (ArrayList<User>) accountUsers; | ||
| } | ||
|
|
||
| public ArrayList<Transaction> getTransactionHistory() { | ||
| return (ArrayList<Transaction>) accountTransactionHistory; | ||
| } | ||
|
|
||
| public String printTransactionHistory(){ | ||
| String history = ""; | ||
| for (Transaction transaction: this.getTransactionHistory()) { | ||
| history += transaction.toString() + "\n"; | ||
| } | ||
| return history; | ||
| } | ||
| } | ||
43 changes: 43 additions & 0 deletions
43
src/main/java/com/zipcode/macrolabs/atm/bankaccount/AccountFactory.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package com.zipcode.macrolabs.atm.bankaccount; | ||
|
|
||
| import com.zipcode.macrolabs.atm.exceptions.NoMoreAccountsException; | ||
| import com.zipcode.macrolabs.atm.user.User; | ||
|
|
||
| public class AccountFactory { | ||
|
|
||
| static int iteratedAccountID = 0; | ||
| static final int ACCOUNT_ID_LENGTH = 9; | ||
|
|
||
| static int nextAccountID() throws NoMoreAccountsException { | ||
| if((""+ iteratedAccountID).length() <= ACCOUNT_ID_LENGTH) { | ||
| return iteratedAccountID++; | ||
| } else { throw new NoMoreAccountsException(); } | ||
| } | ||
|
|
||
| private static Account accountCreatorHelper(Account account, User user){ | ||
| try { | ||
| account.setAccountID(nextAccountID()); | ||
| } catch (NoMoreAccountsException e) { | ||
| e.printStackTrace(); | ||
| } | ||
| account.addUser(user); | ||
| AccountWarehouse.addAccount(account); | ||
| return account; | ||
| } | ||
|
|
||
| public static CheckingAccount createNewCheckingAccount(User user) { | ||
| CheckingAccount account = new CheckingAccount(); | ||
| return (CheckingAccount) accountCreatorHelper(account, user); | ||
| } | ||
|
|
||
| public static SavingsAccount createNewSavingsAccount(User user) { | ||
| SavingsAccount account = new SavingsAccount(); | ||
| return (SavingsAccount) accountCreatorHelper(account, user); | ||
| } | ||
|
|
||
| public static InvestmentAccount createNewInvestmentAccount(User user) { | ||
| InvestmentAccount account = new InvestmentAccount(); | ||
| return (InvestmentAccount) accountCreatorHelper(account, user); | ||
| } | ||
|
|
||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/zipcode/macrolabs/atm/bankaccount/AccountStatus.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.zipcode.macrolabs.atm.bankaccount; | ||
|
|
||
| public enum AccountStatus { | ||
|
|
||
| ACTIVE, | ||
| CLOSED | ||
|
|
||
| } |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/zipcode/macrolabs/atm/bankaccount/AccountType.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.zipcode.macrolabs.atm.bankaccount; | ||
|
|
||
| public enum AccountType { | ||
|
|
||
| CHECKING, | ||
| SAVINGS, | ||
| INVESTMENT, | ||
| TEST | ||
|
|
||
| } |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/zipcode/macrolabs/atm/bankaccount/AccountWarehouse.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.zipcode.macrolabs.atm.bankaccount; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public class AccountWarehouse { | ||
|
|
||
| private static final List<Account> accounts = new ArrayList<Account>(); | ||
|
|
||
| public static void addAccount(Account account) { | ||
| accounts.add(account); | ||
| } | ||
|
|
||
| public static List<Account> getAccounts() { | ||
| return accounts; | ||
| } | ||
|
|
||
| public static Account findAccountByID(String accountID){ | ||
| Account accountOut = null; | ||
| for (Account account: accounts){ | ||
| if(accountID.equals(account.getAccountID())){ | ||
| accountOut = account; | ||
| break; | ||
| } | ||
| } | ||
| return accountOut; | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/zipcode/macrolabs/atm/bankaccount/CheckingAccount.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.zipcode.macrolabs.atm.bankaccount; | ||
|
|
||
| public class CheckingAccount extends Account { | ||
|
|
||
| public CheckingAccount(){ } | ||
|
|
||
| @Override | ||
| public AccountType getAccountType() { | ||
| return AccountType.CHECKING; | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/zipcode/macrolabs/atm/bankaccount/InvestmentAccount.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.zipcode.macrolabs.atm.bankaccount; | ||
|
|
||
| public class InvestmentAccount extends Account { | ||
|
|
||
| public InvestmentAccount(){ } | ||
|
|
||
| @Override | ||
| public AccountType getAccountType() { | ||
| return AccountType.INVESTMENT; | ||
| } | ||
|
|
||
| } |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/zipcode/macrolabs/atm/bankaccount/SavingsAccount.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.zipcode.macrolabs.atm.bankaccount; | ||
|
|
||
| public class SavingsAccount extends Account { | ||
|
|
||
| public SavingsAccount(){ } | ||
|
|
||
| @Override | ||
| public AccountType getAccountType() { | ||
| return AccountType.SAVINGS; | ||
| } | ||
|
|
||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/zipcode/macrolabs/atm/exceptions/AccountNotEmptyException.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.zipcode.macrolabs.atm.exceptions; | ||
|
|
||
| public class AccountNotEmptyException extends Exception{ | ||
|
|
||
| public AccountNotEmptyException(){} | ||
|
|
||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/zipcode/macrolabs/atm/exceptions/BalanceTooLowException.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.zipcode.macrolabs.atm.exceptions; | ||
|
|
||
| public class BalanceTooLowException extends Exception { | ||
|
|
||
| public BalanceTooLowException(){} | ||
|
|
||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/zipcode/macrolabs/atm/exceptions/NoMoreAccountsException.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.zipcode.macrolabs.atm.exceptions; | ||
|
|
||
| public class NoMoreAccountsException extends Exception { | ||
|
|
||
| public NoMoreAccountsException(){} | ||
|
|
||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/zipcode/macrolabs/atm/exceptions/NoMoreTransactionsException.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.zipcode.macrolabs.atm.exceptions; | ||
|
|
||
| public class NoMoreTransactionsException extends Exception { | ||
|
|
||
| public NoMoreTransactionsException(){} | ||
|
|
||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/zipcode/macrolabs/atm/exceptions/NoMoreUsersException.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.zipcode.macrolabs.atm.exceptions; | ||
|
|
||
| public class NoMoreUsersException extends Exception{ | ||
|
|
||
| public NoMoreUsersException(){} | ||
|
|
||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/zipcode/macrolabs/atm/exceptions/TransactionAmountIsZeroException.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.zipcode.macrolabs.atm.exceptions; | ||
|
|
||
| public class TransactionAmountIsZeroException extends Exception{ | ||
|
|
||
| public TransactionAmountIsZeroException(){ | ||
| System.out.println("Please don't waste our time with $0.00 transactions."); | ||
| } | ||
|
|
||
| } |
4 changes: 4 additions & 0 deletions
4
src/main/java/com/zipcode/macrolabs/atm/navigation/Authenticator.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package com.zipcode.macrolabs.atm.navigation; | ||
|
|
||
| public class Authenticator { | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice declaration of the abstract type
Listand instantiation of concrete typeArrayList! 👍