Skip to content

Had this done on a separate git, didn't see the fork #13

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 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions BankAccount/BankAccount.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=5,IE=9" ><![endif]-->
<!DOCTYPE html>
<html>
<head>
<title>BankAccount</title>
<meta charset="utf-8"/>
</head>
<body>
<div class="mxgraph" style="max-width:100%;border:1px solid transparent;" data-mxgraph="{&quot;highlight&quot;:&quot;#0000ff&quot;,&quot;nav&quot;:true,&quot;resize&quot;:true,&quot;xml&quot;:&quot;&lt;mxfile userAgent=\&quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36\&quot; version=\&quot;6.0.2.11\&quot; editor=\&quot;www.draw.io\&quot; type=\&quot;google\&quot;&gt;&lt;diagram name=\&quot;Page-1\&quot;&gt;7Vhbb+I4FP41SDMPXRHSAH2EkE7RcKkadlYzLyuTGGLViZFjSumvn+PYzoVQhtBWsyNtVbX2l+Nzjs9dbtlu/PyFo000ZSGmrU47fG7Zo1an07V68FcCewVY7RsFrDkJNVQAPnnBhk6jWxLitEIoGKOCbKpgwJIEB6KCIc7Zrkq2YrQqdYPWuAb4AaJ19B8Sikihfadd4HeYrCMj2WrrLzEyxBpIIxSyXQmyvZbtcsaEWsXPLqbSdsYu6tztK19zxThOxFkH0Kq3DHtt7CwdK8T2VUdxeEJ0qy87RMnjIAjYFjgqncXeGCLdkZiiBHbDSMQU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mfe93+ng4ev3qLVGzUUcZBMpSx6h4cKu/PLlwrr+kg49d7hoaIWTfUHK9PbTwTS/N6bqSByJ3PfG70lhm4f5j8ktyMz5n/bbTfOb3Rb/X2pNAad8Jw3Gwwn2mHt0dgvdhe6b/D3Yj4dLMbuH+hB6+bjMg+2xTN09q30lm97PwE=&lt;/diagram&gt;&lt;/mxfile&gt;&quot;,&quot;toolbar&quot;:&quot;pages zoom layers lightbox&quot;,&quot;page&quot;:0}"></div>
<script type="text/javascript" src="https://www.draw.io/js/viewer.min.js"></script>
</body>
</html>
17 changes: 17 additions & 0 deletions BankAccount/BankAccount.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>
20 changes: 20 additions & 0 deletions BankAccount/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>armstrong.alexandra</groupId>
<artifactId>BankAccount</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package armstrong.alexandra;

/**
* Created by alexandraarmstrong on 1/17/17.
*/
public enum AccountType {CHECKING, SAVINGS, INVESTMENT, IRA, MONEY_MARKET}
194 changes: 194 additions & 0 deletions BankAccount/src/main/java/armstrong/alexandra/BankAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
package armstrong.alexandra;

import java.io.*;

import static armstrong.alexandra.Status.*;
import static armstrong.alexandra.AccountType.*;
import static armstrong.alexandra.Overdraft.*;

