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
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 added bin/Business_logic/ATMCaseStudy.class
Binary file not shown.
Binary file added bin/Business_logic/DepositSlot.class
Binary file not shown.
Binary file added bin/Business_logic/Euro.class
Binary file not shown.
Binary file added bin/Business_logic/Transaction.class
Binary file not shown.
Binary file removed bin/CashDispenser.class
Binary file not shown.
Binary file added bin/Database/BalanceInquiry.class
Binary file not shown.
Binary file added bin/Database/BankDatabase.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 added bin/GUI/ATM.class
Binary file not shown.
Binary file added bin/GUI/Account.class
Binary file not shown.
Binary file added bin/GUI/CashDispenser.class
Binary file not shown.
Binary file added bin/GUI/Deposit.class
Binary file not shown.
Binary file added bin/GUI/Keypad.class
Binary file not shown.
Binary file added bin/GUI/Screen.class
Binary file not shown.
Binary file added bin/GUI/Withdrawal.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/test/AccountTest.class
Binary file not shown.
Binary file added bin/test/BankDatabaseTest.class
Binary file not shown.
Binary file added bin/test/TestEuro.class
Binary file not shown.
3 changes: 3 additions & 0 deletions componenti.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Mazzolari Daniel Carlo 5200670
Ghio Francesco 5212572
Strata Elena 5199471
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.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package Business_logic;
// ATMCaseStudy.java
// Driver program for the ATM case study

import GUI.ATM;

public class ATMCaseStudy
{
// main method creates and runs the ATM
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package Business_logic;
// DepositSlot.java
// Represents the deposit slot of the ATM

Expand Down
48 changes: 48 additions & 0 deletions src/Business_logic/Euro.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package 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 = 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";
}
}
4 changes: 4 additions & 0 deletions src/Transaction.java → src/Business_logic/Transaction.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package Business_logic;
// Transaction.java
// Abstract superclass Transaction represents an ATM transaction

import Database.BankDatabase;
import GUI.Screen;

