Skip to content

Access Control Lab #11

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 7 commits 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.idea
target
16 changes: 16 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/libraries/Maven__junit_junit_4_12.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Access Control UML.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions Access_Control_Lab.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_8" 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>
36 changes: 36 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?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>battin.preston</groupId>
<artifactId>AccessControl</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>

</dependencies>


<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>


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

import java.util.ArrayList;

/**
* Created by prestonbattin on 1/17/17.
*/
public class Account {


private String accountType, holdersName, status, overDraftProtection;
private int checkingAccountNumber, savingAccountNumber;
private static int totalSavingAccount, totalCheckingAccounts;
private double balance, rate;
private ArrayList<Double> withdrawals = new ArrayList<>(), deposits = new ArrayList<>(),
interestRates = new ArrayList<>(), transfers = new ArrayList<>();
private ArrayList<String> statuses = new ArrayList<>(), names = new ArrayList<>();


protected Account() {
}

protected Account(String type, String name) {
if (type.equals("Checking")) {
this.checkingAccountNumber = totalCheckingAccounts;
this.accountType = type;
totalCheckingAccounts++;
} else if (type.equals("Savings")) {
this.savingAccountNumber = totalSavingAccount;
this.accountType = type;
totalSavingAccount++;
}

this.holdersName = name;
}


protected int getAccountNumber(){

return this.savingAccountNumber;

}

protected void creditAccount(double credit){

this.balance += credit;
deposits.add(credit);
System.out.println("Account successfully credited +" + credit);
}

protected void debitAccount(double debit){

this.balance -= debit;
withdrawals.add(-debit);
System.out.println("Account successfully debited -" + debit);
}

protected ArrayList<Double> getDeposits(){

return deposits;
}

protected ArrayList<Double> getWithdrawls(){

return withdrawals;
}

protected void setAccountHoldersName(String name){

this.holdersName = name;
this.names.add(name);
}

protected ArrayList<Double> getTransfers(){

return transfers;
}

protected void makeTransfer(Account receiving, double money){

if((this.holdersName.equals(receiving.holdersName)) && (this.balance > money)){
this.balance -= money;
receiving.balance += money;
this.transfers.add(-money);
receiving.transfers.add(money);
} else
System.out.println("Not enough money to transfer.");
}

protected ArrayList<String> getStatuses(){

return statuses;
}

protected ArrayList<String> getNames(){

return names;
}

protected ArrayList<Double> getInterestRates(){

return interestRates;
}


protected void setInterestRates(double rate){

this.rate = rate;
this.interestRates.add(rate);
}

protected void setStatus(String status) {

if (status.equals("Open")) {
this.status = status;
}

else if (status.equals("Closed")) {
this.status = status;
}

else {
this.status = "OFAC Freeze";
}

this.statuses.add(status);
}

protected String getStatus() {

return this.status;
}

protected void setOverDraftProtection(String set) {

this.overDraftProtection = set;
}

protected String getOverDraftProtection() {

return this.overDraftProtection;
}

protected double getRate() {

return this.rate;
}

protected double getBalance() {

return this.balance;
}

protected String getHoldersName() {

return this.holdersName;
}

protected void setRate() {

if(this.accountType.equals("Savings")) {
this.rate = .06;
this.interestRates.add(.06);
}
else
this.rate = .05;
this.interestRates.add(.05);

}

}














21 changes: 21 additions & 0 deletions src/main/java/battin/preston/AccessControl/Checking.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package battin.preston.AccessControl;

/**
* Created by prestonbattin on 1/17/17.
*/
public class Checking extends Account {


public Checking(String type, String name){
super(type, name);
setRate();
setStatus("Open");
setOverDraftProtection("On");
}

public int getCheckingAccountNumber() {

return this.getCheckingAccountNumber();
}

}
38 changes: 38 additions & 0 deletions src/main/java/battin/preston/AccessControl/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package battin.preston.AccessControl;

import java.util.ArrayList;
import java.util.Scanner;

/**
* Created by prestonbattin on 1/17/17.
*/
public class Main {

static Scanner input = new Scanner(System.in);
static ArrayList<Checking> checkingAccount = new ArrayList<>();
static ArrayList<Savings> savingsAccount = new ArrayList<>();
static int i;

public static void main(String[] args) {

OpenAccount openedAccount = new OpenAccount();
openedAccount.getNameandAccountType();
openedAccount.openAccount();
















}
}
Loading