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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
bin/code/Account.class
bin/code/BalanceInquiry.class
bin/code/BankDatabase.class
bin/code/Deposit.class
bin/code/Screen.class
bin/code/Withdrawal.class
Binary file removed bin/ATM.class
Binary file not shown.
Binary file removed 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 added bin/code/Buisness_logic/Account.class
Binary file not shown.
Binary file added bin/code/Buisness_logic/CashDispenser.class
Binary file not shown.
Binary file added bin/code/Buisness_logic/Euro.class
Binary file not shown.
Binary file added bin/code/Buisness_logic/Transaction.class
Binary file not shown.
Binary file added bin/code/Database/BankDatabase.class
Binary file not shown.
Binary file added bin/code/GUI/ATM.class
Binary file not shown.
Binary file added bin/code/GUI/ATMCaseStudy.class
Binary file not shown.
Binary file added bin/code/GUI/BalanceInquiry.class
Binary file not shown.
Binary file added bin/code/GUI/Deposit.class
Binary file not shown.
Binary file added bin/code/GUI/DepositSlot.class
Binary file not shown.
Binary file added bin/code/GUI/Keypad.class
Binary file not shown.
Binary file added bin/code/GUI/Screen.class
Binary file not shown.
Binary file added bin/code/GUI/Withdrawal.class
Binary file not shown.
1 change: 1 addition & 0 deletions componenti.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Nikolla Dionis 5196050
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.
67 changes: 30 additions & 37 deletions src/Account.java → src/code/Buisness_logic/Account.java
Original file line number Diff line number Diff line change
@@ -1,76 +1,69 @@
package code.Buisness_logic;
// Account.java

// Represents a bank account

public class 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 )
{
public Account(int theAccountNumber, int thePIN,
Euro theAvailableBalance, Euro theTotalBalance) {
accountNumber = theAccountNumber;
pin = thePIN;
availableBalance = theAvailableBalance;
totalBalance = theTotalBalance;
} // end Account constructor

// determines whether a user-specified PIN matches PIN in Account
public boolean validatePIN( int userPIN )
{
if ( userPIN == pin )
public boolean validatePIN(int userPIN) {
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 )
{
totalBalance += amount; // add to total balance
public void credit(Euro amount) {
totalBalance.somma(amount); // add to total balance
} // end method credit

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

// returns account number
public int getAccountNumber()
{
return accountNumber;
public int getAccountNumber() {
return accountNumber;
} // end method getAccountNumber
} // end class Account


/**************************************************************************
* (C) Copyright 1992-2007 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* (C) Copyright 1992-2007 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
*************************************************************************/
Original file line number Diff line number Diff line change
@@ -1,50 +1,46 @@
package code.Buisness_logic;
// CashDispenser.java

// Represents the cash dispenser of the ATM

public class CashDispenser
{
public class CashDispenser {
// the default initial number of bills in the cash dispenser
private final static int INITIAL_COUNT = 500;
private int count; // number of $20 bills remaining

// no-argument CashDispenser constructor initializes count to default
public CashDispenser()
{
public CashDispenser() {
count = INITIAL_COUNT; // set count attribute to default
} // end CashDispenser constructor

// simulates dispensing of specified amount of cash
public void dispenseCash( int amount )
{
public void dispenseCash(int amount) {
int billsRequired = amount / 20; // number of $20 bills required
count -= billsRequired; // update the count of bills
} // end method dispenseCash

// indicates whether cash dispenser can dispense desired amount
public boolean isSufficientCashAvailable( int amount )
{
public boolean isSufficientCashAvailable(int amount) {
int billsRequired = amount / 20; // number of $20 bills required

if ( count >= billsRequired )
if (count >= billsRequired)
return true; // enough bills available
else
else
return false; // not enough bills available
} // end method isSufficientCashAvailable
} // end class CashDispenser



/**************************************************************************
* (C) Copyright 1992-2007 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* (C) Copyright 1992-2007 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
*************************************************************************/
34 changes: 16 additions & 18 deletions src/DepositSlot.java → src/code/Buisness_logic/DepositSlot.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
package code.Buisness_logic;
// DepositSlot.java

// Represents the deposit slot of the ATM

public class DepositSlot
{
// indicates whether envelope was received (always returns true,
public class DepositSlot {
// indicates whether envelope was received (always returns true,
// because this is only a software simulation of a real deposit slot)
public boolean isEnvelopeReceived()
{
public boolean isEnvelopeReceived() {
return true; // deposit envelope was received
} // end method isEnvelopeReceived
} // end class DepositSlot



/**************************************************************************
* (C) Copyright 1992-2007 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* (C) Copyright 1992-2007 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
*************************************************************************/
54 changes: 54 additions & 0 deletions src/code/Buisness_logic/Euro.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package code.Buisness_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 = 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";
}

public void setValore(long valore) {
this.valore = valore;
}
}
50 changes: 24 additions & 26 deletions src/Transaction.java → src/code/Buisness_logic/Transaction.java
Original file line number Diff line number Diff line change
@@ -1,56 +1,54 @@
package code.Buisness_logic;
// Transaction.java

import code.Database.BankDatabase;
import code.GUI.*;

// Abstract superclass Transaction represents an ATM transaction

public abstract class Transaction
{
public abstract class Transaction {
private int accountNumber; // indicates account involved
private Screen screen; // ATM's screen
private BankDatabase bankDatabase; // account info database

// Transaction constructor invoked by subclasses using super()
public Transaction( int userAccountNumber, Screen atmScreen,
BankDatabase atmBankDatabase )
{
public Transaction(int userAccountNumber, Screen atmScreen,
BankDatabase atmBankDatabase) {
accountNumber = userAccountNumber;
screen = atmScreen;
bankDatabase = atmBankDatabase;
} // end Transaction constructor

// return account number
public int getAccountNumber()
{
return accountNumber;
// return account number
public int getAccountNumber() {
return accountNumber;
} // end method getAccountNumber

// return reference to screen
public Screen getScreen()
{
public Screen getScreen() {
return screen;
} // end method getScreen

// return reference to bank database
public BankDatabase getBankDatabase()
{
public BankDatabase getBankDatabase() {
return bankDatabase;
} // end method getBankDatabase

// perform the transaction (overridden by each subclass)
abstract public void execute();
} // end class Transaction



/**************************************************************************
* (C) Copyright 1992-2007 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* (C) Copyright 1992-2007 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
*************************************************************************/
Loading