public abstract class Transaction
{
private int accountNumber; // indicates account involved
Expand Down
4 changes: 4 additions & 0 deletions src/BalanceInquiry.java → src/Database/BalanceInquiry.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package Database;
// BalanceInquiry.java
// Represents a balance inquiry ATM transaction

import Business_logic.Transaction;
import GUI.Screen;

public class BalanceInquiry extends Transaction
{
// BalanceInquiry constructor
Expand Down
3 changes: 3 additions & 0 deletions src/BankDatabase.java → src/Database/BankDatabase.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package Database;
// BankDatabase.java
// Represents the bank account information database

import GUI.Account;

public class BankDatabase
{
private Account accounts[]; // array of Accounts
Expand Down
6 changes: 6 additions & 0 deletions src/ATM.java → src/GUI/ATM.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package GUI;
// ATM.java
// Represents an automated teller machine

import Business_logic.DepositSlot;
import Business_logic.Transaction;
import Database.BalanceInquiry;
import Database.BankDatabase;

public class ATM
{
private boolean userAuthenticated; // whether user is authenticated
Expand Down
2 changes: 2 additions & 0 deletions src/Account.java → src/GUI/Account.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package GUI;

// Account.java
// Represents a bank account

Expand Down
1 change: 1 addition & 0 deletions src/CashDispenser.java → src/GUI/CashDispenser.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package GUI;
// CashDispenser.java
// Represents the cash dispenser of the ATM

Expand Down
5 changes: 5 additions & 0 deletions src/Deposit.java → src/GUI/Deposit.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package GUI;
// Deposit.java
// Represents a deposit ATM transaction

import Business_logic.DepositSlot;
import Business_logic.Transaction;
import Database.BankDatabase;

public class Deposit extends Transaction
{
private double amount; // amount to deposit
Expand Down
1 change: 1 addition & 0 deletions src/Keypad.java → src/GUI/Keypad.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package GUI;
// Keypad.java
// Represents the keypad of the ATM
import java.util.Scanner; // program uses Scanner to obtain user input
Expand Down
1 change: 1 addition & 0 deletions src/Screen.java → src/GUI/Screen.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package GUI;
// Screen.java
// Represents the screen of the ATM

Expand Down
4 changes: 4 additions & 0 deletions src/Withdrawal.java → src/GUI/Withdrawal.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package GUI;
// Withdrawal.java
// Represents a withdrawal ATM transaction

import Business_logic.Transaction;
import Database.BankDatabase;

public class Withdrawal extends Transaction
{
private int amount; // amount to withdraw
Expand Down
51 changes: 51 additions & 0 deletions src/test/AccountTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package test;
import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import GUI.Account;

public class AccountTest {
private Account account;

@Before
public void setUp() {
// Create a new Account object for each test
account = new Account(123456, 1234, 1000.0, 1000.0);
}

@Test
public void testValidatePIN() {
assertTrue(account.validatePIN(1234));
assertFalse(account.validatePIN(4321));
}

@Test
public void testGetAvailableBalance() {
assertEquals(1000, account.getAvailableBalance(), 0);
}

@Test
public void testGetTotalBalance() {
assertEquals(1000.0, account.getTotalBalance(), 0);
}

@Test
public void testCredit() {
account.credit(500.0);
assertEquals(1500.0, account.getTotalBalance(), 0);
}

@Test
public void testDebit() {
account.debit(500.0);
assertEquals(500.0, account.getTotalBalance(), 0);
}

@Test
public void testGetAccountNumber() {
assertEquals(123456, account.getAccountNumber());
}
}

51 changes: 51 additions & 0 deletions src/test/BankDatabaseTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package test;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import Database.BankDatabase;

public class BankDatabaseTest {
private BankDatabase bankDatabase;

@Before
public void setUp() {
bankDatabase = new BankDatabase();
}

@Test
public void testAuthenticateUser() {
assertTrue(bankDatabase.authenticateUser(12345, 54321));
assertTrue(bankDatabase.authenticateUser(98765, 56789));
assertFalse(bankDatabase.authenticateUser(87654321, 1234));
}

@Test
public void testGetAvailableBalance() {
assertEquals(1000.0, bankDatabase.getAvailableBalance(12345), 0.0);
assertEquals(200.0, bankDatabase.getAvailableBalance(98765), 0.0);
}

@Test
public void testGetTotalBalance() {
assertEquals(1200.0, bankDatabase.getTotalBalance(12345), 0.0);
assertEquals(200.0, bankDatabase.getTotalBalance(98765), 0.0);;
}

@Test
public void testCredit() {
bankDatabase.credit(12345, 500.0);
assertEquals(1000.0, bankDatabase.getAvailableBalance(12345), 0.0);
assertEquals(1700.0, bankDatabase.getTotalBalance(12345), 0.0);
}

@Test
public void testDebit() {
bankDatabase.debit(98765, 200.0);
assertEquals(0.0, bankDatabase.getAvailableBalance(98765), 0.0);
assertEquals(0.0, bankDatabase.getTotalBalance(98765), 0.0);
}

}
64 changes: 64 additions & 0 deletions src/test/TestEuro.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package test;
import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import Business_logic.Euro;



public class TestEuro {

private Euro euro1;
private Euro euro2;
private Euro euro3;

@Before
public void setUp() {
euro1 = new Euro(10, 50);
euro2 = new Euro(-5, 75);
euro3 = new Euro(12.75);
}

@Test
public void testConstructor() {
assertEquals(1050, euro1.getValore());
assertEquals(-575, euro2.getValore());
assertEquals(1275, euro3.getValore());
}

@Test
public void testGetValore() {
assertEquals(1050, euro1.getValore());
}

@Test
public void testSomma() {
euro1.somma(new Euro(5, 75));
assertEquals(1625, euro1.getValore());
}

@Test
public void testSottrai() {
euro1.sottrai(new Euro(5, 75));
assertEquals(475, euro1.getValore());
}

@Test
public void testUgualeA() {
assertTrue(euro1.ugualeA(new Euro(10, 50)));
assertFalse(euro1.ugualeA(new Euro(5, 75)));
}

@Test
public void testMinoreDi() {
assertFalse(euro1.minoreDi(new Euro(5, 75)));
assertTrue(euro1.minoreDi(new Euro(15, 25)));
}

@Test
public void testStampa() {
assertEquals("10.5 euro", euro1.stampa());
}
}