Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
2310ad3
ADD: code pkg & UPDATE: move all classes to code
Nov 21, 2023
4883ae5
ADD: code pkg & UPDATE: move all classes to code
Nov 21, 2023
1182af3
FIX: import error from DepositSlot.java to Withdraw.java
Nov 21, 2023
a464f33
FIX: import error from Account.java to Deposit.java
Nov 21, 2023
2624f02
Merge branch 'feature' of github.com:lollo02/ATM into feature
Nov 21, 2023
8e47c7b
REMOVE: .vscode
arun99-dev Nov 25, 2023
011832d
FIX: compliling
arun99-dev Nov 25, 2023
0c9193c
REMOVE: .vscode
arun99-dev Nov 25, 2023
51e25bf
ADD: Euro.java
arun99-dev Nov 25, 2023
815617d
ADD: Business_logic
arun99-dev Nov 25, 2023
4dc2c06
FIX: Business_logic imports
arun99-dev Nov 25, 2023
641ff30
ADD: GUI
Nov 25, 2023
fa2932a
ADD: Database
Universik15 Nov 25, 2023
60a9f92
ADD: test & EuroTest.java & constructorTests
Samu1538 Nov 25, 2023
12a8ff7
ADD: testSomma, testSottrai & testUgualeA
arun99-dev Nov 25, 2023
0dad77d
ADD: testMinoreDi & testStampa
Nov 25, 2023
dae80a6
REMOVE: empty line
arun99-dev Nov 25, 2023
436340c
UPDATE: double->Euro in Account.java!
arun99-dev Nov 25, 2023
3077a03
UPDATE: double->Euro in BankDatabase.java
arun99-dev Nov 25, 2023
8f332d1
UPDATE: double->Euro in Deposit.java & BalanceInquiry.java
Samu1538 Nov 25, 2023
81a91af
UPDATE: double->Euro in Withdrwal.java & Screen.java
Nov 25, 2023
db6cae9
REMOVE: remove test
arun99-dev Nov 25, 2023
e988a77
REMOVE: lib
arun99-dev Nov 25, 2023
2066fff
ADD: EuroTest.java
arun99-dev Nov 25, 2023
bf1f2e8
ADD: lib
arun99-dev Nov 25, 2023
4f0d3b2
FIX: import error Screen.java
arun99-dev Nov 25, 2023
f7eab84
FIX: datatype in BalanceInquiry.java
Samu1538 Nov 25, 2023
0cb0617
FIX: datatype in Deposit.java
Nov 25, 2023
733bb31
Merge branch 'feature' of github.com:lollo02/ATM into feature
Nov 25, 2023
404346a
ADD: EuroTest.java
arun99-dev Nov 25, 2023
5dc76f6
Merge branch 'test' of https://github.com/lollo02/ATM into test
Samu1538 Nov 25, 2023
21cc402
Merge branch 'test' of github.com:lollo02/ATM into test
Nov 25, 2023
c472330
ADD: AccountTest.java
Nov 25, 2023
940c298
ADD: BankDatabase.java
Samu1538 Nov 25, 2023
b9b5231
Merge branch 'test' of https://github.com/lollo02/ATM into test
Samu1538 Nov 25, 2023
0445d5d
REFACTOR: entire code
arun99-dev Nov 25, 2023
4f26a99
Merge branch 'feature'
arun99-dev Nov 25, 2023
8088718
Merge branch 'test'
arun99-dev Nov 25, 2023
f3ed2eb
REMOVE: testStampa (ready for conflict)
arun99-dev Nov 25, 2023
5ad4f3e
Merge branch 'test'
arun99-dev Nov 25, 2023
8c4ec1c
ADD: testStampa
arun99-dev Nov 25, 2023
d428cd6
UPDATE: ready for conflict #2
arun99-dev Nov 25, 2023
50c4bc7
UPDATE: resolve conflict
arun99-dev Nov 25, 2023
3cca461
UPDATE: ready for conflict #3
arun99-dev Nov 25, 2023
fded15b
UPDATE: ready for conflict #4
arun99-dev Nov 25, 2023
5e4a062
UPDATE: ready for conflict #4
arun99-dev Nov 25, 2023
738415c
UPDATE: resolve conflict
arun99-dev Nov 25, 2023
3809546
ADD: componenti.txt
Nov 25, 2023
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
7 changes: 0 additions & 7 deletions .vscode/settings.json

