Skip to content
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea/
*.iml
target/
*.class
*.properties
23 changes: 23 additions & 0 deletions banking/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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>com.revature</groupId>
<artifactId>banking</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version> 42.2.12</version>
</dependency>
</dependencies>

</project>
23 changes: 23 additions & 0 deletions banking/src/main/java/com/revature/BankingApp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.revature;

import com.revature.screens.HomeScreen;
import com.revature.util.AppState;

public class BankingApp {

private static AppState app =new AppState();

public static void main(String[] args){
while(app.isAppRunning()){
app.getRouter().navigate("/home");
}
}


//convenient to use, also works if we made the object public instead of private
public static AppState app(){
return app;
}


}
75 changes: 75 additions & 0 deletions banking/src/main/java/com/revature/account/Account.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.revature.account;

import com.revature.exceptions.InvalidRequestException;

public class Account {

public int accountId;
private AccountTypes accountType;
private double balance;

public Account(){

}

public Account(double balance,AccountTypes accountType){
this.balance=balance;
this.accountType=accountType;
}

public Account( double balance,AccountTypes accountType,int accountId){
this.accountId=accountId;
this.accountType=accountType;
this.balance=balance;
}

public double deposit(double amount){
balance+= amount;
return balance;
}

public double withdraw(double amount){
if(amount>balance){
System.err.println("Insufficient Funds!");
System.out.print("current balance: ");
return balance;

}
balance-=amount;
return balance;
}

public double transfer(double amount){
if(amount>balance){
System.err.println("Insufficient Funds!");
System.out.print("current balance: ");
return balance;

}
return amount;
}

public int getAccountId() {
return accountId;
}

public void setAccountId(int accountId) {
this.accountId = accountId;
}

public AccountTypes getAccountType() {
return accountType;
}

public void setAccountType(AccountTypes accountType) {
this.accountType = accountType;
}

public double getBalance() {
return balance;
}

public void setBalance(double balance) {
this.balance = balance;
}
}
5 changes: 5 additions & 0 deletions banking/src/main/java/com/revature/account/AccountTypes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.revature.account;

public enum AccountTypes {
CHECKING_ACCOUNT, SAVINGS_ACCOUNT
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.revature.exceptions;

public class AuthenticationException extends RuntimeException {

public AuthenticationException() {
super("Authentication failed!");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.revature.exceptions;

public class InvalidAccountException extends RuntimeException{


public InvalidAccountException(String message){
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.revature.exceptions;

public class InvalidRequestException extends RuntimeException {

public InvalidRequestException() {
super("Invalid request made!");
}

public InvalidRequestException(String message) {
super(message);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.revature.exceptions;

public class ResourcePersistenceException extends RuntimeException {

public ResourcePersistenceException(String message) {
super(message);
}

}
117 changes: 117 additions & 0 deletions banking/src/main/java/com/revature/models/AppUser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package com.revature.models;

import java.util.Objects;

public class AppUser {

private int id;
private String firstName;
private String lastName;
private String username;
private String password;
private UserRole userRole;

public AppUser(){
super();
}

// constructor without id and userRole because people dont sign in with an id and role
public AppUser(String firstName, String lastName, String username, String password) {
this.firstName = firstName;
this.lastName = lastName;
this.username = username;
this.password = password;
}

//constructor with all properties
public AppUser(int id, String firstName, String lastName, String username, String password, UserRole userRole) {
this(firstName, lastName, username, password);
this.id = id;
this.userRole = userRole;
}

//Setters and getters to set and obtain information from the database

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getFirstName() {
return firstName;
}

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

public String getLastName() {
return lastName;
}

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

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public UserRole getUserRole() {
return userRole;
}

public void setUserRole(UserRole userRole) {
this.userRole = userRole;
}

//to compare values in objects
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AppUser appUser = (AppUser) o;
return id == appUser.id &&
Objects.equals(firstName, appUser.firstName) &&
Objects.equals(lastName, appUser.lastName) &&
Objects.equals(username, appUser.username) &&
Objects.equals(password, appUser.password) &&
userRole == appUser.userRole;

}

// facilitates hash structures like a Map
public int hashCode() {
return Objects.hash(id,firstName,lastName,username,password,userRole);
}

//returns a given value into string format
@Override
public String toString() {
return "AppUser{" +
"id=" + id +
", firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
", username='" + username + '\'' +
", password='" + password + '\'' +
", userRole=" + userRole +
'}';
}


}
5 changes: 5 additions & 0 deletions banking/src/main/java/com/revature/models/UserRole.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.revature.models;

public enum UserRole {
ADMIN,EMPLOYEES,BASIC_USER
}
Loading