Skip to content
Open

Ryan #31

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
14 changes: 12 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
<groupId>io.zipcoder</groupId>
<artifactId>project-2-atm</artifactId>
<version>1.0-SNAPSHOT</version>


<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
61 changes: 61 additions & 0 deletions src/main/java/Account.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
public class Account {

Double balance;
String accountType= "Checking";
//Might use this for something later.
//Maybe an added modifier in case of multiple accounts of same type
String IDnum;


//A new instance of account would need starting funds and account type
public Account(Double startingBalance, String typeOfAccount){
balance=startingBalance;
accountType=typeOfAccount;
}

//the version of the constructor the tests use.
//The console should probably use the other one.
//If this constructor IS used, account defaults to a checking account.
public Account(Double startingBalance){
balance=startingBalance;
}

public Double getBalance(){
return balance;
}

public String getAccountType(){
return accountType;
}



//Possible area to expand on: perhaps withdrawing works differently pending account type.
//prevents overdrawing
public Double withdraw(Double amount){
if(amount>balance){
System.out.println("Insufficient funds for withdrawal.");
return 0.0;
}else{balance-=amount;
return amount;}
}

public void deposit(Double amount){
balance+=amount;
}



public void transfer(Account gettingMoney, Double amount){
gettingMoney.deposit(this.withdraw(amount));
}


//Uncertain if this is needed, but it was in the tests.
//Returns true if the account can be closed. False if not.
public Boolean closeAccount(){
if (balance==0.0){return true;}
else return false;
}

}
89 changes: 89 additions & 0 deletions src/main/java/Console.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import java.util.Scanner;

public class Console {

public void greetingMessage(){
System.out.println("Welcome to a real financial institution you can trust! \n");
}

//Just to testing!


//Simple user Interface
public void chooseAccount(){
Scanner userInput = new Scanner(System.in);
System.out.println("Which account would you like to access?");
System.out.println("1 - Checking, 2 - Savings, 2 - Investing");


String numIn = "";
boolean accountSelection = true;
while (accountSelection) {
numIn = userInput.nextLine();
switch (numIn) {
case "1": {
System.out.println("You have chosen Checking");
// insert call to correct map key/value(account object)
accountSelection = false;
break;
}
case "2": {
System.out.println("You have chosen Savings");
// insert call to correct map key/value(account object)
accountSelection = false;
break;
}
case "3": {

System.out.println("You have chosen Investing");
// insert call to correct map key/value(account object)
accountSelection = false;
break;
}
default: {
System.out.println("Please choose from the menu.");
break;
}
}
}




}

public void depositOrWithdraw() {
Scanner userInput = new Scanner(System.in);
System.out.println("Would you like to deposit or withdraw funds?");
System.out.println("1 - Deposit, 2 - Withdraw");

String numIn = userInput.nextLine();
switch (numIn) {
case "1": {
this.deposit();
break;
}
case "2": {
this.withdraw();
break;
}
default: {
System.out.println("Please choose from the menu.");
break;
}
}
}
public void deposit() {
System.out.print("Amount to be deposited: ");
//receive input
//parse to int
//if not an int return message to try again
}
public void withdraw() {
System.out.print("Amount to be withdrawn: ");
//if ( input greater than account balance ask for new amount)
}

//DO A COMMENT

}
8 changes: 7 additions & 1 deletion src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
public class Main {

public static void main(String[] args){


Console consoleOut = new Console();
consoleOut.greetingMessage();
consoleOut.chooseAccount();
consoleOut.depositOrWithdraw();


}
}
4 changes: 2 additions & 2 deletions src/main/test/AccountTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Test the expected Account class from ATM.
public class AccountTest {

@Test
/*@Test
public void testA0() {
Account a = new Account(0.0);
assertEquals(0.0, a.balance(), 0.0001);
Expand Down Expand Up @@ -77,7 +77,7 @@ public void testA6() {
a.transfer(b, 100.0); // nothing should happen
assertEquals(10.0, a.balance(), 0.0001);
assertEquals(0.0, b.balance(), 0.0001);
}
}*/


}
12 changes: 12 additions & 0 deletions src/main/test/ConsoleTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import org.junit.Test;

public class ConsoleTest{

/*@Test
public void greetingTest(){
Console console = new Console();
Console.greeting();

Assert.AssertTrue("Welcome!");
}*/
}