This file was deleted.

Binary file modified bin/ATMCaseStudy.class
Binary file not shown.
Binary file removed bin/Account.class
Binary file not shown.
Binary file removed bin/BalanceInquiry.class
Binary file not shown.
Binary file removed bin/BankDatabase.class
Binary file not shown.
Binary file removed bin/CashDispenser.class
Binary file not shown.
Binary file removed bin/Deposit.class
Binary file not shown.
Binary file removed bin/DepositSlot.class
Binary file not shown.
Binary file removed bin/Keypad.class
Binary file not shown.
Binary file removed bin/Screen.class
Binary file not shown.
Binary file removed bin/Transaction.class
Binary file not shown.
Binary file removed bin/Withdrawal.class
Binary file not shown.
Binary file renamed bin/ATM.class → bin/code/ATM.class
Binary file not shown.
Binary file added bin/code/ATMCaseStudy.class
Binary file not shown.
Binary file added bin/code/Account.class
Binary file not shown.
Binary file added bin/code/BalanceInquiry.class
Binary file not shown.
Binary file added bin/code/BankDatabase.class
Binary file not shown.
Binary file added bin/code/CashDispenser.class
Binary file not shown.
Binary file added bin/code/Deposit.class
Binary file not shown.
Binary file added bin/code/DepositSlot.class
Binary file not shown.
Binary file added bin/code/Keypad.class
Binary file not shown.
Binary file added bin/code/Screen.class
Binary file not shown.
Binary file added bin/code/Transaction.class
Binary file not shown.
Binary file added bin/code/Withdrawal.class
Binary file not shown.
6 changes: 6 additions & 0 deletions componenti.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Componenti del gruppo:
1) ArunRaj Mathiyalakan (S4954688)
2) Samuel Cavicchia (S5225277)
3) Romano Yuri (S5231931)

Nota: se nei commit vede un universik15 è un altro account di Cavicchia.
Binary file added lib/hamcrest-core 1.jar
Binary file not shown.
Binary file added lib/hamcrest-core-1.3.jar
Binary file not shown.
Binary file added lib/junit 4.13.2.jar
Binary file not shown.
Binary file added lib/junit-4.13.2.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions src/ATMCaseStudy.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import code.GUI.ATM;

// ATMCaseStudy.java
// Driver program for the ATM case study

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package code.Business_logic;

// CashDispenser.java
// Represents the cash dispenser of the ATM

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package code.Business_logic;

// DepositSlot.java
// Represents the deposit slot of the ATM

Expand Down
42 changes: 42 additions & 0 deletions src/code/Business_logic/Euro.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package code.Business_logic;

public class Euro {
private long valore;

public Euro(long euro, long cent) {
if (euro >= 0) valore = euro * 100 + cent;
else valore = euro * 100 - cent;
}

public Euro(double d) {
valore = (long)(d*100);
}

public long getValore() {
return valore;
}

public Euro somma(Euro e) {
this.valore = this.valore + e.getValore();
return this;
}

public Euro sottrai(Euro e) {
this.valore -= e.getValore();
return this;
}

public boolean ugualeA(Euro e){
if (valore == e.getValore()) return true;
else return false;
}

public boolean minoreDi(Euro e){
if (valore <= e.getValore()) return true;
else return false;
}

public String stampa(){
return (double)valore/100 +" euro";
}
}
31 changes: 16 additions & 15 deletions src/Account.java → src/code/Database/Account.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package code.Database;

import code.Business_logic.Euro;

// Account.java
// Represents a bank account

