Skip to content

Kai #24

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
wants to merge 31 commits into
base: master
Choose a base branch
from
Open

Kai #24

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
537a90a
add classes
kendrang Oct 26, 2019
f9aa639
added Users Skeleton
Oct 26, 2019
1fece66
added balance method to User class
Oct 26, 2019
c51e00f
did stuff in main
kendrang Oct 26, 2019
7aba45a
merging with kai
kendrang Oct 26, 2019
38ebcc1
worked on main functions more
kendrang Oct 26, 2019
c07b418
drafted account and transactions classes
Oct 26, 2019
e5a0525
added a couple comments and changed a bit of formatting
Oct 26, 2019
8eaaa70
Merge pull request #1 from jackaharrisii/jack
kshields412 Oct 27, 2019
ba036c6
Merge pull request #2 from jackaharrisii/jack
kshields412 Oct 27, 2019
c2db134
added the ascii art
Oct 27, 2019
fae608a
Merge pull request #3 from jackaharrisii/jack
kshields412 Oct 27, 2019
3e4151c
cleaned up the pin menu and framed out some other menus
kendrang Oct 27, 2019
04ebbd1
merged jacks branch
Oct 27, 2019
af1bc45
Merge pull request #4 from kshields412/kai
kendrang Oct 27, 2019
63c91ae
Merge pull request #5 from kendrang/kendra
kshields412 Oct 27, 2019
a733f36
have the skeleton of the transactions menu 90% done
kendrang Oct 27, 2019
3ac8359
successfully tested acct creation and deposit
Oct 27, 2019
17220d2
Merge pull request #6 from jackaharrisii/jack
kshields412 Oct 27, 2019
574ebf2
Merge branch 'kai' into jack
kshields412 Oct 27, 2019
8b660b6
Merge pull request #7 from kshields412/jack
kshields412 Oct 27, 2019
cca16b4
finished all the transactions, accounts, and associated tests
Oct 28, 2019
690c95b
checkpoint kai
Oct 28, 2019
ab22427
Merge pull request #1 from kshields412/dev
jackaharrisii Oct 30, 2019
7b937a8
Merge pull request #8 from jackaharrisii/jack
kshields412 Oct 30, 2019
138ad0c
checkpoint before merge
kendrang Oct 30, 2019
a9f6277
got jacks stuff
kendrang Oct 30, 2019
9e204e0
Merge pull request #9 from kendrang/kendra
kshields412 Oct 30, 2019
c9457b5
figured some stuff out
kendrang Oct 30, 2019
1b7e939
pulling from kendra
Oct 30, 2019
b303559
checkpoint
Oct 31, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
312 changes: 312 additions & 0 deletions ASCII Art

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Tests should demonstrate proper behavior, and proper handling of misuse (eg. att
- Checking
- Savings
- Investment
- Account Actions
- AccountsAndTransactions.Account Actions
- Withdraw from acct
- Deposit to acct
- Transfer across accounts (self)
Expand Down
26 changes: 26 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,32 @@
<groupId>io.zipcoder</groupId>
<artifactId>project-2-atm</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
</dependency>
</dependencies>


</project>
123 changes: 123 additions & 0 deletions src/main/java/AccountsAndTransactions/Account.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package AccountsAndTransactions;

import java.util.ArrayList;

public class Account {
private static double chkAcctBal;


/*
Things we need here:
1. checking accounts
2. savings accounts
3. investment accounts
***bins would probably be a good way to store this information - have a bin for each user with a slot for each account

Things we may also need here?
1. account balance - there's already a balance value in the User.java tab, but it might work better here because we need separate balances in each type of account
2. account number
3. BONUS - Persistence
- create a way to store user information, account balances, etc
- probably the best way if we get to this would be to save a current state of all account balances to a spreadsheet when we close the ATM app
- alternately, access the spreadsheet every time any transaction is completed, so that if the program crashes before closing all information is still saved
*/

//establish all the data stored in the AccountsAndTransactions.Account object:
//instances of Accounts should have name [firstLast]
private String firstName;
private String lastName;
private int pin;
private int chkAcctNum;
private int savAcctNum;
private int invAcctNum;

private double savAcctBal;
private double invAcctBal;
public ArrayList<String> transactionHistory = new ArrayList<String>();

//actions that can be called to create a new account bin:
public Account(String firstName, String lastName, int pin){
this.firstName = firstName;
this.lastName = lastName;
this.pin = pin;
}


//create getters for all the data stored in the AccountsAndTransactions.Account object:
public String getFirstName() {
return firstName;
}

public String getLastName() {
return lastName;
}

public int getPin() {
return pin;
}

public int getChkAcctNum() {
return chkAcctNum;
}

public int getSavAcctNum() {
return savAcctNum;
}

public int getInvAcctNum() {
return invAcctNum;
}

public static double getChkAcctBal() {
return chkAcctBal;
}

public double getSavAcctBal() {
return savAcctBal;
}

public double getInvAcctBal() {
return invAcctBal;
}


public void setFirstName(String firstName) {
this.firstName = firstName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public void setPin(int pin) {
this.pin = pin;
}

public void setChkAcctNum(int chkAcctNum) {
this.chkAcctNum = chkAcctNum;
}

public void setSavAcctNum(int savAcctNum) {
this.savAcctNum = savAcctNum;
}

public void setInvAcctNum(int invAcctNum) {
this.invAcctNum = invAcctNum;
}

public void setChkAcctBal(double chkAcctBal) {
this.chkAcctBal = chkAcctBal;
}

public void setSavAcctBal(double savAcctBal) {
this.savAcctBal = savAcctBal;
}

public void setInvAcctBal(double invAcctBal) {
this.invAcctBal = invAcctBal;
}

public void setTransactionHistory(ArrayList<String> transactionHistory) {
this.transactionHistory = transactionHistory;
}
}
18 changes: 18 additions & 0 deletions src/main/java/AccountsAndTransactions/AccountTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package AccountsAndTransactions;

import org.junit.Assert;
import org.junit.Test;

import static org.junit.jupiter.api.Assertions.*;

public class AccountTest {

@Test
public void AccountTest(){
Account jeff = new Account("Jeff", "Smith",1234);
Assert.assertEquals("Jeff", jeff.getFirstName());
Assert.assertEquals("Smith", jeff.getLastName());
Assert.assertEquals(1234, jeff.getPin());
}

}
115 changes: 115 additions & 0 deletions src/main/java/AccountsAndTransactions/Transactions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package AccountsAndTransactions;

public class Transactions {
/*
needed:
1. Deposit to acct
2. Withdraw from acct
3. Transfer across accounts (self)
4. Open new account
5. Close account (must be empty)
6. Print transaction history
7. Check balance
*. Challenge: Transfer to another user's account (but not from)
*/

//establish variables:
private double increment; //the amount to be changed
private Account acctName; //the primary account (used for most transactions
private Account acctName2; //used when a second account type is required, such as a transfer)
private String acctType; //the type of account being changed
private String acctType2; //used when a second account type is required, such as a transfer


public Transactions(Account acctName) {
this.acctName = acctName;
}

public void deposit(double increment, String acctType){
this.increment = increment; //pull the amount being changed
this.acctType = acctType; //determine which account
//determine appropriate account, then perform balance += increment;
if(acctType == "checking"){
acctName.setChkAcctBal(acctName.getChkAcctBal() + increment);
}
else if (acctType == "savings"){
acctName.setSavAcctBal(acctName.getSavAcctBal() + increment);
}
else if (acctType == "investment"){
acctName.setInvAcctBal(acctName.getInvAcctBal() + increment);
}
else {
System.out.println("not a valid account type");
//then return them to the transaction screen
}
acctName.transactionHistory.add(String.format("Deposited $%.2f to " + acctType + ".", increment)); //append this transaction to the user's transaction history ArrayList
}

public void withdraw(double increment, String acctType){
this.increment = increment; //pull the amount being changed
this.acctType = acctType; //determine which account
if(acctType == "checking" && acctName.getChkAcctBal() >= increment) { //if checking && sufficient funds in acct
acctName.setChkAcctBal(acctName.getChkAcctBal() - increment); //decrement checking account
}
else if (acctType == "savings" && acctName.getSavAcctBal() >= increment){ //if savings && sufficient funds in acct
acctName.setSavAcctBal(acctName.getSavAcctBal() - increment); //decrement savings account
}
else if (acctType == "investment" && acctName.getInvAcctBal() >= increment){ //if investment && sufficient funds in acct
acctName.setInvAcctBal(acctName.getInvAcctBal() - increment); //decrement investment acct
}
else { //error or insufficient funds
System.out.println("not a valid account type or insufficient funds in " + acctType + " acct");
}
acctName.transactionHistory.add(String.format("Withdrew $%.2f from " + acctType + ".", increment)); //append this transaction to the user's transaction history ArrayList
}

public void transfer(double increment, String acctType, Account acctName2, String acctType2){
this.increment = increment; //pull the amount being changed
this.acctType = acctType; //determine the origin account
this.acctName2 = acctName2; //Account being deposited into
this.acctType2 = acctType2; //determine the destination account
withdraw(increment, acctType); //withdraw from first user
acctName = acctName2; //switch the account to the second user
deposit(increment, acctType2); //deposit to the second user
}

//close account will close an empty account, but will not run if the member has money remaining in any account
public void closeAccount(){
if (acctName.getChkAcctBal() == 0 && acctName.getSavAcctBal() == 0 && acctName.getInvAcctBal() == 0){
acctName.setFirstName(null); //java cannot delete objects, so instead we will set all bins to null
acctName.setLastName(null);
acctName.setPin(1000);
acctName.transactionHistory.add("Closed all accounts");
}
}

//force close account will close all accounts regardless of balance, and dispenses the sum balance in cash before logging out
//think of it like force choking your bank
public void forceCloseAccount(){
withdraw(acctName.getChkAcctBal(), "checking");
withdraw(acctName.getSavAcctBal(), "savings");
withdraw(acctName.getInvAcctBal(), "investment");
acctName.setFirstName(null); //java cannot delete objects, so instead we will set all bins to null
acctName.setLastName(null);
acctName.setPin(1000);
acctName.transactionHistory.add("Closed all accounts");
}

public String[] transactionHistory(){
String[] history = new String[acctName.transactionHistory.size()];
for (int i = 0; i < acctName.transactionHistory.size(); i++){
history[i] = acctName.transactionHistory.get(i);
}
return history;
//get a copy of the transaction history
//convert the copy to a string array
//print it
}

/* --------------------CHALLENGE------------------------
public void transferOtherUser(double increment, String acctType, String acctType2, user2){
UPDATE - I forgot this was the challenge and I programmed the transfer this way originally because I thought we had to.......
}
-----------------------CHALLENGE---------------------*/

}
Loading