/**
* Created by alexandraarmstrong on 1/17/17.
*/
public class BankAccount {
private final static int ROUTERNUMBER = 1234567;
private static int accountCounter = 0;

private AccountType accountType;
private long accountNumber;
private double balance = 0;
private String accountHolderName;
private double interestRate = 1.00d;
private Status status = CLOSED;
private Overdraft overdraft = DISABLED;
//private File record;

BankAccount(AccountType accountType, String accountHolderName){
this.accountType = accountType;
this.accountHolderName = accountHolderName;
accountCounter++;
accountNumber = Integer.valueOf(String.valueOf(ROUTERNUMBER) + String.valueOf(accountCounter));
status = OPEN;
}

BankAccount(AccountType accountType, String accountHolderName, Overdraft overdraft){
this(accountType, accountHolderName);
this.overdraft = overdraft;
}

BankAccount(AccountType accountType, String accountHolderName, double interestRate){
this(accountType, accountHolderName);
this.interestRate = interestRate;
}

BankAccount(AccountType accountType, String accountHolderName, double interestRate, Overdraft overdraft){
this(accountType, accountHolderName, overdraft);
this.interestRate = interestRate;
}


public AccountType getAccountType(){
return accountType;
}

public long getAccountNumber(){
return accountNumber;
}

public Double getBalance(){
if (status == FROZEN) {
return null;
} else {
return balance;
}
}

public String getAccountHolderName(){
return accountHolderName;
}

public double getInterestRate(){
return interestRate;
}

public Status getStatus(){
return status;
}

public Overdraft getOverdraft() {
return overdraft;
}

public void setOverdraft(Overdraft overdraft){
this.overdraft = overdraft;
}

public void setInterestRate(double interestRate){
this.interestRate = interestRate;
writeToFileChangeInterestRate();
}

protected void setStatus(Status status){
this.status = status;
writeToFileChangeStatus();
}

public String changeBalance(double amount) {
if (status == OPEN) {
if (overdraft == ENABLED) {
if (amount > 0 || amount > getBalance()) {
balance += amount;
writeToFileChangeBalance();
return "Balance adjusted";
} else {
return "Insufficient Funds";
}
} else {
balance += amount;
writeToFileChangeBalance();
return "Balance adjusted";
}
} else {
return "Balance inaccessible";
}
}

public String transferMoneyToOtherAccount(BankAccount otherAccount, double amount) {
if (accountHolderName.equalsIgnoreCase(otherAccount.accountHolderName)) {
if (getBalance() > amount || overdraft != DISABLED) {
changeBalance(-1 * amount);
otherAccount.changeBalance(amount);
return "Transfer Successful";
} else {
return "Insufficient funds";
}
} else {
return "Permission Denied";
}
}

public void setAccountHolderName(String name){
if(status != CLOSED){
this.accountHolderName = name;
writeToFileChangeName();
}
}

public String closeAccount(){
if(getBalance() == 0d){
setStatus(CLOSED);
return "Account Closed";
} else {
return "Please withdraw funds";
}
}

public String changeFreezeStatus(){
if (status == FROZEN) {
setStatus(OPEN);
return "Account unfrozen";
} else {
setStatus(FROZEN);
return "Account frozen";
}
}

private void writeToFileChangeBalance() {
try {
PrintStream print = new PrintStream(new BufferedOutputStream(new FileOutputStream("BankAccount.txt", true)));
print.println("Balance Changed to " + balance + ".");
print.close();
} catch (IOException e) {
}
}

private void writeToFileChangeStatus(){
try {
PrintStream print = new PrintStream(new BufferedOutputStream(new FileOutputStream("BankAccount.txt", true)));
print.println("Status changed to " + status + ".");
print.close();
} catch (IOException e) {
}
}

private void writeToFileChangeName(){
try {
PrintStream print = new PrintStream(new BufferedOutputStream(new FileOutputStream("BankAccount.txt", true)));
print.println("Name changed to " + accountHolderName + ".");
print.close();
} catch (IOException e) {
}
}

private void writeToFileChangeInterestRate(){
try {
PrintStream print = new PrintStream(new BufferedOutputStream(new FileOutputStream("BankAccount.txt", true)));
print.println("Interest rate changed to " + interestRate + ".");
print.close();
} catch (IOException e) {
}
}

}



6 changes: 6 additions & 0 deletions BankAccount/src/main/java/armstrong/alexandra/Overdraft.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package armstrong.alexandra;

/**
* Created by alexandraarmstrong on 1/17/17.
*/
public enum Overdraft {ENABLED, DISABLED, AUTOMATIC}
6 changes: 6 additions & 0 deletions BankAccount/src/main/java/armstrong/alexandra/Status.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package armstrong.alexandra;

/**
* Created by alexandraarmstrong on 1/17/17.
*/
public enum Status {OPEN, CLOSED, FROZEN}
Loading