public class Account
{
private int accountNumber; // account number
private int pin; // PIN for authentication
private double availableBalance; // funds available for withdrawal
private double totalBalance; // funds available + pending deposits
private Euro availableBalance; // funds available for withdrawal
private Euro totalBalance; // funds available + pending deposits

// Account constructor initializes attributes
public Account( int theAccountNumber, int thePIN,
double theAvailableBalance, double theTotalBalance )
Euro theAvailableBalance, Euro theTotalBalance )
{
accountNumber = theAccountNumber;
pin = thePIN;
Expand All @@ -21,35 +24,33 @@ public Account( int theAccountNumber, int thePIN,
// determines whether a user-specified PIN matches PIN in Account
public boolean validatePIN( int userPIN )
{
if ( userPIN == pin )
return true;
else
return false;
if ( userPIN == pin ) return true;
else return false;
} // end method validatePIN

// returns available balance
public double getAvailableBalance()
public Euro getAvailableBalance()
{
return availableBalance;
} // end getAvailableBalance

// returns the total balance
public double getTotalBalance()
public Euro getTotalBalance()
{
return totalBalance;
} // end method getTotalBalance

// credits an amount to the account
public void credit( double amount )
public void credit( Euro amount )
{
totalBalance += amount; // add to total balance
totalBalance = totalBalance.somma(amount); // add to total balance
} // end method credit

// debits an amount from the account
public void debit( double amount )
public void debit( Euro amount )
{
availableBalance -= amount; // subtract from available balance
totalBalance -= amount; // subtract from total balance
availableBalance.sottrai(amount); // subtract from available balance
totalBalance.sottrai(amount); // subtract from total balance
} // end method debit

// returns account number
Expand Down
16 changes: 10 additions & 6 deletions src/BankDatabase.java → src/code/Database/BankDatabase.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
package code.Database;

import code.Business_logic.Euro;

// BankDatabase.java
// Represents the bank account information database

Expand All @@ -9,8 +13,8 @@ public class BankDatabase
public BankDatabase()
{
accounts = new Account[ 2 ]; // just 2 accounts for testing
accounts[ 0 ] = new Account( 12345, 54321, 1000.0, 1200.0 );
accounts[ 1 ] = new Account( 98765, 56789, 200.0, 200.0 );
accounts[ 0 ] = new Account( 12345, 54321, new Euro(1000.0), new Euro(1200.0) );
accounts[ 1 ] = new Account( 98765, 56789, new Euro(200.0), new Euro(200.0) );
} // end no-argument BankDatabase constructor

// retrieve Account object containing specified account number
Expand Down Expand Up @@ -42,25 +46,25 @@ public boolean authenticateUser( int userAccountNumber, int userPIN )
} // end method authenticateUser

// return available balance of Account with specified account number
public double getAvailableBalance( int userAccountNumber )
public Euro getAvailableBalance( int userAccountNumber )
{
return getAccount( userAccountNumber ).getAvailableBalance();
} // end method getAvailableBalance

// return total balance of Account with specified account number
public double getTotalBalance( int userAccountNumber )
public Euro getTotalBalance( int userAccountNumber )
{
return getAccount( userAccountNumber ).getTotalBalance();
} // end method getTotalBalance

// credit an amount to Account with specified account number
public void credit( int userAccountNumber, double amount )
public void credit( int userAccountNumber, Euro amount )
{
getAccount( userAccountNumber ).credit( amount );
} // end method credit

// debit an amount from of Account with specified account number
public void debit( int userAccountNumber, double amount )
public void debit( int userAccountNumber, Euro amount )
{
getAccount( userAccountNumber ).debit( amount );
} // end method debit
Expand Down
19 changes: 13 additions & 6 deletions src/Deposit.java → src/code/Database/Deposit.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
package code.Database;

import code.Business_logic.DepositSlot;
import code.Business_logic.Euro;
import code.GUI.Keypad;
import code.GUI.Screen;

// Deposit.java
// Represents a deposit ATM transaction

public class Deposit extends Transaction
{
private double amount; // amount to deposit
private Euro amount; // amount to deposit
private Keypad keypad; // reference to keypad
private DepositSlot depositSlot; // reference to deposit slot
private final static int CANCELED = 0; // constant for cancel option
Expand All @@ -30,12 +37,12 @@ public void execute()
amount = promptForDepositAmount(); // get deposit amount from user

// check whether user entered a deposit amount or canceled
if ( amount != CANCELED )
if ( amount.getValore() != CANCELED )
{
// request deposit envelope containing specified amount
screen.displayMessage(
"\nPlease insert a deposit envelope containing " );
screen.displayDollarAmount( amount );
screen.displayDollarAmount( new Euro(amount.getValore()) );
screen.displayMessageLine( "." );

// receive deposit envelope
Expand Down Expand Up @@ -65,7 +72,7 @@ public void execute()
} // end method execute

// prompt user to enter a deposit amount in cents
private double promptForDepositAmount()
private Euro promptForDepositAmount()
{
Screen screen = getScreen(); // get reference to screen

Expand All @@ -76,10 +83,10 @@ private double promptForDepositAmount()

// check whether the user canceled or entered a valid amount
if ( input == CANCELED )
return CANCELED;
return new Euro(CANCELED);
else
{
return ( double ) input / 100; // return dollar amount
return new Euro(input / 100); // return dollar amount
} // end else
} // end method promptForDepositAmount
} // end class Deposit
Expand Down
4 changes: 4 additions & 0 deletions src/Transaction.java → src/code/Database/Transaction.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
package code.Database;

import code.GUI.Screen;

// Transaction.java
// Abstract superclass Transaction represents an ATM transaction

Expand Down
8 changes: 8 additions & 0 deletions src/ATM.java → src/code/GUI/ATM.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
package code.GUI;

import code.Business_logic.CashDispenser;
import code.Business_logic.DepositSlot;
import code.Database.BankDatabase;
import code.Database.Deposit;
import code.Database.Transaction;

// ATM.java
// Represents an automated teller machine

Expand Down
14 changes: 10 additions & 4 deletions src/BalanceInquiry.java → src/code/GUI/BalanceInquiry.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
package code.GUI;

import code.Business_logic.Euro;
import code.Database.BankDatabase;
import code.Database.Transaction;

// BalanceInquiry.java
// Represents a balance inquiry ATM transaction

Expand All @@ -18,19 +24,19 @@ public void execute()
Screen screen = getScreen();

// get the available balance for the account involved
double availableBalance =
Euro availableBalance =
bankDatabase.getAvailableBalance( getAccountNumber() );

// get the total balance for the account involved
double totalBalance =
Euro totalBalance =
bankDatabase.getTotalBalance( getAccountNumber() );

// display the balance information on the screen
screen.displayMessageLine( "\nBalance Information:" );
screen.displayMessage( " - Available balance: " );
screen.displayDollarAmount( availableBalance );
screen.displayDollarAmount( new Euro(availableBalance.getValore()) );
screen.displayMessage( "\n - Total balance: " );
screen.displayDollarAmount( totalBalance );
screen.displayDollarAmount( new Euro(totalBalance.getValore()) );
screen.displayMessageLine( "" );
} // end method execute
} // end class BalanceInquiry
Expand Down
3 changes: 2 additions & 1 deletion src/Keypad.java → src/code/GUI/Keypad.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package code.GUI;

// Keypad.java
// Represents the keypad of the ATM
import java.util.Scanner; // program uses Scanner to obtain user input

public class Keypad
{
private Scanner input; // reads data from the command line

// no-argument constructor initializes the Scanner
public Keypad()
{
Expand Down
6 changes: 5 additions & 1 deletion src/Screen.java → src/code/GUI/Screen.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
package code.GUI;

import code.Business_logic.Euro;

// Screen.java
// Represents the screen of the ATM

Expand All @@ -16,7 +20,7 @@ public void displayMessageLine( String message )
} // end method displayMessageLine

// display a dollar amount
public void displayDollarAmount( double amount )
public void displayDollarAmount( Euro amount )
{
System.out.printf( "$%,.2f", amount );
} // end method displayDollarAmount
Expand Down
13 changes: 10 additions & 3 deletions src/Withdrawal.java → src/code/GUI/Withdrawal.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
package code.GUI;

import code.Business_logic.CashDispenser;
import code.Business_logic.Euro;
import code.Database.BankDatabase;
import code.Database.Transaction;

// Withdrawal.java
// Represents a withdrawal ATM transaction

Expand Down Expand Up @@ -27,7 +34,7 @@ public Withdrawal( int userAccountNumber, Screen atmScreen,
public void execute()
{
boolean cashDispensed = false; // cash was not dispensed yet
double availableBalance; // amount available for withdrawal
Euro availableBalance; // amount available for withdrawal

// get references to bank database and screen
BankDatabase bankDatabase = getBankDatabase();
Expand All @@ -47,13 +54,13 @@ public void execute()
bankDatabase.getAvailableBalance( getAccountNumber() );

// check whether the user has enough money in the account
if ( amount <= availableBalance )
if ( amount <= availableBalance.getValore() )
{
// check whether the cash dispenser has enough money
if ( cashDispenser.isSufficientCashAvailable( amount ) )
{
// update the account involved to reflect withdrawal
bankDatabase.debit( getAccountNumber(), amount );
bankDatabase.debit( getAccountNumber(), new Euro(amount) );

cashDispenser.dispenseCash( amount ); // dispense cash
cashDispensed = true; // cash was dispensed
Expand Down
Loading