From 4f72260c8282a1bf239dfb1c8e3f4b6af81f10f3 Mon Sep 17 00:00:00 2001 From: Anthony DA SILVA COSTA Date: Fri, 6 Mar 2020 15:16:09 +0100 Subject: [PATCH 01/35] Add new directory --- Test/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Test/.gitkeep diff --git a/Test/.gitkeep b/Test/.gitkeep new file mode 100644 index 00000000..e69de29b -- GitLab From a25df2582462b40c98bdf057d7dc3300c96aa974 Mon Sep 17 00:00:00 2001 From: Anthony Date: Tue, 31 Mar 2020 12:45:19 +0200 Subject: [PATCH 02/35] Operation Date, OperationTest, Client - Account --- Test/.gitkeep | 0 .../software/construction/Account.java | 120 +++++++++++------- .../unantes/software/construction/Client.java | 39 ++++-- .../construction/DepositOperation.java | 4 +- .../software/construction/Operation.java | 16 +-- .../construction/WithdrawOperation.java | 6 +- 6 files changed, 115 insertions(+), 70 deletions(-) delete mode 100644 Test/.gitkeep diff --git a/Test/.gitkeep b/Test/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/src/main/java/fr/unantes/software/construction/Account.java b/src/main/java/fr/unantes/software/construction/Account.java index cf6ef413..5c5dab10 100755 --- a/src/main/java/fr/unantes/software/construction/Account.java +++ b/src/main/java/fr/unantes/software/construction/Account.java @@ -1,6 +1,8 @@ package fr.unantes.software.construction; import java.io.InvalidClassException; +import java.time.LocalTime; +import java.util.ArrayList; import java.util.Collection; import java.util.Vector; import java.util.Iterator; @@ -8,7 +10,8 @@ import java.util.Iterator; public class Account { public Vector Operation; public String type; - + public ClientReference cref; + /** * Initializes the owner, amount, overdraft and the account number with parameters * The method also initializes the history with a new empty Vector @@ -23,6 +26,7 @@ public class Account { if (!type.equals("private") && !type.equals("company")) { throw new InvalidClassException("Invalid type supplied. An account can only be private or company"); } + cref = new ClientReference(); } /** @@ -36,22 +40,22 @@ public class Account { /** * If the amount is greater or equal to the balance, withdraws the amount - * If the amount is lower than the balance and greater than the overdraft, + * If the amount is lower than the balance and greater than the overdraft, * withdraws the amount and throws an exception to warn that the balance is negative - * If the amount is lower than the overdraft, - *the amount is not withdrawn and exception is thrown to indicate that there is not enough credit. + * If the amount is lower than the overdraft, + *the amount is not withdrawn and exception is thrown to indicate that there is not enough credit. */ public void withdraw(float amount) throws Exception { float newBalance = balance - amount; if (newBalance > 0){ balance = newBalance; - Operation o = new WithdrawOperation(amount, (int)System.currentTimeMillis()); + Operation o = new WithdrawOperation(amount, LocalTime.now()); addHistory(o); } else{ - if ((Math.abs(newBalance)) <= overdraft){ + if ((Math.abs(newBalance)) <= overdraft){ balance = newBalance; - Operation o = new WithdrawOperation(amount,(int)System.currentTimeMillis()); + Operation o = new WithdrawOperation(amount, LocalTime.now()); addHistory(o); throw new Exception("Warning: the balance is negative: "+balance); } @@ -62,29 +66,29 @@ public class Account { } /** - * + * * This attribute memorizes the current balance of the account - * + * */ private float balance; /** - * + * * this is the maximum overdraft authorized for this account - * + * */ private float overdraft; /** - * + * * @uml.property name="history" * @uml.associationEnd inverse="compte:fr.unantes.software.construction.Operation" multiplicity="(0 -1)" - * + * */ private Collection history; /** - * + * * @uml.property name="history" */ public java.util.Collection getHistory() { @@ -92,7 +96,7 @@ public class Account { } /** - * + * * @uml.property name="history" */ public void setHistory(java.util.Collection value) { @@ -100,7 +104,7 @@ public class Account { } /** - * + * * @uml.property name="history" */ public Iterator historyIterator() { @@ -108,7 +112,7 @@ public class Account { } /** - * + * * @uml.property name="history" */ public boolean addHistory(Operation element) { @@ -116,7 +120,7 @@ public class Account { } /** - * + * * @uml.property name="history" */ public boolean removeHistory(Operation element) { @@ -124,7 +128,7 @@ public class Account { } /** - * + * * @uml.property name="history" */ public boolean isHistoryEmpty() { @@ -132,7 +136,7 @@ public class Account { } /** - * + * * @uml.property name="history" */ public void clearHistory() { @@ -140,7 +144,7 @@ public class Account { } /** - * + * * @uml.property name="history" */ public boolean containsHistory(Operation element) { @@ -148,7 +152,7 @@ public class Account { } /** - * + * * @uml.property name="history" */ public boolean containsAllHistory(Collection elements) { @@ -156,7 +160,7 @@ public class Account { } /** - * + * * @uml.property name="history" */ public int historySize() { @@ -164,96 +168,96 @@ public class Account { } /** - * + * * @uml.property name="history" */ public Operation[] historyToArray() { return (Operation[]) history - .toArray(new Operation[history.size()]); + .toArray(new Operation[history.size()]); } /** - * + * * @uml.property name="overdraft" - * + * */ public float getOverdraft() { return overdraft; } /** - * + * * @uml.property name="overdraft" - * + * */ public void setOverdraft(float overdraft) { this.overdraft = overdraft; } /** - * + * * @uml.property name="balance" - * + * */ public float getBalance() { return balance; } /** - * + * * @uml.property name="balance" - * + * */ public void setBalance(float balance) { this.balance = balance; } /** - * + * * this is the number of the account - * + * */ private int number; /** - * + * * @uml.property name="number" - * + * */ public int getNumber() { return number; } /** - * + * * @uml.property name="number" - * + * */ public void setNumber(int number) { this.number = number; } /** - * + * * @uml.property name="owner" * @uml.associationEnd inverse="accounts:fr.unantes.software.construction.Client" multiplicity="(0 1)" - * + * */ public Client owner; /** - * + * * @uml.property name="owner" - * + * */ public Client getOwner() { return owner; } /** - * + * * @uml.property name="owner" - * + * */ public void setOwner(Client owner) { if (owner.role == "private" & this.type != "private") return; @@ -270,5 +274,31 @@ public class Account { } } + public class ClientReference { + private ArrayList clients; + + public ClientReference(){ + clients = new ArrayList(); + } + + public void add(Client c){ + basicAdd(c); + c.aref.basicAdd(Account.this); + } + + public void remove(Client c){ + basicRemove(c); + c.aref.basicRemove(Account.this); + } + + public void basicAdd(Client c){ + clients.add(c); + } + + public void basicRemove(Client c){ + clients.remove(c); + } + } + } diff --git a/src/main/java/fr/unantes/software/construction/Client.java b/src/main/java/fr/unantes/software/construction/Client.java index e2914cc4..1f73577f 100644 --- a/src/main/java/fr/unantes/software/construction/Client.java +++ b/src/main/java/fr/unantes/software/construction/Client.java @@ -4,6 +4,7 @@ import fr.unantes.software.construction.address.Address; import fr.unantes.software.construction.address.Card; import java.io.InvalidClassException; +import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.Vector; @@ -11,15 +12,14 @@ import java.util.Vector; public class Client { /** - * * The name of the person - * */ public String name; public String role; public Account[] accounts; short account_size = 0; public Card card; + public AccountReference aref; public Client(String name, String role) throws InvalidClassException { @@ -52,7 +52,6 @@ public class Client { } /** - * * @uml.property name="accounts" */ public Account[] getAccounts() { @@ -60,7 +59,6 @@ public class Client { } /** - * * @uml.property name="accounts" */ public void setAccounts(Account[] value) { @@ -68,7 +66,6 @@ public class Client { } /** - * * @uml.property name="accounts" */ public void addAccounts(Account element) { @@ -76,7 +73,6 @@ public class Client { } /** - * * @uml.property name="accounts" */ public boolean removeAccounts(Account element) { @@ -87,7 +83,6 @@ public class Client { } /** - * * @uml.property name="accounts" */ public boolean isAccountsEmpty() { @@ -99,7 +94,6 @@ public class Client { } /** - * * @uml.property name="accounts" */ public void clearAccounts() { @@ -107,7 +101,6 @@ public class Client { } /** - * * @uml.property name="accounts" */ public boolean containsAccounts(Account element) { @@ -119,7 +112,6 @@ public class Client { /** - * * @uml.property name="accounts" */ public int accountsSize() { @@ -127,7 +119,6 @@ public class Client { } /** - * * @uml.property name="accounts" */ public Account[] accountsToArray() { @@ -140,13 +131,35 @@ public class Client { if (o == null || getClass() != o.getClass()) return false; Client person = (Client) o; if (getRole().equals(person.getRole()) && role.equals("agent")) { - return getName().equals(person.getName()) && card == person.card; + return getName().equals(person.getName()) && card == person.card; } return getName().equals(person.getName()) && getRole().equals(person.getRole()); } public int hashCode() { - return getName().hashCode() + getRole().hashCode() + card.hashCode(); + return getName().hashCode() + getRole().hashCode() + card.hashCode(); } + + public class AccountReference { + private ArrayList account; + public void add(Account a){ + basicAdd(a); + a.cref.basicAdd(Client.this); + } + + public void basicAdd(Account a) { + account.add(a); + } + + public void remove(Account a){ + basicRemove(a); + a.cref.basicRemove(Client.this); + } + + public void basicRemove(Account a) { + account.remove(a); + } + } } + diff --git a/src/main/java/fr/unantes/software/construction/DepositOperation.java b/src/main/java/fr/unantes/software/construction/DepositOperation.java index a77f9405..ad56c7ed 100755 --- a/src/main/java/fr/unantes/software/construction/DepositOperation.java +++ b/src/main/java/fr/unantes/software/construction/DepositOperation.java @@ -1,12 +1,14 @@ package fr.unantes.software.construction; +import java.time.LocalTime; + public class DepositOperation extends Operation { /** * Calls the constructor of super class with the parameter amount */ - public DepositOperation(float amount, int i) { + public DepositOperation(float amount, LocalTime i) { super(amount, i); } diff --git a/src/main/java/fr/unantes/software/construction/Operation.java b/src/main/java/fr/unantes/software/construction/Operation.java index 6c889331..df6c57de 100755 --- a/src/main/java/fr/unantes/software/construction/Operation.java +++ b/src/main/java/fr/unantes/software/construction/Operation.java @@ -1,30 +1,28 @@ package fr.unantes.software.construction; +import java.time.*; + public abstract class Operation { public Account account; - private int time; + private LocalTime time; /** - * * This attribute memorizes the amount involved in the operation - * */ private float amount; /** - * * @uml.property name="amount" - * */ public float getAmount() { return amount; } + public LocalTime getTime(){ return time; } + /** - * * @uml.property name="amount" - * */ public void setAmount(float amount) { this.amount = amount; @@ -33,13 +31,13 @@ public abstract class Operation { /** * Sets the amount with the parameter */ - public Operation(float amount, int i) { + public Operation(float amount, LocalTime i) { this.amount = amount; this.time = i; } /** - * Returns the type of the operation as a String. + * Returns the type of the operation as a String. */ public abstract String getOperationType(); diff --git a/src/main/java/fr/unantes/software/construction/WithdrawOperation.java b/src/main/java/fr/unantes/software/construction/WithdrawOperation.java index e6a9a64b..53b9d220 100755 --- a/src/main/java/fr/unantes/software/construction/WithdrawOperation.java +++ b/src/main/java/fr/unantes/software/construction/WithdrawOperation.java @@ -1,12 +1,14 @@ package fr.unantes.software.construction; +import java.time.LocalTime; + public class WithdrawOperation extends Operation { /** * calls the super constructor with the amount */ - public WithdrawOperation(float amount, int i) { + public WithdrawOperation(float amount, LocalTime i) { super(amount, i); } @@ -14,7 +16,7 @@ public class WithdrawOperation extends Operation { * returns "Withdraw" */ public String getOperationType() { - return "Withdraw"; + return "Withdraw"; } } -- GitLab From 070a8222eea59f53215ab0570d9a60911917f663 Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Tue, 31 Mar 2020 14:05:34 +0200 Subject: [PATCH 03/35] Test --- .../OperationTest.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/Test/java/fr.unantes.software.construction/OperationTest.java diff --git a/src/Test/java/fr.unantes.software.construction/OperationTest.java b/src/Test/java/fr.unantes.software.construction/OperationTest.java new file mode 100644 index 00000000..ed8a1045 --- /dev/null +++ b/src/Test/java/fr.unantes.software.construction/OperationTest.java @@ -0,0 +1,40 @@ +package fr.unantes.software.construction; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; +import java.time.LocalTime; + +public class OperationTest { + + private Operation operation; + + @SuppressWarnings("static-access") + @Test + public void DepositOperation() throws Exception { + LocalTime time = LocalTime.now(); + operation = new DepositOperation((float) 10.5,time); + assertEquals("Deposit",operation.getOperationType()); + assertEquals(10.5, operation.getAmount(),0.5); + assertEquals(time,operation.getTime()); + operation.setAmount((float)13.5); + assertEquals(13.5, operation.getAmount(),0.5); + Account testAccount = new Account(new Client("test","private"),2,2,1,"private"); + operation.set_account(testAccount); + assertEquals(testAccount,operation.account); + } + + @SuppressWarnings("static-access") + @Test + public void WithdrawOperation() throws Exception { + LocalTime time = LocalTime.now(); + operation = new WithdrawOperation((float) 10.5,time); + assertEquals("Withdraw",operation.getOperationType()); + assertEquals(10.5, operation.getAmount(),0.5); + assertEquals(time,operation.getTime()); + operation.setAmount((float)12.5); + assertEquals(12.5, operation.getAmount(),0.5); + Account testAccount = new Account(new Client("test","private"),2,2,1,"private"); + operation.set_account(testAccount); + assertEquals(testAccount,operation.account); + } +} -- GitLab From 6368019904baa5a942d76df12626a6ff2e8f7d30 Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Tue, 31 Mar 2020 18:05:09 +0200 Subject: [PATCH 04/35] Reference AccountClientTest --- .../fr.unantes.software.construction/AccountClientTest.java | 4 ++++ .../java/fr.unantes.software.construction/AccountTest.java | 4 ++++ .../java/fr.unantes.software.construction/ClientTest.java | 4 ++++ 3 files changed, 12 insertions(+) create mode 100644 src/Test/java/fr.unantes.software.construction/AccountClientTest.java create mode 100644 src/Test/java/fr.unantes.software.construction/AccountTest.java create mode 100644 src/Test/java/fr.unantes.software.construction/ClientTest.java diff --git a/src/Test/java/fr.unantes.software.construction/AccountClientTest.java b/src/Test/java/fr.unantes.software.construction/AccountClientTest.java new file mode 100644 index 00000000..a350e036 --- /dev/null +++ b/src/Test/java/fr.unantes.software.construction/AccountClientTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction; + +public class AccountClientTest { +} diff --git a/src/Test/java/fr.unantes.software.construction/AccountTest.java b/src/Test/java/fr.unantes.software.construction/AccountTest.java new file mode 100644 index 00000000..17a7c441 --- /dev/null +++ b/src/Test/java/fr.unantes.software.construction/AccountTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction; + +public class AccountTest { +} diff --git a/src/Test/java/fr.unantes.software.construction/ClientTest.java b/src/Test/java/fr.unantes.software.construction/ClientTest.java new file mode 100644 index 00000000..5ca88a7d --- /dev/null +++ b/src/Test/java/fr.unantes.software.construction/ClientTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction; + +public class ClientTest { +} -- GitLab From af37532664f6566c72ab383cc2144e23304bace3 Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Tue, 31 Mar 2020 20:07:45 +0200 Subject: [PATCH 05/35] AccountOperationReference + Test --- .../AccountClientTest.java | 63 ++++++++++ .../AccountOperationTest.java | 44 +++++++ .../AccountTest.java | 6 + .../OperationTest.java | 8 +- .../software/construction/Account.java | 117 +++++++++++++++--- .../unantes/software/construction/Bank.java | 7 +- .../unantes/software/construction/Client.java | 91 ++++++-------- .../software/construction/Operation.java | 42 ++++++- 8 files changed, 300 insertions(+), 78 deletions(-) create mode 100644 src/Test/java/fr.unantes.software.construction/AccountOperationTest.java diff --git a/src/Test/java/fr.unantes.software.construction/AccountClientTest.java b/src/Test/java/fr.unantes.software.construction/AccountClientTest.java index a350e036..3f727f61 100644 --- a/src/Test/java/fr.unantes.software.construction/AccountClientTest.java +++ b/src/Test/java/fr.unantes.software.construction/AccountClientTest.java @@ -1,4 +1,67 @@ package fr.unantes.software.construction; +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; + +import java.io.InvalidClassException; + public class AccountClientTest { + private Account account; + private Account account2; + private Client client; + private Client client2; + + @SuppressWarnings("static-access") + @Test + public void ClientToAccount() throws InvalidClassException { + client.addAccounts(account); + assertEquals(1,client.accountsSize()); + assertEquals(1,account.clientsSize()); + assertTrue(client.containsAccounts(account)); + client.addAccounts(account2); + assertEquals(2,client.accountsSize()); + assertEquals(1,account.clientsSize()); + assertEquals(1,account2.clientsSize()); + assertTrue(client.containsAccounts(account)); + assertTrue(client.containsAccounts(account2)); + client.removeAccounts(account2); + assertEquals(1,client.accountsSize()); + assertTrue(client.containsAccounts(account)); + assertFalse(client.containsAccounts(account2)); + assertFalse(client.isAccountsEmpty()); + client.clearAccounts(); + assertTrue(client.isAccountsEmpty()); + } + + @SuppressWarnings("static-access") + @Test + public void AccountToClient() throws InvalidClassException { + account.addClients(client); + assertEquals(1,account.clientsSize()); + assertEquals(1,client.accountsSize()); + assertTrue(account.containsClients(client)); + account.addClients(client2); + assertEquals(2,account.clientsSize()); + assertEquals(1,client.accountsSize()); + assertEquals(1,client2.accountsSize()); + assertTrue(account.containsClients(client)); + assertTrue(account.containsClients(client2)); + account.removeClients(client2); + assertEquals(1,account.clientsSize()); + assertTrue(account.containsClients(client)); + assertFalse(account.containsClients(client2)); + assertFalse(account.isClientsEmpty()); + account.clearClients(); + assertTrue(account.isClientsEmpty()); + } + + @Before +public void initBeforeTest() throws InvalidClassException { + account = new Account(client,1,1,1,"private"); + account2 = new Account(client,0,0,0,"private"); + client = new Client("test1","private"); + client2 = new Client("test2","private"); + } } diff --git a/src/Test/java/fr.unantes.software.construction/AccountOperationTest.java b/src/Test/java/fr.unantes.software.construction/AccountOperationTest.java new file mode 100644 index 00000000..6957e192 --- /dev/null +++ b/src/Test/java/fr.unantes.software.construction/AccountOperationTest.java @@ -0,0 +1,44 @@ +package fr.unantes.software.construction; + +import org.junit.Before; +import org.junit.Test; + +import java.io.InvalidClassException; +import java.time.LocalTime; + +import static org.junit.Assert.*; + +public class AccountOperationTest { + private Account account; + private Operation operation1; + private Operation operation2; + + @SuppressWarnings("static-access") + @Test + public void OperationToAccount() { + operation1.setAccount(account); + assertEquals(operation1.getAccount(),account); + assertTrue(account.containsOperation(operation1)); + operation1.removeAccount(); + assertNotEquals(operation1.getAccount(),account); + assertFalse(account.containsOperation(operation1)); + } + + @SuppressWarnings("static-access") + @Test + public void AccountToOperation() throws InvalidClassException { + account.addOperation(operation1); + assertTrue(account.containsOperation(operation1)); + assertEquals(operation1.getAccount(),account); + account.addOperation(operation2); + assertTrue(account.containsOperation(operation2)); + assertEquals(operation2.getAccount(),account); + } + + @Before + public void initBeforeTest() throws InvalidClassException { + account = new Account(new Client("test","private"),1,1,1,"private"); + operation1 = new DepositOperation(0,LocalTime.now()); + operation2 = new WithdrawOperation(10, LocalTime.now()); + } +} diff --git a/src/Test/java/fr.unantes.software.construction/AccountTest.java b/src/Test/java/fr.unantes.software.construction/AccountTest.java index 17a7c441..f90c9979 100644 --- a/src/Test/java/fr.unantes.software.construction/AccountTest.java +++ b/src/Test/java/fr.unantes.software.construction/AccountTest.java @@ -1,4 +1,10 @@ package fr.unantes.software.construction; +import static org.junit.Assert.assertEquals; +import org.junit.Test; + public class AccountTest { + private Account account; + + } diff --git a/src/Test/java/fr.unantes.software.construction/OperationTest.java b/src/Test/java/fr.unantes.software.construction/OperationTest.java index ed8a1045..ccb5597b 100644 --- a/src/Test/java/fr.unantes.software.construction/OperationTest.java +++ b/src/Test/java/fr.unantes.software.construction/OperationTest.java @@ -19,8 +19,8 @@ public class OperationTest { operation.setAmount((float)13.5); assertEquals(13.5, operation.getAmount(),0.5); Account testAccount = new Account(new Client("test","private"),2,2,1,"private"); - operation.set_account(testAccount); - assertEquals(testAccount,operation.account); + operation.setAccount(testAccount); + assertEquals(testAccount,operation.getAccount()); } @SuppressWarnings("static-access") @@ -34,7 +34,7 @@ public class OperationTest { operation.setAmount((float)12.5); assertEquals(12.5, operation.getAmount(),0.5); Account testAccount = new Account(new Client("test","private"),2,2,1,"private"); - operation.set_account(testAccount); - assertEquals(testAccount,operation.account); + operation.setAccount(testAccount); + assertEquals(testAccount,operation.getAccount()); } } diff --git a/src/main/java/fr/unantes/software/construction/Account.java b/src/main/java/fr/unantes/software/construction/Account.java index 5c5dab10..2682bb44 100755 --- a/src/main/java/fr/unantes/software/construction/Account.java +++ b/src/main/java/fr/unantes/software/construction/Account.java @@ -8,9 +8,9 @@ import java.util.Vector; import java.util.Iterator; public class Account { - public Vector Operation; + public OperationReference operation; public String type; - public ClientReference cref; + public ClientReference clients; /** * Initializes the owner, amount, overdraft and the account number with parameters @@ -21,12 +21,12 @@ public class Account { this.balance = amount; this.history = new Vector(); this.number = n; - Operation = new Vector(); + operation = new OperationReference(); this.type = type; if (!type.equals("private") && !type.equals("company")) { throw new InvalidClassException("Invalid type supplied. An account can only be private or company"); } - cref = new ClientReference(); + clients = new ClientReference(); } /** @@ -265,30 +265,23 @@ public class Account { this.owner = owner; } - public void addOperation(Operation o) { - Operation.add(o); - try { - o.set_account((Account)this.clone()); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - } + + public class ClientReference { private ArrayList clients; - public ClientReference(){ clients = new ArrayList(); } public void add(Client c){ basicAdd(c); - c.aref.basicAdd(Account.this); + c.account.basicAdd(Account.this); } public void remove(Client c){ basicRemove(c); - c.aref.basicRemove(Account.this); + c.account.basicRemove(Account.this); } public void basicAdd(Client c){ @@ -300,5 +293,97 @@ public class Account { } } -} + /** + * @uml.property name="accounts" + */ + public ArrayList getClients() { + return clients.clients; + } + + /** + * @uml.property name="accounts" + */ + public void addClients(Client element) { + clients.add(element); + } + + /** + * @uml.property name="accounts" + */ + public void removeClients(Client element) { + clients.remove(element); + } + + /** + * @uml.property name="accounts" + */ + public boolean isClientsEmpty() { + if (clients.clients.size() == 0) { + return true; + } else { + return false; + } + } + + /** + * @uml.property name="accounts" + */ + public void clearClients() { + clients.clients.clear(); + } + + /** + * @uml.property name="accounts" + */ + public boolean containsClients(Client element) { + return clients.clients.contains(element); + } + + /** + * @uml.property name="accounts" + */ + public int clientsSize() { + return clients.clients.size(); + } + + + + + public class OperationReference { + private ArrayList operations; + public OperationReference(){ + operations = new ArrayList(); + } + + public void add(Operation o){ + basicAdd(o); + o.account.basicSet(Account.this); + } + + public void remove(Operation o){ + basicRemove(o); + o.account.basicUnSet(); + } + + public void basicAdd(Operation o){ + operations.add(o); + } + + public void basicRemove(Operation o){ + operations.remove(o); + } + } + + public void addOperation(Operation o) { + operation.add(o); + } + + public boolean containsOperation(Operation o){ + return operation.operations.contains(o); + } + + public ArrayList getOperations() { + return operation.operations; + } +} \ No newline at end of file diff --git a/src/main/java/fr/unantes/software/construction/Bank.java b/src/main/java/fr/unantes/software/construction/Bank.java index 8a30e6a3..05a816c1 100755 --- a/src/main/java/fr/unantes/software/construction/Bank.java +++ b/src/main/java/fr/unantes/software/construction/Bank.java @@ -3,6 +3,7 @@ package fr.unantes.software.construction; import fr.unantes.software.construction.address.AddressBook; import java.io.InvalidClassException; +import java.util.ArrayList; import java.util.Iterator; import java.util.Vector; @@ -171,7 +172,11 @@ public class Bank { public void closeAccount(int accountNumber) throws Exception { Account a=getAccount(accountNumber); if (a!=null){ - a.owner.removeAccounts(a); + ArrayList tmp = a.getClients(); + for(int i = 0; i < a.clientsSize(); i++){ + a.removeClients(tmp.get(i)); + + } this.removeAccounts(a); } else{ diff --git a/src/main/java/fr/unantes/software/construction/Client.java b/src/main/java/fr/unantes/software/construction/Client.java index 1f73577f..051e1d29 100644 --- a/src/main/java/fr/unantes/software/construction/Client.java +++ b/src/main/java/fr/unantes/software/construction/Client.java @@ -16,10 +16,8 @@ public class Client { */ public String name; public String role; - public Account[] accounts; - short account_size = 0; public Card card; - public AccountReference aref; + public AccountReference account; public Client(String name, String role) throws InvalidClassException { @@ -29,7 +27,7 @@ public class Client { this.name = name; this.role = role; - accounts = new Account[100]; + account = new AccountReference(); } public String getName() { @@ -51,42 +49,47 @@ public class Client { this.role = role; } - /** - * @uml.property name="accounts" - */ - public Account[] getAccounts() { - return accounts; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Client person = (Client) o; + if (getRole().equals(person.getRole()) && role.equals("agent")) { + return getName().equals(person.getName()) && card == person.card; + } + return getName().equals(person.getName()) && getRole().equals(person.getRole()); + } + + public int hashCode() { + return getName().hashCode() + getRole().hashCode() + card.hashCode(); + } /** * @uml.property name="accounts" */ - public void setAccounts(Account[] value) { - accounts = value; + public ArrayList getAccounts() { + return account.account; } /** * @uml.property name="accounts" */ public void addAccounts(Account element) { - accounts[account_size++] = element; + account.add(element); } /** * @uml.property name="accounts" */ - public boolean removeAccounts(Account element) { - for (int i = 0; i < account_size ; i++) { - if (element == accounts [i]) accounts[i] = null; - } - return true; + public void removeAccounts(Account element) { + account.remove(element); } /** * @uml.property name="accounts" */ public boolean isAccountsEmpty() { - if (account_size == 0) { + if (account.account.size() == 0) { return true; } else { return false; @@ -97,69 +100,49 @@ public class Client { * @uml.property name="accounts" */ public void clearAccounts() { - account_size = 0; + account.account.clear(); } /** * @uml.property name="accounts" */ public boolean containsAccounts(Account element) { - for (int i = 0; i < account_size; i++) { - if (accounts[account_size] == element) return true; - } - return false; + return account.account.contains(element); } - /** * @uml.property name="accounts" */ public int accountsSize() { - return accounts.length; + return account.account.size(); } - /** - * @uml.property name="accounts" - */ - public Account[] accountsToArray() { - return accounts; - } - - - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Client person = (Client) o; - if (getRole().equals(person.getRole()) && role.equals("agent")) { - return getName().equals(person.getName()) && card == person.card; - } - return getName().equals(person.getName()) && getRole().equals(person.getRole()); - } - - public int hashCode() { - return getName().hashCode() + getRole().hashCode() + card.hashCode(); - + public Account[] accountsToArray(){ + return (Account[]) account.account.toArray(); } public class AccountReference { private ArrayList account; - public void add(Account a){ - basicAdd(a); - a.cref.basicAdd(Client.this); + public AccountReference(){ + account = new ArrayList(); } - public void basicAdd(Account a) { - account.add(a); + public void add(Account a){ + basicAdd(a); + a.clients.basicAdd(Client.this); } public void remove(Account a){ basicRemove(a); - a.cref.basicRemove(Client.this); + a.clients.basicRemove(Client.this); + } + + public void basicAdd(Account a) { + account.add(a); } public void basicRemove(Account a) { account.remove(a); } } -} - +} \ No newline at end of file diff --git a/src/main/java/fr/unantes/software/construction/Operation.java b/src/main/java/fr/unantes/software/construction/Operation.java index df6c57de..6ad1ef6a 100755 --- a/src/main/java/fr/unantes/software/construction/Operation.java +++ b/src/main/java/fr/unantes/software/construction/Operation.java @@ -4,7 +4,7 @@ import java.time.*; public abstract class Operation { - public Account account; + public AccountReference account; private LocalTime time; /** @@ -34,6 +34,7 @@ public abstract class Operation { public Operation(float amount, LocalTime i) { this.amount = amount; this.time = i; + account = new AccountReference(); } /** @@ -41,8 +42,43 @@ public abstract class Operation { */ public abstract String getOperationType(); - public void set_account(Account xyz) { - account = xyz; + + + + public class AccountReference { + private Account acc; + public AccountReference(){ + acc = null; + } + + public void set(Account a){ + basicSet(a); + a.operation.basicAdd(Operation.this); + } + + public void unSet(){ + acc.operation.basicRemove(Operation.this); + basicUnSet(); + } + + public void basicSet(Account a) { + acc = a; + } + + public void basicUnSet() { + acc = null; + } + } + + public void setAccount(Account a) { + account.set(a); } + public Account getAccount() { + return account.acc; + } + + public void removeAccount() { + account.unSet(); + } } -- GitLab From b395e92c7a0cdab8378ce2b9edb752a82b17959e Mon Sep 17 00:00:00 2001 From: Curtis Meda Date: Tue, 31 Mar 2020 21:16:33 +0200 Subject: [PATCH 06/35] Client - Particulier & Entreprise --- .../java/fr/unantes/software/construction/Entreprise.java | 4 ++++ .../java/fr/unantes/software/construction/Particulier.java | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 src/main/java/fr/unantes/software/construction/Entreprise.java create mode 100644 src/main/java/fr/unantes/software/construction/Particulier.java diff --git a/src/main/java/fr/unantes/software/construction/Entreprise.java b/src/main/java/fr/unantes/software/construction/Entreprise.java new file mode 100644 index 00000000..e806c1f4 --- /dev/null +++ b/src/main/java/fr/unantes/software/construction/Entreprise.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction; + +public class Entreprise { +} diff --git a/src/main/java/fr/unantes/software/construction/Particulier.java b/src/main/java/fr/unantes/software/construction/Particulier.java new file mode 100644 index 00000000..d88c1835 --- /dev/null +++ b/src/main/java/fr/unantes/software/construction/Particulier.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction; + +public class Particulier { +} -- GitLab From 73730209d71b117cd18b4371858ea39a665eada6 Mon Sep 17 00:00:00 2001 From: Curtis Meda Date: Tue, 31 Mar 2020 21:26:51 +0200 Subject: [PATCH 07/35] Client - Particulier & Entreprise --- pom.xml | 4 ++++ .../unantes/software/construction/Client.java | 4 ++-- .../software/construction/Entreprise.java | 19 +++++++++++++++++- .../software/construction/Particulier.java | 20 ++++++++++++++++++- 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 4907c460..93bdc6f8 100644 --- a/pom.xml +++ b/pom.xml @@ -22,6 +22,10 @@ org.apache.maven.plugins maven-compiler-plugin 3.7.0 + + 8 + 8 + diff --git a/src/main/java/fr/unantes/software/construction/Client.java b/src/main/java/fr/unantes/software/construction/Client.java index 051e1d29..a15291be 100644 --- a/src/main/java/fr/unantes/software/construction/Client.java +++ b/src/main/java/fr/unantes/software/construction/Client.java @@ -9,10 +9,10 @@ import java.util.Collection; import java.util.Iterator; import java.util.Vector; -public class Client { +public abstract class Client { /** - * The name of the person + * The name of the client */ public String name; public String role; diff --git a/src/main/java/fr/unantes/software/construction/Entreprise.java b/src/main/java/fr/unantes/software/construction/Entreprise.java index e806c1f4..caa8719d 100644 --- a/src/main/java/fr/unantes/software/construction/Entreprise.java +++ b/src/main/java/fr/unantes/software/construction/Entreprise.java @@ -1,4 +1,21 @@ package fr.unantes.software.construction; -public class Entreprise { +import java.io.InvalidClassException; + +public class Entreprise extends Client { + + /** + * Attributes + */ + private String addressEntreprise; + + public Entreprise(String name, String role, String address ) throws InvalidClassException { + super(name, role); + addressEntreprise =address; + } + + public String getAddressEntreprise() { return addressEntreprise; } + + public void setAddressEntreprise(String address) { this.addressEntreprise = address; } + } diff --git a/src/main/java/fr/unantes/software/construction/Particulier.java b/src/main/java/fr/unantes/software/construction/Particulier.java index d88c1835..a4ea7eed 100644 --- a/src/main/java/fr/unantes/software/construction/Particulier.java +++ b/src/main/java/fr/unantes/software/construction/Particulier.java @@ -1,4 +1,22 @@ package fr.unantes.software.construction; -public class Particulier { +import java.io.InvalidClassException; + +public class Particulier extends Client { + + /** + * Attributes + */ + private String addressParticular; + + public Particulier(String name, String role,String address) throws InvalidClassException { + super(name,role); + addressParticular = address; + } + + public String getAddressParticular() { return addressParticular; } + + public void setAddressParticular(String address) { this.addressParticular = address; } + + } -- GitLab From 0c2b8a4b4ec8b2fbf8c49e490d9a18413236b8c4 Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Tue, 31 Mar 2020 22:13:35 +0200 Subject: [PATCH 08/35] ClienCardReference + Test --- pom.xml | 6 ++ .../AccountClientTest.java | 7 +- .../AccountOperationTest.java | 3 +- .../ClientCardTest.java | 55 +++++++++++++ .../OperationTest.java | 6 +- .../unantes/software/construction/Client.java | 77 +++++++++++++++---- .../software/construction/Entreprise.java | 19 +++-- .../software/construction/Particulier.java | 18 ++++- .../software/construction/address/Card.java | 45 ++++++++++- .../construction/address/CompanyCard.java | 10 +++ .../construction/address/PrivateCard.java | 9 +++ 11 files changed, 225 insertions(+), 30 deletions(-) create mode 100644 src/Test/java/fr.unantes.software.construction/ClientCardTest.java diff --git a/pom.xml b/pom.xml index 93bdc6f8..35648905 100644 --- a/pom.xml +++ b/pom.xml @@ -84,6 +84,12 @@ javafx-controls 13 + + junit + junit + RELEASE + test + diff --git a/src/Test/java/fr.unantes.software.construction/AccountClientTest.java b/src/Test/java/fr.unantes.software.construction/AccountClientTest.java index 3f727f61..e404898f 100644 --- a/src/Test/java/fr.unantes.software.construction/AccountClientTest.java +++ b/src/Test/java/fr.unantes.software.construction/AccountClientTest.java @@ -2,6 +2,9 @@ package fr.unantes.software.construction; import static org.junit.Assert.*; +import fr.unantes.software.construction.address.Address; +import fr.unantes.software.construction.address.CompanyAddress; +import fr.unantes.software.construction.address.PrivateAddress; import org.junit.Before; import org.junit.Test; @@ -61,7 +64,7 @@ public class AccountClientTest { public void initBeforeTest() throws InvalidClassException { account = new Account(client,1,1,1,"private"); account2 = new Account(client,0,0,0,"private"); - client = new Client("test1","private"); - client2 = new Client("test2","private"); + client = new Entreprise("test1","company", new CompanyAddress()); + client2 = new Particulier("test2","private", new PrivateAddress()); } } diff --git a/src/Test/java/fr.unantes.software.construction/AccountOperationTest.java b/src/Test/java/fr.unantes.software.construction/AccountOperationTest.java index 6957e192..c992cb43 100644 --- a/src/Test/java/fr.unantes.software.construction/AccountOperationTest.java +++ b/src/Test/java/fr.unantes.software.construction/AccountOperationTest.java @@ -1,5 +1,6 @@ package fr.unantes.software.construction; +import fr.unantes.software.construction.address.PrivateAddress; import org.junit.Before; import org.junit.Test; @@ -37,7 +38,7 @@ public class AccountOperationTest { @Before public void initBeforeTest() throws InvalidClassException { - account = new Account(new Client("test","private"),1,1,1,"private"); + account = new Account(new Particulier("test","private", new PrivateAddress()),1,1,1,"private"); operation1 = new DepositOperation(0,LocalTime.now()); operation2 = new WithdrawOperation(10, LocalTime.now()); } diff --git a/src/Test/java/fr.unantes.software.construction/ClientCardTest.java b/src/Test/java/fr.unantes.software.construction/ClientCardTest.java new file mode 100644 index 00000000..d08c4aa2 --- /dev/null +++ b/src/Test/java/fr.unantes.software.construction/ClientCardTest.java @@ -0,0 +1,55 @@ +package fr.unantes.software.construction; + +import fr.unantes.software.construction.address.*; +import org.junit.Before; +import org.junit.Test; + +import java.io.InvalidClassException; + +import static org.junit.Assert.*; + +public class ClientCardTest { + private Client client1; + private Client client2; + private Card card1; + private Card card2; + + @SuppressWarnings("static-access") + @Test + public void ClientToCard() { + client1.setCard(card2); + assertNotEquals(client1.getCard(),card2); + client1.setCard(card1); + assertEquals(client1.getCard(),card1); + client1.unSetCard(); + assertNotEquals(client1.getCard(),card1); + + client2.setCard(card1); + assertNotEquals(client2.getCard(),card1); + client2.setCard(card2); + assertEquals(client2.getCard(),card2); + } + + @SuppressWarnings("static-access") + @Test + public void CardToClient() { + card1.setClient(client2); + assertNotEquals(card1.getClient(),client2); + card1.setClient(client1); + assertEquals(card1.getClient(),client1); + card1.unSetClient(); + assertNotEquals(card1.getClient(),client1); + card2.setClient(client1); + assertNotEquals(card2.getClient(),client1); + card2.setClient(client2); + assertEquals(card2.getClient(),client2); + } + + @Before + public void initBeforeTest() throws InvalidClassException { + card1 = new CompanyCard("Company"); + card2 = new PrivateCard("test","private"); + client1 = new Entreprise("test1","company", new CompanyAddress()); + client2 = new Particulier("test2","private", new PrivateAddress()); + } +} diff --git a/src/Test/java/fr.unantes.software.construction/OperationTest.java b/src/Test/java/fr.unantes.software.construction/OperationTest.java index ccb5597b..1ba15dd4 100644 --- a/src/Test/java/fr.unantes.software.construction/OperationTest.java +++ b/src/Test/java/fr.unantes.software.construction/OperationTest.java @@ -1,6 +1,8 @@ package fr.unantes.software.construction; import static org.junit.Assert.assertEquals; + +import fr.unantes.software.construction.address.PrivateAddress; import org.junit.Test; import java.time.LocalTime; @@ -18,7 +20,7 @@ public class OperationTest { assertEquals(time,operation.getTime()); operation.setAmount((float)13.5); assertEquals(13.5, operation.getAmount(),0.5); - Account testAccount = new Account(new Client("test","private"),2,2,1,"private"); + Account testAccount = new Account(new Particulier("test","private", new PrivateAddress()),2,2,1,"private"); operation.setAccount(testAccount); assertEquals(testAccount,operation.getAccount()); } @@ -33,7 +35,7 @@ public class OperationTest { assertEquals(time,operation.getTime()); operation.setAmount((float)12.5); assertEquals(12.5, operation.getAmount(),0.5); - Account testAccount = new Account(new Client("test","private"),2,2,1,"private"); + Account testAccount = new Account(new Particulier("test","private", new PrivateAddress()),2,2,1,"private"); operation.setAccount(testAccount); assertEquals(testAccount,operation.getAccount()); } diff --git a/src/main/java/fr/unantes/software/construction/Client.java b/src/main/java/fr/unantes/software/construction/Client.java index a15291be..f2c27326 100644 --- a/src/main/java/fr/unantes/software/construction/Client.java +++ b/src/main/java/fr/unantes/software/construction/Client.java @@ -16,7 +16,7 @@ public abstract class Client { */ public String name; public String role; - public Card card; + public CardReference card; public AccountReference account; @@ -28,6 +28,7 @@ public abstract class Client { this.name = name; this.role = role; account = new AccountReference(); + card = new CardReference(); } public String getName() { @@ -64,6 +65,36 @@ public abstract class Client { } + + + + + + public class AccountReference { + private ArrayList account; + public AccountReference(){ + account = new ArrayList(); + } + + public void add(Account a){ + basicAdd(a); + a.clients.basicAdd(Client.this); + } + + public void remove(Account a){ + basicRemove(a); + a.clients.basicRemove(Client.this); + } + + public void basicAdd(Account a) { + account.add(a); + } + + public void basicRemove(Account a) { + account.remove(a); + } + } + /** * @uml.property name="accounts" */ @@ -121,28 +152,44 @@ public abstract class Client { return (Account[]) account.account.toArray(); } - public class AccountReference { - private ArrayList account; - public AccountReference(){ - account = new ArrayList(); + + + + + public class CardReference { + private Card car; + public CardReference(){ + car = null; } - public void add(Account a){ - basicAdd(a); - a.clients.basicAdd(Client.this); + public void set(Card c){ + basicSet(c); + c.client.basicSet(Client.this); } - public void remove(Account a){ - basicRemove(a); - a.clients.basicRemove(Client.this); + public void unSet(){ + car.client.basicUnSet(); + basicUnSet(); } - public void basicAdd(Account a) { - account.add(a); + public void basicSet(Card c){ + this.car = c; } - public void basicRemove(Account a) { - account.remove(a); + public void basicUnSet(){ + this.car = null; } } + + public void setCard(Card c){ + card.set(c); + } + + public Card getCard(){ + return card.car; + } + + public void unSetCard(){ + card.unSet(); + } } \ No newline at end of file diff --git a/src/main/java/fr/unantes/software/construction/Entreprise.java b/src/main/java/fr/unantes/software/construction/Entreprise.java index caa8719d..dd1d46e4 100644 --- a/src/main/java/fr/unantes/software/construction/Entreprise.java +++ b/src/main/java/fr/unantes/software/construction/Entreprise.java @@ -1,5 +1,9 @@ package fr.unantes.software.construction; +import fr.unantes.software.construction.address.Card; +import fr.unantes.software.construction.address.CompanyAddress; +import fr.unantes.software.construction.address.CompanyCard; + import java.io.InvalidClassException; public class Entreprise extends Client { @@ -7,15 +11,20 @@ public class Entreprise extends Client { /** * Attributes */ - private String addressEntreprise; + private CompanyAddress addressEntreprise; - public Entreprise(String name, String role, String address ) throws InvalidClassException { + public Entreprise(String name, String role, CompanyAddress address ) throws InvalidClassException { super(name, role); - addressEntreprise =address; + addressEntreprise = address; } - public String getAddressEntreprise() { return addressEntreprise; } + public CompanyAddress getAddressEntreprise() { return addressEntreprise; } - public void setAddressEntreprise(String address) { this.addressEntreprise = address; } + public void setAddressEntreprise(CompanyAddress address) { this.addressEntreprise = address; } + public void setCard(Card c){ + if(c.getClass().equals(CompanyCard.class)){ + card.set(c); + } + } } diff --git a/src/main/java/fr/unantes/software/construction/Particulier.java b/src/main/java/fr/unantes/software/construction/Particulier.java index a4ea7eed..e0383599 100644 --- a/src/main/java/fr/unantes/software/construction/Particulier.java +++ b/src/main/java/fr/unantes/software/construction/Particulier.java @@ -1,5 +1,9 @@ package fr.unantes.software.construction; +import fr.unantes.software.construction.address.Card; +import fr.unantes.software.construction.address.PrivateAddress; +import fr.unantes.software.construction.address.PrivateCard; + import java.io.InvalidClassException; public class Particulier extends Client { @@ -7,16 +11,22 @@ public class Particulier extends Client { /** * Attributes */ - private String addressParticular; + private PrivateAddress addressParticular; - public Particulier(String name, String role,String address) throws InvalidClassException { + public Particulier(String name, String role, PrivateAddress address) throws InvalidClassException { super(name,role); addressParticular = address; } - public String getAddressParticular() { return addressParticular; } + public PrivateAddress getAddressParticular() { return addressParticular; } + + public void setAddressParticular(PrivateAddress address) { this.addressParticular = address; } - public void setAddressParticular(String address) { this.addressParticular = address; } + public void setCard(Card c){ + if(c.getClass().equals(PrivateCard.class)){ + card.set(c); + } + } } diff --git a/src/main/java/fr/unantes/software/construction/address/Card.java b/src/main/java/fr/unantes/software/construction/address/Card.java index 7309bf87..d4ac5b8c 100755 --- a/src/main/java/fr/unantes/software/construction/address/Card.java +++ b/src/main/java/fr/unantes/software/construction/address/Card.java @@ -15,13 +15,14 @@ public abstract class Card { protected AddressList _ad = new AddressList(); protected PhoneList _tel= new PhoneList(); protected MailList _mail = new MailList(); - public Client client; + public ClientReference client; /** * Constructeur sans parametres */ public Card(String nom) { identification = nom; + client = new ClientReference(); } @@ -119,4 +120,46 @@ public abstract class Card { } return false; } + + + + + + + public class ClientReference { + private Client client; + public ClientReference(){ + client = null; + } + + public void set(Client c){ + basicSet(c); + c.card.basicSet(Card.this); + } + + public void unSet(){ + client.card.basicUnSet(); + basicUnSet(); + } + + public void basicSet(Client c){ + client = c; + } + + public void basicUnSet(){ + client = null; + } + } + + public void setClient(Client c){ + client.set(c); + } + + public Client getClient(){ + return client.client; + } + + public void unSetClient(){ + client.unSet(); + } } diff --git a/src/main/java/fr/unantes/software/construction/address/CompanyCard.java b/src/main/java/fr/unantes/software/construction/address/CompanyCard.java index 8e838e3b..581dfd39 100755 --- a/src/main/java/fr/unantes/software/construction/address/CompanyCard.java +++ b/src/main/java/fr/unantes/software/construction/address/CompanyCard.java @@ -1,5 +1,8 @@ package fr.unantes.software.construction.address; +import fr.unantes.software.construction.Client; +import fr.unantes.software.construction.Entreprise; + public class CompanyCard extends Card { protected String _raison_social; @@ -51,4 +54,11 @@ public class CompanyCard extends Card { return ("" + identification + _raison_social + _ad.toXML() + _tel.toXML() + _mail.toXML() + _grp.toXML() + ""); } + + public void setClient(Client c){ + if(c.getClass().equals(Entreprise.class)){ + client.set(c); + } + } + } diff --git a/src/main/java/fr/unantes/software/construction/address/PrivateCard.java b/src/main/java/fr/unantes/software/construction/address/PrivateCard.java index 443209fc..8d9fec26 100755 --- a/src/main/java/fr/unantes/software/construction/address/PrivateCard.java +++ b/src/main/java/fr/unantes/software/construction/address/PrivateCard.java @@ -1,5 +1,8 @@ package fr.unantes.software.construction.address; +import fr.unantes.software.construction.Client; +import fr.unantes.software.construction.Particulier; + /** * @author * @version 1.0 @@ -91,4 +94,10 @@ public class PrivateCard extends Card { return ("" + identification + _nomP + _prenom + _ad.toXML() + _tel.toXML() + _mail.toXML() + _grp.toXML() + ""); } + + public void setClient(Client c){ + if(c.getClass().equals(Particulier.class)){ + client.set(c); + } + } } -- GitLab From 2b870a3b917659a6a1747899982c4d0118dfb1e2 Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Wed, 1 Apr 2020 00:59:09 +0200 Subject: [PATCH 09/35] Encapsulation 1 --- .../software/construction}/AccountTest.java | 1 - .../Association/CardToGroupTest.java | 4 + .../software/construction}/ClientTest.java | 3 +- .../software/construction}/OperationTest.java | 0 .../AccountClientTest.java | 9 +- .../AccountOperationTest.java | 3 +- .../ClientCardTest.java | 5 +- .../software/construction/Account.java | 114 +++++++----------- .../unantes/software/construction/Bank.java | 54 +++++---- .../unantes/software/construction/Client.java | 20 +-- .../software/construction/Entreprise.java | 2 +- .../software/construction/Operation.java | 10 +- .../software/construction/Particulier.java | 2 +- .../software/construction/ReferenceUniDi.java | 22 ++++ .../software/construction/address/Card.java | 2 +- 15 files changed, 133 insertions(+), 118 deletions(-) rename src/Test/java/{fr.unantes.software.construction => fr/unantes/software/construction}/AccountTest.java (86%) create mode 100644 src/Test/java/fr/unantes/software/construction/Association/CardToGroupTest.java rename src/Test/java/{fr.unantes.software.construction => fr/unantes/software/construction}/ClientTest.java (97%) rename src/Test/java/{fr.unantes.software.construction => fr/unantes/software/construction}/OperationTest.java (100%) rename src/Test/java/{fr.unantes.software.construction => fr/unantes/software/construction/bidirectionalAssociation}/AccountClientTest.java (88%) rename src/Test/java/{fr.unantes.software.construction => fr/unantes/software/construction/bidirectionalAssociation}/AccountOperationTest.java (93%) rename src/Test/java/{fr.unantes.software.construction => fr/unantes/software/construction/bidirectionalAssociation}/ClientCardTest.java (88%) create mode 100644 src/main/java/fr/unantes/software/construction/ReferenceUniDi.java diff --git a/src/Test/java/fr.unantes.software.construction/AccountTest.java b/src/Test/java/fr/unantes/software/construction/AccountTest.java similarity index 86% rename from src/Test/java/fr.unantes.software.construction/AccountTest.java rename to src/Test/java/fr/unantes/software/construction/AccountTest.java index f90c9979..66b89fcc 100644 --- a/src/Test/java/fr.unantes.software.construction/AccountTest.java +++ b/src/Test/java/fr/unantes/software/construction/AccountTest.java @@ -1,7 +1,6 @@ package fr.unantes.software.construction; import static org.junit.Assert.assertEquals; -import org.junit.Test; public class AccountTest { private Account account; diff --git a/src/Test/java/fr/unantes/software/construction/Association/CardToGroupTest.java b/src/Test/java/fr/unantes/software/construction/Association/CardToGroupTest.java new file mode 100644 index 00000000..2622fed9 --- /dev/null +++ b/src/Test/java/fr/unantes/software/construction/Association/CardToGroupTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction.Association; + +public class CardToGroupTest { +} diff --git a/src/Test/java/fr.unantes.software.construction/ClientTest.java b/src/Test/java/fr/unantes/software/construction/ClientTest.java similarity index 97% rename from src/Test/java/fr.unantes.software.construction/ClientTest.java rename to src/Test/java/fr/unantes/software/construction/ClientTest.java index 5ca88a7d..42c0d9e8 100644 --- a/src/Test/java/fr.unantes.software.construction/ClientTest.java +++ b/src/Test/java/fr/unantes/software/construction/ClientTest.java @@ -1,4 +1,5 @@ package fr.unantes.software.construction; public class ClientTest { -} + +} \ No newline at end of file diff --git a/src/Test/java/fr.unantes.software.construction/OperationTest.java b/src/Test/java/fr/unantes/software/construction/OperationTest.java similarity index 100% rename from src/Test/java/fr.unantes.software.construction/OperationTest.java rename to src/Test/java/fr/unantes/software/construction/OperationTest.java diff --git a/src/Test/java/fr.unantes.software.construction/AccountClientTest.java b/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountClientTest.java similarity index 88% rename from src/Test/java/fr.unantes.software.construction/AccountClientTest.java rename to src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountClientTest.java index e404898f..9c6b85a9 100644 --- a/src/Test/java/fr.unantes.software.construction/AccountClientTest.java +++ b/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountClientTest.java @@ -1,8 +1,11 @@ -package fr.unantes.software.construction; +package fr.unantes.software.construction.bidirectionalAssociation; import static org.junit.Assert.*; -import fr.unantes.software.construction.address.Address; +import fr.unantes.software.construction.Account; +import fr.unantes.software.construction.Client; +import fr.unantes.software.construction.Entreprise; +import fr.unantes.software.construction.Particulier; import fr.unantes.software.construction.address.CompanyAddress; import fr.unantes.software.construction.address.PrivateAddress; import org.junit.Before; @@ -61,7 +64,7 @@ public class AccountClientTest { } @Before -public void initBeforeTest() throws InvalidClassException { + public void initBeforeTest() throws InvalidClassException { account = new Account(client,1,1,1,"private"); account2 = new Account(client,0,0,0,"private"); client = new Entreprise("test1","company", new CompanyAddress()); diff --git a/src/Test/java/fr.unantes.software.construction/AccountOperationTest.java b/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountOperationTest.java similarity index 93% rename from src/Test/java/fr.unantes.software.construction/AccountOperationTest.java rename to src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountOperationTest.java index c992cb43..5a6fa73e 100644 --- a/src/Test/java/fr.unantes.software.construction/AccountOperationTest.java +++ b/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountOperationTest.java @@ -1,5 +1,6 @@ -package fr.unantes.software.construction; +package fr.unantes.software.construction.bidirectionalAssociation; +import fr.unantes.software.construction.*; import fr.unantes.software.construction.address.PrivateAddress; import org.junit.Before; import org.junit.Test; diff --git a/src/Test/java/fr.unantes.software.construction/ClientCardTest.java b/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/ClientCardTest.java similarity index 88% rename from src/Test/java/fr.unantes.software.construction/ClientCardTest.java rename to src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/ClientCardTest.java index d08c4aa2..9715c665 100644 --- a/src/Test/java/fr.unantes.software.construction/ClientCardTest.java +++ b/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/ClientCardTest.java @@ -1,5 +1,8 @@ -package fr.unantes.software.construction; +package fr.unantes.software.construction.bidirectionalAssociation; +import fr.unantes.software.construction.Client; +import fr.unantes.software.construction.Entreprise; +import fr.unantes.software.construction.Particulier; import fr.unantes.software.construction.address.*; import org.junit.Before; import org.junit.Test; diff --git a/src/main/java/fr/unantes/software/construction/Account.java b/src/main/java/fr/unantes/software/construction/Account.java index 2682bb44..063375f9 100755 --- a/src/main/java/fr/unantes/software/construction/Account.java +++ b/src/main/java/fr/unantes/software/construction/Account.java @@ -8,16 +8,40 @@ import java.util.Vector; import java.util.Iterator; public class Account { - public OperationReference operation; - public String type; - public ClientReference clients; + private OperationReference operation; + private String type; + private ClientReference clients; + /** + * + * This attribute memorizes the current balance of the account + * + */ + private float balance; + /** + * + * this is the maximum overdraft authorized for this account + * + */ + private float overdraft; + /** + * + * @uml.property name="history" + * @uml.associationEnd inverse="compte:fr.unantes.software.construction.Operation" multiplicity="(0 -1)" + * + */ + private Collection history; + /** + * + * this is the number of the account + * + */ + private int number; /** * Initializes the owner, amount, overdraft and the account number with parameters * The method also initializes the history with a new empty Vector */ public Account(Client p, float amount, float overdraft, int n, String type) throws InvalidClassException { - this.owner = p; this.balance = amount; this.history = new Vector(); this.number = n; @@ -27,6 +51,7 @@ public class Account { throw new InvalidClassException("Invalid type supplied. An account can only be private or company"); } clients = new ClientReference(); + clients.add(p); } /** @@ -65,28 +90,6 @@ public class Account { } } - /** - * - * This attribute memorizes the current balance of the account - * - */ - private float balance; - - /** - * - * this is the maximum overdraft authorized for this account - * - */ - private float overdraft; - - /** - * - * @uml.property name="history" - * @uml.associationEnd inverse="compte:fr.unantes.software.construction.Operation" multiplicity="(0 -1)" - * - */ - private Collection history; - /** * * @uml.property name="history" @@ -176,6 +179,14 @@ public class Account { .toArray(new Operation[history.size()]); } + public String getType(){ + return type; + } + + public void setType(String t){ + type = t; + } + /** * * @uml.property name="overdraft" @@ -212,13 +223,6 @@ public class Account { this.balance = balance; } - /** - * - * this is the number of the account - * - */ - private int number; - /** * * @uml.property name="number" @@ -237,34 +241,6 @@ public class Account { this.number = number; } - /** - * - * @uml.property name="owner" - * @uml.associationEnd inverse="accounts:fr.unantes.software.construction.Client" multiplicity="(0 1)" - * - */ - public Client owner; - - /** - * - * @uml.property name="owner" - * - */ - public Client getOwner() { - return owner; - } - - /** - * - * @uml.property name="owner" - * - */ - public void setOwner(Client owner) { - if (owner.role == "private" & this.type != "private") return; - if (owner.role == "company" & this.type != "company") return; - this.owner = owner; - } - @@ -276,12 +252,12 @@ public class Account { public void add(Client c){ basicAdd(c); - c.account.basicAdd(Account.this); + c.getAccounts().basicAdd(Account.this); } public void remove(Client c){ basicRemove(c); - c.account.basicRemove(Account.this); + c.getAccounts().basicRemove(Account.this); } public void basicAdd(Client c){ @@ -296,8 +272,8 @@ public class Account { /** * @uml.property name="accounts" */ - public ArrayList getClients() { - return clients.clients; + public ClientReference getClients() { + return clients; } /** @@ -357,12 +333,12 @@ public class Account { public void add(Operation o){ basicAdd(o); - o.account.basicSet(Account.this); + o.getAccount().basicSet(Account.this); } public void remove(Operation o){ basicRemove(o); - o.account.basicUnSet(); + o.getAccount().basicUnSet(); } public void basicAdd(Operation o){ @@ -382,8 +358,8 @@ public class Account { return operation.operations.contains(o); } - public ArrayList getOperations() { - return operation.operations; + public OperationReference getOperations() { + return operation; } } \ No newline at end of file diff --git a/src/main/java/fr/unantes/software/construction/Bank.java b/src/main/java/fr/unantes/software/construction/Bank.java index 05a816c1..b26a2727 100755 --- a/src/main/java/fr/unantes/software/construction/Bank.java +++ b/src/main/java/fr/unantes/software/construction/Bank.java @@ -8,7 +8,28 @@ import java.util.Iterator; import java.util.Vector; public class Bank { - public AddressBook ab; + private AddressBook ab; + /** + * + * this is a counter that is incremented each time a new account is created + * + */ + private int accountNumbers; + /** + * + * @uml.property name="clients" + * @uml.associationEnd inverse="bank:fr.unantes.software.construction.Client" multiplicity="(0 -1)" + * + */ + private Vector clients; + + /** + * + * @uml.property name="accounts" + * @uml.associationEnd aggregation="composite" inverse="bank:fr.unantes.software.construction.Account" multiplicity="(0 -1)" + * + */ + private Vector accounts; /** * this constructor initializes the attributes : accountNumbers is initially 0, @@ -19,13 +40,6 @@ public class Bank { this.accounts = new Vector(); ab = new AddressBook(); } - - /** - * - * this is a counter that is incremented each time a new account is created - * - */ - private int accountNumbers; /** * @@ -45,14 +59,6 @@ public class Bank { this.accountNumbers = accountNumbers; } - /** - * - * @uml.property name="clients" - * @uml.associationEnd inverse="bank:fr.unantes.software.construction.Client" multiplicity="(0 -1)" - * - */ - private Vector clients; - /** * * @uml.property name="clients" @@ -185,6 +191,14 @@ public class Bank { } } + public AddressBook getAb(){ + return ab; + } + + public void setAb(AddressBook a){ + ab = a; + } + /** * Looks for a person named name in the set of clients. * Returns the Client object corresponding to the client if it exists @@ -264,14 +278,6 @@ public class Bank { } } - /** - * - * @uml.property name="accounts" - * @uml.associationEnd aggregation="composite" inverse="bank:fr.unantes.software.construction.Account" multiplicity="(0 -1)" - * - */ - private Vector accounts; - /** * * @uml.property name="accounts" diff --git a/src/main/java/fr/unantes/software/construction/Client.java b/src/main/java/fr/unantes/software/construction/Client.java index f2c27326..34401e43 100644 --- a/src/main/java/fr/unantes/software/construction/Client.java +++ b/src/main/java/fr/unantes/software/construction/Client.java @@ -14,10 +14,10 @@ public abstract class Client { /** * The name of the client */ - public String name; - public String role; - public CardReference card; - public AccountReference account; + private String name; + private String role; + private CardReference card; + private AccountReference account; public Client(String name, String role) throws InvalidClassException { @@ -78,12 +78,12 @@ public abstract class Client { public void add(Account a){ basicAdd(a); - a.clients.basicAdd(Client.this); + a.getClients().basicAdd(Client.this); } public void remove(Account a){ basicRemove(a); - a.clients.basicRemove(Client.this); + a.getClients().basicRemove(Client.this); } public void basicAdd(Account a) { @@ -98,8 +98,8 @@ public abstract class Client { /** * @uml.property name="accounts" */ - public ArrayList getAccounts() { - return account.account; + public AccountReference getAccounts() { + return account; } /** @@ -185,8 +185,8 @@ public abstract class Client { card.set(c); } - public Card getCard(){ - return card.car; + public CardReference getCard(){ + return card; } public void unSetCard(){ diff --git a/src/main/java/fr/unantes/software/construction/Entreprise.java b/src/main/java/fr/unantes/software/construction/Entreprise.java index dd1d46e4..a17b996a 100644 --- a/src/main/java/fr/unantes/software/construction/Entreprise.java +++ b/src/main/java/fr/unantes/software/construction/Entreprise.java @@ -24,7 +24,7 @@ public class Entreprise extends Client { public void setCard(Card c){ if(c.getClass().equals(CompanyCard.class)){ - card.set(c); + getCard().set(c); } } } diff --git a/src/main/java/fr/unantes/software/construction/Operation.java b/src/main/java/fr/unantes/software/construction/Operation.java index 6ad1ef6a..1f593242 100755 --- a/src/main/java/fr/unantes/software/construction/Operation.java +++ b/src/main/java/fr/unantes/software/construction/Operation.java @@ -4,7 +4,7 @@ import java.time.*; public abstract class Operation { - public AccountReference account; + private AccountReference account; private LocalTime time; /** @@ -53,11 +53,11 @@ public abstract class Operation { public void set(Account a){ basicSet(a); - a.operation.basicAdd(Operation.this); + a.getOperations().basicAdd(Operation.this); } public void unSet(){ - acc.operation.basicRemove(Operation.this); + acc.getOperations().basicRemove(Operation.this); basicUnSet(); } @@ -74,8 +74,8 @@ public abstract class Operation { account.set(a); } - public Account getAccount() { - return account.acc; + public AccountReference getAccount() { + return account; } public void removeAccount() { diff --git a/src/main/java/fr/unantes/software/construction/Particulier.java b/src/main/java/fr/unantes/software/construction/Particulier.java index e0383599..02fbc29e 100644 --- a/src/main/java/fr/unantes/software/construction/Particulier.java +++ b/src/main/java/fr/unantes/software/construction/Particulier.java @@ -24,7 +24,7 @@ public class Particulier extends Client { public void setCard(Card c){ if(c.getClass().equals(PrivateCard.class)){ - card.set(c); + getCard().set(c); } } diff --git a/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java b/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java new file mode 100644 index 00000000..66ed5988 --- /dev/null +++ b/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java @@ -0,0 +1,22 @@ +package fr.unantes.software.construction; + +import java.util.ArrayList; + +public class ReferenceUniDi{ + private ArrayList list; + public ReferenceUniDi(){ + list = new ArrayList(); + } + + public void add(T obj){ + list.add(obj); + } + + public void remove(T obj){ + list.remove(obj); + } + + public ArrayList get(){ + return list; + } +} diff --git a/src/main/java/fr/unantes/software/construction/address/Card.java b/src/main/java/fr/unantes/software/construction/address/Card.java index d4ac5b8c..2fccba5c 100755 --- a/src/main/java/fr/unantes/software/construction/address/Card.java +++ b/src/main/java/fr/unantes/software/construction/address/Card.java @@ -53,7 +53,7 @@ public abstract class Card { public GroupList getListeGroupe() { return _grp; } - + /** * @param ad -- GitLab From 5d73b0b32032806426346c4ee52a59b7657928d9 Mon Sep 17 00:00:00 2001 From: kankoue serge tomety Date: Wed, 1 Apr 2020 09:57:32 +0100 Subject: [PATCH 10/35] sepaaration logique et cryptage Separation de la logique de gestion client et la logique de cryptage de mot de passe - Changement de l'algorithme de cryptage de mot de passe. --- pom.xml | 4 +++ .../security/ClientController.java | 28 +++---------------- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/pom.xml b/pom.xml index 4907c460..93bdc6f8 100644 --- a/pom.xml +++ b/pom.xml @@ -22,6 +22,10 @@ org.apache.maven.plugins maven-compiler-plugin 3.7.0 + + 8 + 8 + diff --git a/src/main/java/fr/unantes/software/construction/security/ClientController.java b/src/main/java/fr/unantes/software/construction/security/ClientController.java index 99d44607..4b09cac9 100644 --- a/src/main/java/fr/unantes/software/construction/security/ClientController.java +++ b/src/main/java/fr/unantes/software/construction/security/ClientController.java @@ -8,10 +8,12 @@ import java.util.Map; public class ClientController { private Map namesToUsers; private Map usersToPasswords; + private Password passwordEncrypted; public ClientController() { namesToUsers = new HashMap(); usersToPasswords = new HashMap(); + passwordEncrypted = new Password("ma-cledechiffrement", "az8sA5dsdaSSSI8P"); } /** @@ -35,7 +37,7 @@ public class ClientController { throw new IllegalArgumentException("Invalid argument: the person is already registered."); } namesToUsers.put(person.toString(), person); - usersToPasswords.put(person.getName(), encryptPassword(password)); + usersToPasswords.put(person.getName(), passwordEncrypted.encryptPassword(password)); return true; } @@ -63,30 +65,8 @@ public class ClientController { if (namesToUsers.containsKey(person.getName())) { Client p = (Client) namesToUsers.get(person.getName()); String reference = (String) usersToPasswords.get(p.getName()); - return decryptPassword(reference).equals(password); + return passwordEncrypted.decryptPassword(reference).equals(password); } return false; } - - /** - * Encrypt a password - * @param password - Password to encrypt - * @return Encrypted password - * @throws IllegalArgumentException - */ - private String encryptPassword(String password) throws IllegalArgumentException { - if (password.matches("a")) { - throw new IllegalArgumentException("The password contains unsecure characters, cannot perform encryption."); - } - return password.replaceAll("a", "e"); - } - - /** - * Decrypt a password - * @param encrypted - Password to decrypt - * @return Decrypted password - */ - private String decryptPassword(String encrypted) { - return encrypted.replaceAll("e", "a"); - } } -- GitLab From 304dbd807780b3d8b40b48594c92499d53dbdafa Mon Sep 17 00:00:00 2001 From: kankoue serge tomety Date: Wed, 1 Apr 2020 11:11:56 +0100 Subject: [PATCH 11/35] sepaaration logique et cryptage Separation de la logique de gestion client et la logique de cryptage de mot de passe - Changement de l'algorithme de cryptage de mot de passe. --- .../construction/security/Password.java | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/main/java/fr/unantes/software/construction/security/Password.java diff --git a/src/main/java/fr/unantes/software/construction/security/Password.java b/src/main/java/fr/unantes/software/construction/security/Password.java new file mode 100644 index 00000000..81c13d76 --- /dev/null +++ b/src/main/java/fr/unantes/software/construction/security/Password.java @@ -0,0 +1,72 @@ +package fr.unantes.software.construction.security; + +import java.security.spec.KeySpec; +import java.util.Base64; +import javax.crypto.Cipher; +import javax.crypto.SecretKey; +import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.PBEKeySpec; +import javax.crypto.spec.SecretKeySpec; + +public class Password { + private static String secretKey; + private static String salt; + + public Password(String nsecretKey, String nsalt){ + this.secretKey=nsecretKey; + this.salt=nsalt; + } + /** + * Encrypt a password + * + * @param password - Password to encrypt + * @return Encrypted password + * @throws IllegalArgumentException + */ + + public static String encryptPassword(String password) { + try { + byte[] iv = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + IvParameterSpec ivspec = new IvParameterSpec(iv); + + SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256"); + KeySpec spec = new PBEKeySpec(secretKey.toCharArray(), salt.getBytes(), 65536, 256); + SecretKey tmp = factory.generateSecret(spec); + SecretKeySpec secretKey = new SecretKeySpec(tmp.getEncoded(), "AES"); + + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivspec); + + return Base64.getEncoder().encodeToString(cipher.doFinal(password.getBytes("UTF-8"))); + } catch (Exception e) { + System.out.println("Error while encrypting: " + e.toString()); + } + return null; + } + + /** + * Decrypt a password + * + * @param encrypted - Password to decrypt + * @return Decrypted password + */ + public static String decryptPassword(String encrypted) { + try { + byte[] iv = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + IvParameterSpec ivspec = new IvParameterSpec(iv); + + SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256"); + KeySpec spec = new PBEKeySpec(secretKey.toCharArray(), salt.getBytes(), 65536, 256); + SecretKey tmp = factory.generateSecret(spec); + SecretKeySpec secretKey = new SecretKeySpec(tmp.getEncoded(), "AES"); + + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); + cipher.init(Cipher.DECRYPT_MODE, secretKey, ivspec); + return new String(cipher.doFinal(Base64.getDecoder().decode(encrypted))); + } catch (Exception e) { + System.out.println("Error while decrypting: " + e.toString()); + } + return null; + } +} \ No newline at end of file -- GitLab From 60d7c2df52dddc5a440f7bbbb78cd493119810c6 Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Wed, 1 Apr 2020 15:58:35 +0200 Subject: [PATCH 12/35] Add test --- .../software/construction/Association/CardToGroupTest.java | 4 ---- src/Test/java/fr/unantes/software/construction/BankTest.java | 4 ++++ .../fr/unantes/software/construction/address/AddressTest.java | 4 ++++ .../fr/unantes/software/construction/address/CardTest.java | 4 ++++ .../fr/unantes/software/construction/address/CityTest.java | 4 ++++ .../fr/unantes/software/construction/address/GroupTest.java | 4 ++++ .../fr/unantes/software/construction/address/MailTest.java | 4 ++++ .../fr/unantes/software/construction/address/PhoneTest.java | 4 ++++ .../software/construction/association/BankToAccountTest.java | 4 ++++ .../construction/association/BankToAddressBookTest.java | 4 ++++ .../software/construction/association/BankToClientTest.java | 4 ++++ .../software/construction/association/CardToAddressTest.java | 4 ++++ .../software/construction/association/CardToGroupTest.java | 4 ++++ .../software/construction/security/ClientControllerTest.java | 4 ++++ .../fr/unantes/software/construction/ui/GraphiqueUiTest.java | 4 ++++ .../fr/unantes/software/construction/ui/TextualUiTest.java | 4 ++++ 16 files changed, 60 insertions(+), 4 deletions(-) delete mode 100644 src/Test/java/fr/unantes/software/construction/Association/CardToGroupTest.java create mode 100644 src/Test/java/fr/unantes/software/construction/BankTest.java create mode 100644 src/Test/java/fr/unantes/software/construction/address/AddressTest.java create mode 100644 src/Test/java/fr/unantes/software/construction/address/CardTest.java create mode 100644 src/Test/java/fr/unantes/software/construction/address/CityTest.java create mode 100644 src/Test/java/fr/unantes/software/construction/address/GroupTest.java create mode 100644 src/Test/java/fr/unantes/software/construction/address/MailTest.java create mode 100644 src/Test/java/fr/unantes/software/construction/address/PhoneTest.java create mode 100644 src/Test/java/fr/unantes/software/construction/association/BankToAccountTest.java create mode 100644 src/Test/java/fr/unantes/software/construction/association/BankToAddressBookTest.java create mode 100644 src/Test/java/fr/unantes/software/construction/association/BankToClientTest.java create mode 100644 src/Test/java/fr/unantes/software/construction/association/CardToAddressTest.java create mode 100644 src/Test/java/fr/unantes/software/construction/association/CardToGroupTest.java create mode 100644 src/Test/java/fr/unantes/software/construction/security/ClientControllerTest.java create mode 100644 src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java create mode 100644 src/Test/java/fr/unantes/software/construction/ui/TextualUiTest.java diff --git a/src/Test/java/fr/unantes/software/construction/Association/CardToGroupTest.java b/src/Test/java/fr/unantes/software/construction/Association/CardToGroupTest.java deleted file mode 100644 index 2622fed9..00000000 --- a/src/Test/java/fr/unantes/software/construction/Association/CardToGroupTest.java +++ /dev/null @@ -1,4 +0,0 @@ -package fr.unantes.software.construction.Association; - -public class CardToGroupTest { -} diff --git a/src/Test/java/fr/unantes/software/construction/BankTest.java b/src/Test/java/fr/unantes/software/construction/BankTest.java new file mode 100644 index 00000000..c517e416 --- /dev/null +++ b/src/Test/java/fr/unantes/software/construction/BankTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction; + +public class BankTest { +} diff --git a/src/Test/java/fr/unantes/software/construction/address/AddressTest.java b/src/Test/java/fr/unantes/software/construction/address/AddressTest.java new file mode 100644 index 00000000..40e21e3b --- /dev/null +++ b/src/Test/java/fr/unantes/software/construction/address/AddressTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction.address; + +public class AddressTest { +} diff --git a/src/Test/java/fr/unantes/software/construction/address/CardTest.java b/src/Test/java/fr/unantes/software/construction/address/CardTest.java new file mode 100644 index 00000000..1492669d --- /dev/null +++ b/src/Test/java/fr/unantes/software/construction/address/CardTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction.address; + +public class CardTest { +} diff --git a/src/Test/java/fr/unantes/software/construction/address/CityTest.java b/src/Test/java/fr/unantes/software/construction/address/CityTest.java new file mode 100644 index 00000000..0111761a --- /dev/null +++ b/src/Test/java/fr/unantes/software/construction/address/CityTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction.address; + +public class CityTest { +} diff --git a/src/Test/java/fr/unantes/software/construction/address/GroupTest.java b/src/Test/java/fr/unantes/software/construction/address/GroupTest.java new file mode 100644 index 00000000..f1a9f8be --- /dev/null +++ b/src/Test/java/fr/unantes/software/construction/address/GroupTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction.address; + +public class GroupTest { +} diff --git a/src/Test/java/fr/unantes/software/construction/address/MailTest.java b/src/Test/java/fr/unantes/software/construction/address/MailTest.java new file mode 100644 index 00000000..d551d9f7 --- /dev/null +++ b/src/Test/java/fr/unantes/software/construction/address/MailTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction.address; + +public class MailTest { +} diff --git a/src/Test/java/fr/unantes/software/construction/address/PhoneTest.java b/src/Test/java/fr/unantes/software/construction/address/PhoneTest.java new file mode 100644 index 00000000..a057b628 --- /dev/null +++ b/src/Test/java/fr/unantes/software/construction/address/PhoneTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction.address; + +public class PhoneTest { +} diff --git a/src/Test/java/fr/unantes/software/construction/association/BankToAccountTest.java b/src/Test/java/fr/unantes/software/construction/association/BankToAccountTest.java new file mode 100644 index 00000000..f331970e --- /dev/null +++ b/src/Test/java/fr/unantes/software/construction/association/BankToAccountTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction.association; + +public class BankToAccountTest { +} diff --git a/src/Test/java/fr/unantes/software/construction/association/BankToAddressBookTest.java b/src/Test/java/fr/unantes/software/construction/association/BankToAddressBookTest.java new file mode 100644 index 00000000..ab9923d2 --- /dev/null +++ b/src/Test/java/fr/unantes/software/construction/association/BankToAddressBookTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction.association; + +public class BankToAddressBookTest { +} diff --git a/src/Test/java/fr/unantes/software/construction/association/BankToClientTest.java b/src/Test/java/fr/unantes/software/construction/association/BankToClientTest.java new file mode 100644 index 00000000..811bb1e7 --- /dev/null +++ b/src/Test/java/fr/unantes/software/construction/association/BankToClientTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction.association; + +public class BankToClientTest { +} diff --git a/src/Test/java/fr/unantes/software/construction/association/CardToAddressTest.java b/src/Test/java/fr/unantes/software/construction/association/CardToAddressTest.java new file mode 100644 index 00000000..e232914a --- /dev/null +++ b/src/Test/java/fr/unantes/software/construction/association/CardToAddressTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction.association; + +public class CardToAddressTest { +} diff --git a/src/Test/java/fr/unantes/software/construction/association/CardToGroupTest.java b/src/Test/java/fr/unantes/software/construction/association/CardToGroupTest.java new file mode 100644 index 00000000..6d0c0d73 --- /dev/null +++ b/src/Test/java/fr/unantes/software/construction/association/CardToGroupTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction.association; + +public class CardToGroupTest { +} diff --git a/src/Test/java/fr/unantes/software/construction/security/ClientControllerTest.java b/src/Test/java/fr/unantes/software/construction/security/ClientControllerTest.java new file mode 100644 index 00000000..8867f07c --- /dev/null +++ b/src/Test/java/fr/unantes/software/construction/security/ClientControllerTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction.security; + +public class ClientControllerTest { +} diff --git a/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java b/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java new file mode 100644 index 00000000..33aea173 --- /dev/null +++ b/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction.ui; + +public class GraphiqueUiTest { +} diff --git a/src/Test/java/fr/unantes/software/construction/ui/TextualUiTest.java b/src/Test/java/fr/unantes/software/construction/ui/TextualUiTest.java new file mode 100644 index 00000000..dee64f58 --- /dev/null +++ b/src/Test/java/fr/unantes/software/construction/ui/TextualUiTest.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction.ui; + +public class TextualUiTest { +} -- GitLab From 0a238a6606f76d815e055d88e5b4540a905fbafa Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Wed, 1 Apr 2020 18:05:41 +0200 Subject: [PATCH 13/35] CardToGroup Reference + Test + Correction test --- .../association/CardToGroupTest.java | 50 +++++++++++++++++++ .../AccountClientTest.java | 18 +++---- .../software/construction/Account.java | 32 +++++++----- .../unantes/software/construction/Bank.java | 2 +- .../unantes/software/construction/Client.java | 18 +++++-- .../software/construction/Entreprise.java | 2 +- .../software/construction/Operation.java | 6 ++- .../software/construction/Particulier.java | 2 +- .../construction/address/AddressList.java | 2 +- .../software/construction/address/Card.java | 27 ++++++++-- .../construction/address/CompanyCard.java | 2 +- .../software/construction/address/Group.java | 6 +-- .../construction/address/GroupList.java | 11 ++-- .../construction/address/PhoneList.java | 2 +- .../construction/address/PrivateCard.java | 4 +- .../construction/ui/TextualUserInterface.java | 2 +- 16 files changed, 136 insertions(+), 50 deletions(-) diff --git a/src/Test/java/fr/unantes/software/construction/association/CardToGroupTest.java b/src/Test/java/fr/unantes/software/construction/association/CardToGroupTest.java index 6d0c0d73..de9a3217 100644 --- a/src/Test/java/fr/unantes/software/construction/association/CardToGroupTest.java +++ b/src/Test/java/fr/unantes/software/construction/association/CardToGroupTest.java @@ -1,4 +1,54 @@ package fr.unantes.software.construction.association; +import fr.unantes.software.construction.address.*; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +import java.io.InvalidClassException; + public class CardToGroupTest { + private CompanyCard card1c; + private CompanyCard card2c; + private PrivateCard card1p; + private PrivateCard card2p; + private Group g1; + private Group g2; + + @SuppressWarnings("static-access") + @Test + public void CompanyTest(){ + card1c.addGroupe(g1); + card1c.addGroupe(g2); + card2c.setListeGroupe(card1c.getListeGroupe()); + assertTrue(card2c.getListeGroupe().find(g1)); + assertTrue(card2c.getListeGroupe().find(g2)); + card1c.deleteGroupe(g2); + assertFalse(card1c.getListeGroupe().find(g2)); + assertTrue(card2c.getListeGroupe().find(g2)); + } + + @SuppressWarnings("static-access") + @Test + public void PrivateTest(){ + card1p.addGroupe(g1); + card1p.addGroupe(g2); + card2p.setListeGroupe(card1p.getListeGroupe()); + assertTrue(card2p.getListeGroupe().find(g1)); + assertTrue(card2p.getListeGroupe().find(g2)); + card2p.deleteGroupe(g2); + assertFalse(card2p.getListeGroupe().find(g2)); + assertTrue(card1p.getListeGroupe().find(g2)); + } + + @Before + public void initBeforeTest() throws InvalidClassException { + card1c = new CompanyCard("Company1"); + card2c = new CompanyCard("Company2"); + card1p = new PrivateCard("test","private"); + card2p = new PrivateCard("test","private"); + g1 = new Group("g1","test"); + g2 = new Group("g2","test"); + } } diff --git a/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountClientTest.java b/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountClientTest.java index 9c6b85a9..5691a70a 100644 --- a/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountClientTest.java +++ b/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountClientTest.java @@ -22,13 +22,14 @@ public class AccountClientTest { @SuppressWarnings("static-access") @Test public void ClientToAccount() throws InvalidClassException { - client.addAccounts(account); - assertEquals(1,client.accountsSize()); + assertEquals(2,client.accountsSize()); assertEquals(1,account.clientsSize()); + client2.addAccounts(account); + assertEquals(1,client2.accountsSize()); + assertEquals(2,account.clientsSize()); assertTrue(client.containsAccounts(account)); client.addAccounts(account2); assertEquals(2,client.accountsSize()); - assertEquals(1,account.clientsSize()); assertEquals(1,account2.clientsSize()); assertTrue(client.containsAccounts(account)); assertTrue(client.containsAccounts(account2)); @@ -44,15 +45,14 @@ public class AccountClientTest { @SuppressWarnings("static-access") @Test public void AccountToClient() throws InvalidClassException { - account.addClients(client); assertEquals(1,account.clientsSize()); - assertEquals(1,client.accountsSize()); - assertTrue(account.containsClients(client)); + assertEquals(2,client.accountsSize()); account.addClients(client2); assertEquals(2,account.clientsSize()); - assertEquals(1,client.accountsSize()); assertEquals(1,client2.accountsSize()); assertTrue(account.containsClients(client)); + assertEquals(2,client.accountsSize()); + assertTrue(account.containsClients(client)); assertTrue(account.containsClients(client2)); account.removeClients(client2); assertEquals(1,account.clientsSize()); @@ -65,9 +65,9 @@ public class AccountClientTest { @Before public void initBeforeTest() throws InvalidClassException { - account = new Account(client,1,1,1,"private"); - account2 = new Account(client,0,0,0,"private"); client = new Entreprise("test1","company", new CompanyAddress()); client2 = new Particulier("test2","private", new PrivateAddress()); + account = new Account(client,1,1,1,"private"); + account2 = new Account(client,0,0,0,"private"); } } diff --git a/src/main/java/fr/unantes/software/construction/Account.java b/src/main/java/fr/unantes/software/construction/Account.java index 063375f9..5c1354b6 100755 --- a/src/main/java/fr/unantes/software/construction/Account.java +++ b/src/main/java/fr/unantes/software/construction/Account.java @@ -51,7 +51,7 @@ public class Account { throw new InvalidClassException("Invalid type supplied. An account can only be private or company"); } clients = new ClientReference(); - clients.add(p); + addClients(p); } /** @@ -267,31 +267,39 @@ public class Account { public void basicRemove(Client c){ clients.remove(c); } + + public Client get(int i){ + return clients.get(i); + } } /** - * @uml.property name="accounts" + * @uml.property name="clients" */ public ClientReference getClients() { return clients; } /** - * @uml.property name="accounts" + * @uml.property name="clients" */ public void addClients(Client element) { - clients.add(element); + if(!containsClients(element)){ + clients.add(element); + } } /** - * @uml.property name="accounts" + * @uml.property name="clients" */ public void removeClients(Client element) { - clients.remove(element); + if(containsClients(element)){ + clients.remove(element); + } } /** - * @uml.property name="accounts" + * @uml.property name="clients" */ public boolean isClientsEmpty() { if (clients.clients.size() == 0) { @@ -302,21 +310,21 @@ public class Account { } /** - * @uml.property name="accounts" + * @uml.property name="clients" */ public void clearClients() { clients.clients.clear(); } /** - * @uml.property name="accounts" + * @uml.property name="clients" */ public boolean containsClients(Client element) { return clients.clients.contains(element); } /** - * @uml.property name="accounts" + * @uml.property name="clients" */ public int clientsSize() { return clients.clients.size(); @@ -333,12 +341,12 @@ public class Account { public void add(Operation o){ basicAdd(o); - o.getAccount().basicSet(Account.this); + o.getAccountReference().basicSet(Account.this); } public void remove(Operation o){ basicRemove(o); - o.getAccount().basicUnSet(); + o.getAccountReference().basicUnSet(); } public void basicAdd(Operation o){ diff --git a/src/main/java/fr/unantes/software/construction/Bank.java b/src/main/java/fr/unantes/software/construction/Bank.java index b26a2727..c3e1e447 100755 --- a/src/main/java/fr/unantes/software/construction/Bank.java +++ b/src/main/java/fr/unantes/software/construction/Bank.java @@ -178,7 +178,7 @@ public class Bank { public void closeAccount(int accountNumber) throws Exception { Account a=getAccount(accountNumber); if (a!=null){ - ArrayList tmp = a.getClients(); + Account.ClientReference tmp = a.getClients(); for(int i = 0; i < a.clientsSize(); i++){ a.removeClients(tmp.get(i)); diff --git a/src/main/java/fr/unantes/software/construction/Client.java b/src/main/java/fr/unantes/software/construction/Client.java index 34401e43..c277e68b 100644 --- a/src/main/java/fr/unantes/software/construction/Client.java +++ b/src/main/java/fr/unantes/software/construction/Client.java @@ -106,14 +106,18 @@ public abstract class Client { * @uml.property name="accounts" */ public void addAccounts(Account element) { - account.add(element); + if(!containsAccounts(element)){ + account.add(element); + } } /** * @uml.property name="accounts" */ public void removeAccounts(Account element) { - account.remove(element); + if(containsAccounts(element)){ + account.remove(element); + } } /** @@ -164,11 +168,11 @@ public abstract class Client { public void set(Card c){ basicSet(c); - c.client.basicSet(Client.this); + c.getClientReference().basicSet(Client.this); } public void unSet(){ - car.client.basicUnSet(); + car.getClientReference().basicUnSet(); basicUnSet(); } @@ -185,7 +189,11 @@ public abstract class Client { card.set(c); } - public CardReference getCard(){ + public Card getCard(){ + return card.car; + } + + public CardReference getCardReference(){ return card; } diff --git a/src/main/java/fr/unantes/software/construction/Entreprise.java b/src/main/java/fr/unantes/software/construction/Entreprise.java index a17b996a..acf1e79b 100644 --- a/src/main/java/fr/unantes/software/construction/Entreprise.java +++ b/src/main/java/fr/unantes/software/construction/Entreprise.java @@ -24,7 +24,7 @@ public class Entreprise extends Client { public void setCard(Card c){ if(c.getClass().equals(CompanyCard.class)){ - getCard().set(c); + getCardReference().set(c); } } } diff --git a/src/main/java/fr/unantes/software/construction/Operation.java b/src/main/java/fr/unantes/software/construction/Operation.java index 1f593242..79434cc3 100755 --- a/src/main/java/fr/unantes/software/construction/Operation.java +++ b/src/main/java/fr/unantes/software/construction/Operation.java @@ -74,10 +74,12 @@ public abstract class Operation { account.set(a); } - public AccountReference getAccount() { - return account; + public Account getAccount() { + return account.acc; } + public AccountReference getAccountReference() { return account; } + public void removeAccount() { account.unSet(); } diff --git a/src/main/java/fr/unantes/software/construction/Particulier.java b/src/main/java/fr/unantes/software/construction/Particulier.java index 02fbc29e..27bec104 100644 --- a/src/main/java/fr/unantes/software/construction/Particulier.java +++ b/src/main/java/fr/unantes/software/construction/Particulier.java @@ -24,7 +24,7 @@ public class Particulier extends Client { public void setCard(Card c){ if(c.getClass().equals(PrivateCard.class)){ - getCard().set(c); + getCardReference().set(c); } } diff --git a/src/main/java/fr/unantes/software/construction/address/AddressList.java b/src/main/java/fr/unantes/software/construction/address/AddressList.java index 7c713e22..29577a95 100755 --- a/src/main/java/fr/unantes/software/construction/address/AddressList.java +++ b/src/main/java/fr/unantes/software/construction/address/AddressList.java @@ -78,7 +78,7 @@ public class AddressList { /** * fusion entre 2 listes dans une nouvelle. * - * @param l l'autre liste. + * @param lA l'autre liste. * @return une nouvelle liste, fusion des deux autres. * */ diff --git a/src/main/java/fr/unantes/software/construction/address/Card.java b/src/main/java/fr/unantes/software/construction/address/Card.java index 2fccba5c..4ec806db 100755 --- a/src/main/java/fr/unantes/software/construction/address/Card.java +++ b/src/main/java/fr/unantes/software/construction/address/Card.java @@ -15,7 +15,7 @@ public abstract class Card { protected AddressList _ad = new AddressList(); protected PhoneList _tel= new PhoneList(); protected MailList _mail = new MailList(); - public ClientReference client; + private ClientReference client; /** * Constructeur sans parametres @@ -80,9 +80,24 @@ public abstract class Card { * @param grp */ public void setListeGroupe(GroupList grp) { - _grp = grp; + _grp.setListeGroupe(grp.getListeGroupe()); } + /** + * @param grp + */ + public void addGroupe(Group grp) { + _grp.add(grp); + } + + /** + * @param grp + */ + public void deleteGroupe(Group grp) { + _grp.delete(grp); + } + + /** * Renvoie une fusion de deux fiches. * @param f @@ -134,11 +149,11 @@ public abstract class Card { public void set(Client c){ basicSet(c); - c.card.basicSet(Card.this); + c.getCardReference().basicSet(Card.this); } public void unSet(){ - client.card.basicUnSet(); + client.getCardReference().basicUnSet(); basicUnSet(); } @@ -159,6 +174,10 @@ public abstract class Card { return client.client; } + public ClientReference getClientReference(){ + return client; + } + public void unSetClient(){ client.unSet(); } diff --git a/src/main/java/fr/unantes/software/construction/address/CompanyCard.java b/src/main/java/fr/unantes/software/construction/address/CompanyCard.java index 581dfd39..b4b37a7a 100755 --- a/src/main/java/fr/unantes/software/construction/address/CompanyCard.java +++ b/src/main/java/fr/unantes/software/construction/address/CompanyCard.java @@ -57,7 +57,7 @@ public class CompanyCard extends Card { public void setClient(Client c){ if(c.getClass().equals(Entreprise.class)){ - client.set(c); + getClientReference().set(c); } } diff --git a/src/main/java/fr/unantes/software/construction/address/Group.java b/src/main/java/fr/unantes/software/construction/address/Group.java index 25b4c1fb..d91a3e38 100755 --- a/src/main/java/fr/unantes/software/construction/address/Group.java +++ b/src/main/java/fr/unantes/software/construction/address/Group.java @@ -10,8 +10,8 @@ public class Group { /** Attributs d'instance */ - protected String _grp; - protected String _comGrp; + private String _grp; + private String _comGrp; /** Constructeurs */ public Group() { @@ -65,7 +65,7 @@ public class Group { /** * Fusione deux groups en un troisieme. * - * @param f fiche a faire fusionner avec la fiche courante + * @param g fiche a faire fusionner avec la fiche courante * @return fiche resultant de la fusion de la fiche courante et celle passee en parametre */ public Group merge(Group g) { diff --git a/src/main/java/fr/unantes/software/construction/address/GroupList.java b/src/main/java/fr/unantes/software/construction/address/GroupList.java index 7d0d2de0..faa378a0 100755 --- a/src/main/java/fr/unantes/software/construction/address/GroupList.java +++ b/src/main/java/fr/unantes/software/construction/address/GroupList.java @@ -4,7 +4,7 @@ import java.util.*; public class GroupList { - Vector _listeGroup; + private Vector _listeGroup; public GroupList() { _listeGroup = new Vector(); @@ -12,8 +12,7 @@ public class GroupList { public GroupList(GroupList lG) { _listeGroup = new Vector(); - for (Enumeration e = lG.getListeGroupe().elements(); e - .hasMoreElements();) { + for (Enumeration e = lG.getListeGroupe().elements(); e.hasMoreElements();) { _listeGroup.add((Group) e.nextElement()); } } @@ -26,7 +25,7 @@ public class GroupList { } /** - * @param l + * @param lG */ public void setListeGroupe(Vector lG) { for (Enumeration e = lG.elements(); e.hasMoreElements();) { @@ -44,7 +43,7 @@ public class GroupList { } /** - * @param e + * @param g * element a supprimer de la liste */ public void delete(Group g) { @@ -71,7 +70,7 @@ public class GroupList { /** * Fusion entre 2 listes dans un 3eme que l'on cree. * - * @param l + * @param lg * 2eme liste a faire fusionner * @return La 3eme liste fusion de la liste courante et de la liste passee * en parametre diff --git a/src/main/java/fr/unantes/software/construction/address/PhoneList.java b/src/main/java/fr/unantes/software/construction/address/PhoneList.java index a204e989..fb0d4a85 100755 --- a/src/main/java/fr/unantes/software/construction/address/PhoneList.java +++ b/src/main/java/fr/unantes/software/construction/address/PhoneList.java @@ -77,7 +77,7 @@ public class PhoneList { /** * Fusion entre 2 listes dans une 3eme que l'on cree. * - * @param l 2eme liste a faire fusionner + * @param lT 2eme liste a faire fusionner * @return La 3eme liste fusion de la liste courante et de la liste passee en parametre */ public PhoneList merge(PhoneList lT) { diff --git a/src/main/java/fr/unantes/software/construction/address/PrivateCard.java b/src/main/java/fr/unantes/software/construction/address/PrivateCard.java index 8d9fec26..e8f4a09a 100755 --- a/src/main/java/fr/unantes/software/construction/address/PrivateCard.java +++ b/src/main/java/fr/unantes/software/construction/address/PrivateCard.java @@ -61,7 +61,7 @@ public class PrivateCard extends Card { * permet la fusion entre la fiche courante et une fiche passee en parametre * dans une troisieme fiche * - * @param f fiche a faire fusionner a vec la fiche courante + * @param f fiche a faire fusionner avec la fiche courante * @return fiche resultant de la fusion de la fiche courante et celle passee en parametre */ public Card merge(Card f) { @@ -97,7 +97,7 @@ public class PrivateCard extends Card { public void setClient(Client c){ if(c.getClass().equals(Particulier.class)){ - client.set(c); + getClientReference().set(c); } } } diff --git a/src/main/java/fr/unantes/software/construction/ui/TextualUserInterface.java b/src/main/java/fr/unantes/software/construction/ui/TextualUserInterface.java index 76c4d6a8..6e48574b 100755 --- a/src/main/java/fr/unantes/software/construction/ui/TextualUserInterface.java +++ b/src/main/java/fr/unantes/software/construction/ui/TextualUserInterface.java @@ -288,7 +288,7 @@ public class TextualUserInterface { //case balanceCmd : balance(); case historyCmd : history(); case clientsCmd : clients(); - case accountsCmd : displayAccounts(); + case accountsCmd : displayAccounts(); case accountsOfClientsCmd : displayAccountsOfClient(); default : System.out.println("this is not a valid command"); } -- GitLab From 4adc482041dff0198662e7f5b65005ee32906ebd Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Wed, 1 Apr 2020 18:31:10 +0200 Subject: [PATCH 14/35] CardToAddress Amelioration + Test --- .../association/CardToAddressTest.java | 55 +++++++++++++++++++ .../software/construction/Account.java | 9 ++- .../construction/address/AddressList.java | 2 +- .../software/construction/address/Card.java | 16 +++++- 4 files changed, 79 insertions(+), 3 deletions(-) diff --git a/src/Test/java/fr/unantes/software/construction/association/CardToAddressTest.java b/src/Test/java/fr/unantes/software/construction/association/CardToAddressTest.java index e232914a..85560dba 100644 --- a/src/Test/java/fr/unantes/software/construction/association/CardToAddressTest.java +++ b/src/Test/java/fr/unantes/software/construction/association/CardToAddressTest.java @@ -1,4 +1,59 @@ package fr.unantes.software.construction.association; +import fr.unantes.software.construction.address.*; +import org.junit.Before; +import org.junit.Test; + +import java.io.InvalidClassException; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + public class CardToAddressTest { + private CompanyCard card1c; + private CompanyCard card2c; + private PrivateCard card1p; + private PrivateCard card2p; + private CompanyAddress adr1c; + private CompanyAddress adr2c; + private PrivateAddress adr1p; + private PrivateAddress adr2p; + + @SuppressWarnings("static-access") + @Test + public void CompanyTest(){ + card1c.addAddress(adr1c); + card1c.addAddress(adr2c); + card2c.setListeAdresse(card1c.getListeAdresse()); + assertTrue(card2c.getListeAdresse().rechercher(adr1c)); + assertTrue(card2c.getListeAdresse().rechercher(adr2c)); + card1c.deleteAddress(adr2c); + assertFalse(card1c.getListeAdresse().rechercher(adr2c)); + assertTrue(card2c.getListeAdresse().rechercher(adr2c)); + } + + @SuppressWarnings("static-access") + @Test + public void PrivateTest(){ + card1p.addAddress(adr1p); + card1p.addAddress(adr2p); + card2p.setListeAdresse(card1p.getListeAdresse()); + assertTrue(card2p.getListeAdresse().rechercher(adr1p)); + assertTrue(card2p.getListeAdresse().rechercher(adr2p)); + card2p.deleteAddress(adr2p); + assertFalse(card2p.getListeAdresse().rechercher(adr2p)); + assertTrue(card1p.getListeAdresse().rechercher(adr2p)); + } + + @Before + public void initBeforeTest() throws InvalidClassException { + card1c = new CompanyCard("Company1"); + card2c = new CompanyCard("Company2"); + card1p = new PrivateCard("test","private"); + card2p = new PrivateCard("test","private"); + adr1c = new CompanyAddress(); + adr2c = new CompanyAddress(); + adr1p = new PrivateAddress(); + adr2p = new PrivateAddress(); + } } diff --git a/src/main/java/fr/unantes/software/construction/Account.java b/src/main/java/fr/unantes/software/construction/Account.java index 5c1354b6..4d1cf909 100755 --- a/src/main/java/fr/unantes/software/construction/Account.java +++ b/src/main/java/fr/unantes/software/construction/Account.java @@ -37,6 +37,8 @@ public class Account { */ private int number; + private Client owner; + /** * Initializes the owner, amount, overdraft and the account number with parameters * The method also initializes the history with a new empty Vector @@ -51,7 +53,8 @@ public class Account { throw new InvalidClassException("Invalid type supplied. An account can only be private or company"); } clients = new ClientReference(); - addClients(p); + owner = p; + addClients(owner); } /** @@ -90,6 +93,10 @@ public class Account { } } + public Client getOwner(){ + return owner; + } + /** * * @uml.property name="history" diff --git a/src/main/java/fr/unantes/software/construction/address/AddressList.java b/src/main/java/fr/unantes/software/construction/address/AddressList.java index 29577a95..9277106c 100755 --- a/src/main/java/fr/unantes/software/construction/address/AddressList.java +++ b/src/main/java/fr/unantes/software/construction/address/AddressList.java @@ -42,7 +42,7 @@ public class AddressList { /** Modificateur */ /** - * @param listeAdresse + * @param lA */ public void setListeAdresse(Vector lA) { for (Enumeration e = lA.elements(); e.hasMoreElements();) { diff --git a/src/main/java/fr/unantes/software/construction/address/Card.java b/src/main/java/fr/unantes/software/construction/address/Card.java index 4ec806db..8a356cba 100755 --- a/src/main/java/fr/unantes/software/construction/address/Card.java +++ b/src/main/java/fr/unantes/software/construction/address/Card.java @@ -59,7 +59,21 @@ public abstract class Card { * @param ad */ public void setListeAdresse(AddressList ad) { - _ad = ad; + _ad.setListeAdresse(ad.getListeAdresse()); + } + + /** + * @param a + */ + public void addAddress(Address a) { + _ad.ajouter(a); + } + + /** + * @param a + */ + public void deleteAddress(Address a) { + _ad.supprimer(a); } /** -- GitLab From 1d2401fd3e34873968495ab21e0d801d1d87d6ce Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Wed, 1 Apr 2020 19:20:42 +0200 Subject: [PATCH 15/35] Bank -> Account,AddressBook,Client reference+test --- .../association/BankToAccountTest.java | 38 ++++ .../association/BankToAddressBookTest.java | 30 +++ .../association/BankToClientTest.java | 37 ++++ .../unantes/software/construction/Bank.java | 204 ++---------------- .../software/construction/ReferenceUniDi.java | 37 +++- .../construction/ui/TextualUserInterface.java | 4 +- 6 files changed, 157 insertions(+), 193 deletions(-) diff --git a/src/Test/java/fr/unantes/software/construction/association/BankToAccountTest.java b/src/Test/java/fr/unantes/software/construction/association/BankToAccountTest.java index f331970e..7ca04c2a 100644 --- a/src/Test/java/fr/unantes/software/construction/association/BankToAccountTest.java +++ b/src/Test/java/fr/unantes/software/construction/association/BankToAccountTest.java @@ -1,4 +1,42 @@ package fr.unantes.software.construction.association; +import fr.unantes.software.construction.Account; +import fr.unantes.software.construction.Bank; +import fr.unantes.software.construction.Entreprise; +import fr.unantes.software.construction.Particulier; +import fr.unantes.software.construction.address.CompanyAddress; +import fr.unantes.software.construction.address.PrivateAddress; +import org.junit.Before; +import org.junit.Test; + +import java.io.InvalidClassException; + +import static org.junit.Assert.assertEquals; + public class BankToAccountTest { + private Bank b; + private Account acc1; + private Account acc2; + + @SuppressWarnings("static-access") + @Test + public void Test(){ + b.getAccountRef().add(acc1); + assertEquals(1,b.getAccountRef().size()); + b.getAccountRef().add(acc2); + assertEquals(2,b.getAccountRef().size()); + b.getAccountRef().remove(acc1); + assertEquals(1,b.getAccountRef().size()); + b.getAccountRef().remove(acc1); + b.getAccountRef().remove(acc2); + assertEquals(0,b.getAccountRef().size()); + + } + + @Before + public void initBeforeTest() throws InvalidClassException { + b = new Bank(); + acc1 = new Account(new Particulier("test","private", new PrivateAddress()),1,1,1,"private"); + acc2 = new Account(new Entreprise("test","company", new CompanyAddress()),1,1,1,"private"); + } } diff --git a/src/Test/java/fr/unantes/software/construction/association/BankToAddressBookTest.java b/src/Test/java/fr/unantes/software/construction/association/BankToAddressBookTest.java index ab9923d2..870433a9 100644 --- a/src/Test/java/fr/unantes/software/construction/association/BankToAddressBookTest.java +++ b/src/Test/java/fr/unantes/software/construction/association/BankToAddressBookTest.java @@ -1,4 +1,34 @@ package fr.unantes.software.construction.association; +import fr.unantes.software.construction.Bank; +import fr.unantes.software.construction.address.AddressBook; +import org.junit.Before; +import org.junit.Test; + +import java.io.InvalidClassException; + +import static org.junit.Assert.*; + public class BankToAddressBookTest { + private Bank b; + private AddressBook ab1; + private AddressBook ab2; + + @SuppressWarnings("static-access") + @Test + public void Test(){ + b.setAb(ab1); + assertEquals(b.getAb(),ab1); + assertNotEquals(b.getAb(),ab2); + b.setAb(ab2); + assertNotEquals(b.getAb(),ab1); + assertEquals(b.getAb(),ab2); + } + + @Before + public void initBeforeTest() throws InvalidClassException { + b = new Bank(); + ab1 = new AddressBook(); + ab2 = new AddressBook(); + } } diff --git a/src/Test/java/fr/unantes/software/construction/association/BankToClientTest.java b/src/Test/java/fr/unantes/software/construction/association/BankToClientTest.java index 811bb1e7..97a24c8c 100644 --- a/src/Test/java/fr/unantes/software/construction/association/BankToClientTest.java +++ b/src/Test/java/fr/unantes/software/construction/association/BankToClientTest.java @@ -1,4 +1,41 @@ package fr.unantes.software.construction.association; +import fr.unantes.software.construction.Bank; +import fr.unantes.software.construction.Entreprise; +import fr.unantes.software.construction.Particulier; +import fr.unantes.software.construction.address.CompanyAddress; +import fr.unantes.software.construction.address.PrivateAddress; +import org.junit.Before; +import org.junit.Test; + +import java.io.InvalidClassException; + +import static org.junit.Assert.assertEquals; + public class BankToClientTest { + private Bank b; + private Entreprise entreprise; + private Particulier particulier; + + @SuppressWarnings("static-access") + @Test + public void Test(){ + b.getClientRef().add(entreprise); + assertEquals(1,b.getClientRef().size()); + b.getClientRef().add(particulier); + assertEquals(2,b.getClientRef().size()); + b.getClientRef().remove(entreprise); + assertEquals(1,b.getClientRef().size()); + b.getClientRef().remove(entreprise); + b.getClientRef().remove(particulier); + assertEquals(0,b.getClientRef().size()); + + } + + @Before + public void initBeforeTest() throws InvalidClassException { + b = new Bank(); + entreprise = new Entreprise("test1","company", new CompanyAddress()); + particulier = new Particulier("test2","private", new PrivateAddress()); + } } diff --git a/src/main/java/fr/unantes/software/construction/Bank.java b/src/main/java/fr/unantes/software/construction/Bank.java index c3e1e447..e63d5281 100755 --- a/src/main/java/fr/unantes/software/construction/Bank.java +++ b/src/main/java/fr/unantes/software/construction/Bank.java @@ -3,9 +3,7 @@ package fr.unantes.software.construction; import fr.unantes.software.construction.address.AddressBook; import java.io.InvalidClassException; -import java.util.ArrayList; import java.util.Iterator; -import java.util.Vector; public class Bank { private AddressBook ab; @@ -21,7 +19,7 @@ public class Bank { * @uml.associationEnd inverse="bank:fr.unantes.software.construction.Client" multiplicity="(0 -1)" * */ - private Vector clients; + private ReferenceUniDi clients; /** * @@ -29,7 +27,7 @@ public class Bank { * @uml.associationEnd aggregation="composite" inverse="bank:fr.unantes.software.construction.Account" multiplicity="(0 -1)" * */ - private Vector accounts; + private ReferenceUniDi accounts; /** * this constructor initializes the attributes : accountNumbers is initially 0, @@ -37,8 +35,9 @@ public class Bank { */ public Bank() { this.accountNumbers = 0; - this.accounts = new Vector(); + this.accounts = new ReferenceUniDi(); ab = new AddressBook(); + this.clients = new ReferenceUniDi(); } /** @@ -59,96 +58,6 @@ public class Bank { this.accountNumbers = accountNumbers; } - /** - * - * @uml.property name="clients" - */ - public Vector getClients() { - return clients; - } - - /** - * - * @uml.property name="clients" - */ - public void setClients(Vector value) { - clients = value; - } - - /** - * - * @uml.property name="clients" - * @return - */ - public Iterator clientsIterator() { - return clients.iterator(); - } - - /** - * - * @uml.property name="clients" - */ - public boolean addClients(Client element) { - return clients.add(element); - } - - /** - * - * @uml.property name="clients" - */ - public boolean removeClients(Client element) { - return clients.remove(element); - } - - /** - * - * @uml.property name="clients" - */ - public boolean isClientsEmpty() { - return clients.isEmpty(); - } - - /** - * - * @uml.property name="clients" - */ - public void clearClients() { - clients.clear(); - } - - /** - * - * @uml.property name="clients" - */ - public boolean containsClients(Client element) { - return clients.contains(element); - } - - /** - * - * @uml.property name="clients" - */ - public boolean containsAllClients(Vector elements) { - return clients.containsAll(elements); - } - - /** - * - * @uml.property name="clients" - */ - public int clientsSize() { - return clients.size(); - } - - /** - * - * @uml.property name="clients" - */ - public Client[] clientsToArray() { - return (Client[]) clients - .toArray(new Client[clients.size()]); - } - /** * Creates an account for the person named name. * If no client has this name, a new client object is created and is added to the list of clients, then the account is created @@ -165,7 +74,7 @@ public class Bank { e.printStackTrace(); } p.addAccounts(a); - this.addAccounts(a); + this.accounts.add(a); }; return accountNumbers; } @@ -183,7 +92,7 @@ public class Bank { a.removeClients(tmp.get(i)); } - this.removeAccounts(a); + this.accounts.remove(a); } else{ Exception error = new Exception("The account number "+accountNumber+" does not exist. Impossible to close this account"); @@ -199,13 +108,20 @@ public class Bank { ab = a; } + public ReferenceUniDi getClientRef(){ + return clients; + } + + public ReferenceUniDi getAccountRef(){ + return accounts; + } /** * Looks for a person named name in the set of clients. * Returns the Client object corresponding to the client if it exists * Returns null if there is no client named name */ public Client getClient(String name) { - Iterator it = this.clientsIterator(); + Iterator it = this.clients.iterator(); while (it.hasNext()){ Client p = (Client)it.next(); if(p.getName()==name){ @@ -223,7 +139,7 @@ public class Bank { * The assumption is that there cannot be several accounts with the same number */ public Account getAccount(int accountNumber) { - Iterator it = this.accountsIterator(); + Iterator it = this.accounts.iterator(); while (it.hasNext()){ Account a = (Account)it.next(); if(a.getNumber()==accountNumber){ @@ -277,95 +193,5 @@ public class Bank { return null; } } - - /** - * - * @uml.property name="accounts" - */ - public Vector getAccounts() { - return accounts; - } - - /** - * - * @uml.property name="accounts" - */ - public void setAccounts(Vector value) { - accounts = value; - } - - /** - * - * @uml.property name="accounts" - */ - public Iterator accountsIterator() { - return accounts.iterator(); - } - - /** - * - * @uml.property name="accounts" - */ - public boolean addAccounts(Account element) { - return accounts.add(element); - } - - /** - * - * @uml.property name="accounts" - */ - public boolean removeAccounts(Account element) { - return accounts.remove(element); - } - - /** - * - * @uml.property name="accounts" - */ - public boolean isAccountsEmpty() { - return accounts.isEmpty(); - } - - /** - * - * @uml.property name="accounts" - */ - public void clearAccounts() { - accounts.clear(); - } - - /** - * - * @uml.property name="accounts" - */ - public boolean containsAccounts(Account element) { - return accounts.contains(element); - } - - /** - * - * @uml.property name="accounts" - */ - public boolean containsAllAccounts(Vector elements) { - return accounts.containsAll(elements); - } - - /** - * - * @uml.property name="accounts" - */ - public int accountsSize() { - return accounts.size(); - } - - /** - * - * @uml.property name="accounts" - */ - public Account[] accountsToArray() { - return (Account[]) accounts - .toArray(new Account[accounts.size()]); - } - } diff --git a/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java b/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java index 66ed5988..78e61547 100644 --- a/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java +++ b/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java @@ -1,6 +1,7 @@ package fr.unantes.software.construction; import java.util.ArrayList; +import java.util.Iterator; public class ReferenceUniDi{ private ArrayList list; @@ -8,6 +9,18 @@ public class ReferenceUniDi{ list = new ArrayList(); } + public ArrayList get(){ + return list; + } + + public void set(ArrayList v){ + list = v; + } + + public Iterator iterator(){ + return list.iterator(); + } + public void add(T obj){ list.add(obj); } @@ -16,7 +29,27 @@ public class ReferenceUniDi{ list.remove(obj); } - public ArrayList get(){ - return list; + public boolean isEmpty(){ + return list.isEmpty(); + } + + public void clear(){ + list.clear(); + } + + public boolean contains(T ele){ + return list.contains(ele); + } + + public boolean containsAll(ArrayList ele){ + return list.containsAll(ele); + } + + public int size(){ + return list.size(); + } + + public T[] toArray(){ + return (T[])list.toArray(); } } diff --git a/src/main/java/fr/unantes/software/construction/ui/TextualUserInterface.java b/src/main/java/fr/unantes/software/construction/ui/TextualUserInterface.java index 6e48574b..c0a6fd76 100755 --- a/src/main/java/fr/unantes/software/construction/ui/TextualUserInterface.java +++ b/src/main/java/fr/unantes/software/construction/ui/TextualUserInterface.java @@ -154,7 +154,7 @@ public class TextualUserInterface { */ public static void clients(){ System.out.println("The list of clients of the bank is:"); - Iterator it = bank.clientsIterator(); + Iterator it = bank.getClientRef().iterator(); while(it.hasNext()){ Client client = (Client)it.next(); System.out.println(client.getName()); @@ -165,7 +165,7 @@ public class TextualUserInterface { * Displays the list of accounts in the bank (number, balance and overdraft) */ public static void displayAccounts() { - Iterator it = bank.accountsIterator(); + Iterator it = bank.getAccountRef().iterator(); Account acc= (Account)it.next();; while(it.hasNext()){ System.out.println("Account number "+acc.getNumber()+" is owned by "+acc.getOwner().getName()); -- GitLab From 0c67c0edce8667a70a1d68447c83d4c11c021443 Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Wed, 1 Apr 2020 21:32:37 +0200 Subject: [PATCH 16/35] Encapsulation 2 --- .../construction/address/Address.java | 10 ++++---- .../construction/address/AddressList.java | 2 +- .../software/construction/address/Card.java | 10 ++++---- .../construction/address/CardList.java | 2 +- .../software/construction/address/City.java | 4 +-- .../construction/address/CompanyAddress.java | 11 +++----- .../construction/address/CompanyCard.java | 25 ++++++++----------- .../software/construction/address/Phone.java | 4 +-- .../construction/address/PhoneList.java | 2 +- .../construction/address/PrivateAddress.java | 11 +++----- .../construction/address/PrivateCard.java | 22 ++++++++-------- 11 files changed, 47 insertions(+), 56 deletions(-) diff --git a/src/main/java/fr/unantes/software/construction/address/Address.java b/src/main/java/fr/unantes/software/construction/address/Address.java index af43d4f7..003ec3d1 100755 --- a/src/main/java/fr/unantes/software/construction/address/Address.java +++ b/src/main/java/fr/unantes/software/construction/address/Address.java @@ -8,11 +8,11 @@ package fr.unantes.software.construction.address; */ public abstract class Address { - protected int _voie; - protected String _rue; - protected City _ville; - protected int _code_postal; - protected String _comAd; + private int _voie; + private String _rue; + private City _ville; + private int _code_postal; + private String _comAd; public Address() { _voie = 0; diff --git a/src/main/java/fr/unantes/software/construction/address/AddressList.java b/src/main/java/fr/unantes/software/construction/address/AddressList.java index 9277106c..d6d7c33f 100755 --- a/src/main/java/fr/unantes/software/construction/address/AddressList.java +++ b/src/main/java/fr/unantes/software/construction/address/AddressList.java @@ -12,7 +12,7 @@ import java.util.*; public class AddressList { /** Les attributs d'instance */ - protected Vector adresses; + private Vector adresses; /** Les Constructeurs */ diff --git a/src/main/java/fr/unantes/software/construction/address/Card.java b/src/main/java/fr/unantes/software/construction/address/Card.java index 8a356cba..3bb9c624 100755 --- a/src/main/java/fr/unantes/software/construction/address/Card.java +++ b/src/main/java/fr/unantes/software/construction/address/Card.java @@ -10,11 +10,11 @@ import fr.unantes.software.construction.Client; public abstract class Card { - protected String identification; - protected GroupList _grp = new GroupList(); - protected AddressList _ad = new AddressList(); - protected PhoneList _tel= new PhoneList(); - protected MailList _mail = new MailList(); + private String identification; + private GroupList _grp = new GroupList(); + private AddressList _ad = new AddressList(); + private PhoneList _tel= new PhoneList(); + private MailList _mail = new MailList(); private ClientReference client; /** diff --git a/src/main/java/fr/unantes/software/construction/address/CardList.java b/src/main/java/fr/unantes/software/construction/address/CardList.java index 16041c98..9db3238f 100755 --- a/src/main/java/fr/unantes/software/construction/address/CardList.java +++ b/src/main/java/fr/unantes/software/construction/address/CardList.java @@ -5,7 +5,7 @@ import java.util.*; public class CardList { /** Les attributs d'instance */ - protected Vector _listeCard; + private Vector _listeCard; /** Les Constructeurs */ diff --git a/src/main/java/fr/unantes/software/construction/address/City.java b/src/main/java/fr/unantes/software/construction/address/City.java index 00cf4ae8..e186cf59 100644 --- a/src/main/java/fr/unantes/software/construction/address/City.java +++ b/src/main/java/fr/unantes/software/construction/address/City.java @@ -4,8 +4,8 @@ package fr.unantes.software.construction.address; * A city */ public class City { - public String country; - public String name; + private String country; + private String name; public City(String country, String name) { this.country = country; diff --git a/src/main/java/fr/unantes/software/construction/address/CompanyAddress.java b/src/main/java/fr/unantes/software/construction/address/CompanyAddress.java index 65eea569..f09ffe32 100755 --- a/src/main/java/fr/unantes/software/construction/address/CompanyAddress.java +++ b/src/main/java/fr/unantes/software/construction/address/CompanyAddress.java @@ -41,11 +41,8 @@ public class CompanyAddress extends Address { * @param f une adresse */ public CompanyAddress(CompanyAddress f) { + super(f.getVoie(),f.getRue(),f.getVille(),f.getCode_postal(),f.getComAd()); _secteur = f.getSecteur(); - _voie = f.getVoie(); - _rue = f.getRue(); - _ville = f.getVille(); - _code_postal = f.getCode_postal(); } /** @@ -65,11 +62,11 @@ public class CompanyAddress extends Address { public String toString() { return super.toString() - + " " + _secteur; + + " " + getSecteur(); } public String toXML() { - return ("" + _voie + "/" + _rue + "/" + _ville + "/" - + _code_postal + "/" + _secteur + ""); + return ("" + getVoie() + "/" + getRue() + "/" + getVille() + "/" + + getCode_postal() + "/" + getSecteur() + ""); } } diff --git a/src/main/java/fr/unantes/software/construction/address/CompanyCard.java b/src/main/java/fr/unantes/software/construction/address/CompanyCard.java index b4b37a7a..6c9b2fca 100755 --- a/src/main/java/fr/unantes/software/construction/address/CompanyCard.java +++ b/src/main/java/fr/unantes/software/construction/address/CompanyCard.java @@ -5,8 +5,7 @@ import fr.unantes.software.construction.Entreprise; public class CompanyCard extends Card { - protected String _raison_social; - + private String _raison_social; public CompanyCard(String raison_social) { super(raison_social); @@ -14,7 +13,6 @@ public class CompanyCard extends Card { } - public String getRaisonSocial() { return _raison_social; } @@ -24,13 +22,13 @@ public class CompanyCard extends Card { } public CompanyCard mergeCompanyCard(CompanyCard f) { - CompanyCard res = new CompanyCard(identification); - f.setIdentification(identification); - f.setRaisonSocial(_raison_social); - res.setListeAdresse(_ad.fusion(f.getListeAdresse())); - res.setListeTel(_tel.merge(f.getListeTel())); - res.setListeMail(_mail.merge(f.getListeMail())); - res.setListeGroupe(_grp.merge(f.getListeGroupe())); + CompanyCard res = new CompanyCard(getIdentification()); + f.setIdentification(getIdentification()); + f.setRaisonSocial(getRaisonSocial()); + res.setListeAdresse(getListeAdresse().fusion(f.getListeAdresse())); + res.setListeTel(getListeTel().merge(f.getListeTel())); + res.setListeMail(getListeMail().merge(f.getListeMail())); + res.setListeGroupe(getListeGroupe().merge(f.getListeGroupe())); return res; } @@ -40,7 +38,7 @@ public class CompanyCard extends Card { * @see Card#merge(Card) */ public Card merge(Card f) { - Card res = new PrivateCard(identification); + Card res = new PrivateCard(getIdentification()); if (memeFiche(f)) res = f.mergeCompanyCard(this); return res; @@ -51,8 +49,8 @@ public class CompanyCard extends Card { } public String toXML() { - return ("" + identification + _raison_social + _ad.toXML() - + _tel.toXML() + _mail.toXML() + _grp.toXML() + ""); + return ("" + getIdentification() + _raison_social + getListeAdresse().toXML() + + getListeTel().toXML() + getListeMail().toXML() + getListeGroupe().toXML() + ""); } public void setClient(Client c){ @@ -60,5 +58,4 @@ public class CompanyCard extends Card { getClientReference().set(c); } } - } diff --git a/src/main/java/fr/unantes/software/construction/address/Phone.java b/src/main/java/fr/unantes/software/construction/address/Phone.java index 1da61370..20b94cdd 100755 --- a/src/main/java/fr/unantes/software/construction/address/Phone.java +++ b/src/main/java/fr/unantes/software/construction/address/Phone.java @@ -7,8 +7,8 @@ package fr.unantes.software.construction.address; */ public class Phone { - protected int number = 0; - protected String comment; + private int number = 0; + private String comment; public Phone(int num, String com) { number = num; diff --git a/src/main/java/fr/unantes/software/construction/address/PhoneList.java b/src/main/java/fr/unantes/software/construction/address/PhoneList.java index fb0d4a85..3424ae2e 100755 --- a/src/main/java/fr/unantes/software/construction/address/PhoneList.java +++ b/src/main/java/fr/unantes/software/construction/address/PhoneList.java @@ -4,7 +4,7 @@ import java.util.*; public class PhoneList { - protected Vector telephones; + private Vector telephones; public PhoneList() { telephones = new Vector(); diff --git a/src/main/java/fr/unantes/software/construction/address/PrivateAddress.java b/src/main/java/fr/unantes/software/construction/address/PrivateAddress.java index 96809b11..379b612a 100755 --- a/src/main/java/fr/unantes/software/construction/address/PrivateAddress.java +++ b/src/main/java/fr/unantes/software/construction/address/PrivateAddress.java @@ -33,11 +33,8 @@ public class PrivateAddress extends Address { * @param f une adresse */ public PrivateAddress(PrivateAddress f) { - _voie = f.getVoie(); - _rue = f.getRue(); + super(f.getVoie(),f.getRue(),f.getVille(),f.getCode_postal(),f.getComAd()); lieuDit = f.getLieu_dit(); - _ville = f.getVille(); - _code_postal = f.getCode_postal(); } /** Les accesseurs */ @@ -59,11 +56,11 @@ public class PrivateAddress extends Address { } public String toString() { - return ("" + _voie + ", " + _rue + " " + lieuDit + " " + _ville + " " + _code_postal); + return ("" + getVoie() + ", " + getRue() + " " + lieuDit + " " + getVille() + " " + getCode_postal()); } public String toXML() { - return ("" + _voie + "/" + _rue + "/" + lieuDit + "/" - + _ville + "/" + _code_postal + ""); + return ("" + getVoie() + "/" + getRue() + "/" + lieuDit + "/" + + getVille() + "/" + getCode_postal() + ""); } } diff --git a/src/main/java/fr/unantes/software/construction/address/PrivateCard.java b/src/main/java/fr/unantes/software/construction/address/PrivateCard.java index e8f4a09a..0cb774ca 100755 --- a/src/main/java/fr/unantes/software/construction/address/PrivateCard.java +++ b/src/main/java/fr/unantes/software/construction/address/PrivateCard.java @@ -12,8 +12,8 @@ import fr.unantes.software.construction.Particulier; public class PrivateCard extends Card { /** attributs d'insatance */ - protected String _prenom; - protected String _nomP; + private String _prenom; + private String _nomP; public PrivateCard(String nom, String prenom) { @@ -65,7 +65,7 @@ public class PrivateCard extends Card { * @return fiche resultant de la fusion de la fiche courante et celle passee en parametre */ public Card merge(Card f) { - Card res = new PrivateCard(identification); + Card res = new PrivateCard(getIdentification()); if (memeFiche(f)) res = f.fusionFichePart(this); return res; @@ -76,23 +76,23 @@ public class PrivateCard extends Card { } public PrivateCard fusionFichePart(PrivateCard f) { - PrivateCard res = new PrivateCard(identification); - res.setIdentification(identification); + PrivateCard res = new PrivateCard(getIdentification()); + res.setIdentification(getIdentification()); res.setNomP(_nomP); if (_prenom == null) res.setPrenom(f.getPrenom()); else res.setPrenom(_prenom); - res.setListeAdresse(_ad.fusion(f.getListeAdresse())); - res.setListeTel(_tel.merge(f.getListeTel())); - res.setListeMail(_mail.merge(f.getListeMail())); - res.setListeGroupe(_grp.merge(f.getListeGroupe())); + res.setListeAdresse(getListeAdresse().fusion(f.getListeAdresse())); + res.setListeTel(getListeTel().merge(f.getListeTel())); + res.setListeMail(getListeMail().merge(f.getListeMail())); + res.setListeGroupe(getListeGroupe().merge(f.getListeGroupe())); return res; } public String toXML() { - return ("" + identification + _nomP + _prenom + _ad.toXML() - + _tel.toXML() + _mail.toXML() + _grp.toXML() + ""); + return ("" + getIdentification() + _nomP + _prenom + getListeAdresse().toXML() + + getListeTel().toXML() + getListeMail().toXML() + getListeGroupe().toXML() + ""); } public void setClient(Client c){ -- GitLab From a1f1185ae93da10d358a8948c794c5f3ccbcf0db Mon Sep 17 00:00:00 2001 From: Curtis Meda Date: Thu, 2 Apr 2020 18:02:20 +0200 Subject: [PATCH 17/35] Documentation --- .../software/construction/Account.java | 88 ++++++++++-------- .../unantes/software/construction/Bank.java | 39 ++++---- .../unantes/software/construction/Client.java | 43 +++++++-- .../construction/DepositOperation.java | 9 +- .../software/construction/Entreprise.java | 17 ++++ .../software/construction/Operation.java | 17 +++- .../software/construction/Particulier.java | 17 ++++ .../software/construction/ReferenceUniDi.java | 92 +++++++++++-------- .../construction/WithdrawOperation.java | 9 +- .../construction/address/Address.java | 44 ++++----- .../construction/address/AddressBook.java | 36 ++++++-- .../construction/address/AddressList.java | 41 ++++----- .../software/construction/address/Card.java | 73 +++++++++------ .../construction/address/CardList.java | 39 ++++---- .../software/construction/address/City.java | 22 +++++ .../construction/address/CompanyAddress.java | 18 ++-- .../construction/address/CompanyCard.java | 29 +++++- .../software/construction/address/Group.java | 36 ++++---- .../construction/address/GroupList.java | 48 ++++++---- .../software/construction/address/Mail.java | 16 +++- .../construction/address/MailList.java | 38 ++++---- .../software/construction/address/Phone.java | 17 +++- .../construction/address/PhoneList.java | 35 ++++--- .../construction/address/PrivateAddress.java | 18 ++-- .../construction/address/PrivateCard.java | 42 ++++++--- 25 files changed, 563 insertions(+), 320 deletions(-) diff --git a/src/main/java/fr/unantes/software/construction/Account.java b/src/main/java/fr/unantes/software/construction/Account.java index 4d1cf909..5fab56ce 100755 --- a/src/main/java/fr/unantes/software/construction/Account.java +++ b/src/main/java/fr/unantes/software/construction/Account.java @@ -8,35 +8,38 @@ import java.util.Vector; import java.util.Iterator; public class Account { + + /** + * attributes + */ private OperationReference operation; private String type; private ClientReference clients; + /** - * * This attribute memorizes the current balance of the account - * */ private float balance; + /** - * * this is the maximum overdraft authorized for this account - * */ private float overdraft; + /** - * * @uml.property name="history" * @uml.associationEnd inverse="compte:fr.unantes.software.construction.Operation" multiplicity="(0 -1)" - * */ private Collection history; + /** - * * this is the number of the account - * */ private int number; + /** + * this is the owner + */ private Client owner; /** @@ -93,12 +96,14 @@ public class Account { } } + /** + * @return owner + */ public Client getOwner(){ return owner; } /** - * * @uml.property name="history" */ public java.util.Collection getHistory() { @@ -106,7 +111,7 @@ public class Account { } /** - * + * @role set l'history * @uml.property name="history" */ public void setHistory(java.util.Collection value) { @@ -114,7 +119,6 @@ public class Account { } /** - * * @uml.property name="history" */ public Iterator historyIterator() { @@ -122,7 +126,7 @@ public class Account { } /** - * + * @role ajoute une operation * @uml.property name="history" */ public boolean addHistory(Operation element) { @@ -130,7 +134,7 @@ public class Account { } /** - * + * @role retire une operation * @uml.property name="history" */ public boolean removeHistory(Operation element) { @@ -138,7 +142,7 @@ public class Account { } /** - * + * @role Savoir si l'history est vide * @uml.property name="history" */ public boolean isHistoryEmpty() { @@ -146,7 +150,7 @@ public class Account { } /** - * + * @role vider l'history * @uml.property name="history" */ public void clearHistory() { @@ -154,7 +158,7 @@ public class Account { } /** - * + * @role savoir si l'history contient une operation * @uml.property name="history" */ public boolean containsHistory(Operation element) { @@ -170,7 +174,7 @@ public class Account { } /** - * + * @role avoir la taille de l'history * @uml.property name="history" */ public int historySize() { @@ -178,7 +182,6 @@ public class Account { } /** - * * @uml.property name="history" */ public Operation[] historyToArray() { @@ -186,71 +189,69 @@ public class Account { .toArray(new Operation[history.size()]); } - public String getType(){ - return type; - } + /** + * @return type + */ + public String getType(){ return type; } - public void setType(String t){ - type = t; - } + /** + * @role set le type + * @param t + */ + public void setType(String t){ type = t; } /** - * * @uml.property name="overdraft" - * + * @return overdraft */ public float getOverdraft() { return overdraft; } /** - * + * @role set le overdraft * @uml.property name="overdraft" - * */ public void setOverdraft(float overdraft) { this.overdraft = overdraft; } /** - * * @uml.property name="balance" - * + * @return balance */ public float getBalance() { return balance; } /** - * + * @role set balance * @uml.property name="balance" - * */ public void setBalance(float balance) { this.balance = balance; } /** - * * @uml.property name="number" - * + * @return number */ public int getNumber() { return number; } /** - * + * @role set le number * @uml.property name="number" - * */ public void setNumber(int number) { this.number = number; } - - + /** + * @role classe de reference + */ public class ClientReference { private ArrayList clients; public ClientReference(){ @@ -282,12 +283,14 @@ public class Account { /** * @uml.property name="clients" + * @return clients */ public ClientReference getClients() { return clients; } /** + * @role ajouter un client * @uml.property name="clients" */ public void addClients(Client element) { @@ -297,6 +300,7 @@ public class Account { } /** + * @role retire un client * @uml.property name="clients" */ public void removeClients(Client element) { @@ -317,6 +321,7 @@ public class Account { } /** + * @role vider client * @uml.property name="clients" */ public void clearClients() { @@ -324,6 +329,7 @@ public class Account { } /** + * @role savoir si un client est deja client * @uml.property name="clients" */ public boolean containsClients(Client element) { @@ -331,6 +337,7 @@ public class Account { } /** + * @role taille de client * @uml.property name="clients" */ public int clientsSize() { @@ -338,8 +345,9 @@ public class Account { } - - + /** + * @role classe de reference + */ public class OperationReference { private ArrayList operations; public OperationReference(){ diff --git a/src/main/java/fr/unantes/software/construction/Bank.java b/src/main/java/fr/unantes/software/construction/Bank.java index e63d5281..57b83d52 100755 --- a/src/main/java/fr/unantes/software/construction/Bank.java +++ b/src/main/java/fr/unantes/software/construction/Bank.java @@ -6,26 +6,25 @@ import java.io.InvalidClassException; import java.util.Iterator; public class Bank { + /** + * Attributes + */ private AddressBook ab; + /** - * * this is a counter that is incremented each time a new account is created - * */ private int accountNumbers; + /** - * * @uml.property name="clients" * @uml.associationEnd inverse="bank:fr.unantes.software.construction.Client" multiplicity="(0 -1)" - * */ private ReferenceUniDi clients; /** - * * @uml.property name="accounts" * @uml.associationEnd aggregation="composite" inverse="bank:fr.unantes.software.construction.Account" multiplicity="(0 -1)" - * */ private ReferenceUniDi accounts; @@ -41,18 +40,16 @@ public class Bank { } /** - * * @uml.property name="accountNumbers" - * + * @return accountNumbers */ public int getAccountNumbers() { return accountNumbers; } /** - * + * @role set le numero de compte * @uml.property name="accountNumbers" - * */ public void setAccountNumbers(int accountNumbers) { this.accountNumbers = accountNumbers; @@ -100,21 +97,31 @@ public class Bank { } } - public AddressBook getAb(){ - return ab; - } + /** + * @return ab + */ + public AddressBook getAb(){ return ab; } - public void setAb(AddressBook a){ - ab = a; - } + /** + * @role set ab + * @param a + */ + public void setAb(AddressBook a){ ab = a; } + /** + * @return clients + */ public ReferenceUniDi getClientRef(){ return clients; } + /** + * @return accounts + */ public ReferenceUniDi getAccountRef(){ return accounts; } + /** * Looks for a person named name in the set of clients. * Returns the Client object corresponding to the client if it exists diff --git a/src/main/java/fr/unantes/software/construction/Client.java b/src/main/java/fr/unantes/software/construction/Client.java index c277e68b..d384d24a 100644 --- a/src/main/java/fr/unantes/software/construction/Client.java +++ b/src/main/java/fr/unantes/software/construction/Client.java @@ -12,7 +12,7 @@ import java.util.Vector; public abstract class Client { /** - * The name of the client + * Attributes */ private String name; private String role; @@ -20,6 +20,11 @@ public abstract class Client { private AccountReference account; + /** + * @param name + * @param role + * @throws InvalidClassException + */ public Client(String name, String role) throws InvalidClassException { if (!role.equals("private") && !role.equals("company")) { throw new InvalidClassException("Invalid role supplied. A person can only be private or company"); @@ -31,18 +36,33 @@ public abstract class Client { card = new CardReference(); } + /** + * @return name + */ public String getName() { return name; } + /** + * @role set le nom + * @param name + */ public void setName(String name) { this.name = name; } + /** + * @return role + */ public String getRole() { return role; } + /** + * @role set le role + * @param role + * @throws InvalidClassException + */ public void setRole(String role) throws InvalidClassException { if (!role.equals("private") && !role.equals("company")) { throw new InvalidClassException("Invalid role supplied. A person can only be private or company"); @@ -65,11 +85,9 @@ public abstract class Client { } - - - - - + /** + * @role classe reference + */ public class AccountReference { private ArrayList account; public AccountReference(){ @@ -97,12 +115,14 @@ public abstract class Client { /** * @uml.property name="accounts" + * @return account */ public AccountReference getAccounts() { return account; } /** + * @role ajouter un compte * @uml.property name="accounts" */ public void addAccounts(Account element) { @@ -112,6 +132,7 @@ public abstract class Client { } /** + * @role retirer un compte * @uml.property name="accounts" */ public void removeAccounts(Account element) { @@ -121,6 +142,7 @@ public abstract class Client { } /** + * @role savoir si le compte est vide * @uml.property name="accounts" */ public boolean isAccountsEmpty() { @@ -132,6 +154,7 @@ public abstract class Client { } /** + * @role clear un compte * @uml.property name="accounts" */ public void clearAccounts() { @@ -146,20 +169,22 @@ public abstract class Client { } /** + * @role taille du compte * @uml.property name="accounts" */ public int accountsSize() { return account.account.size(); } + public Account[] accountsToArray(){ return (Account[]) account.account.toArray(); } - - - + /** + * @role classe de reference + */ public class CardReference { private Card car; public CardReference(){ diff --git a/src/main/java/fr/unantes/software/construction/DepositOperation.java b/src/main/java/fr/unantes/software/construction/DepositOperation.java index ad56c7ed..d6536fab 100755 --- a/src/main/java/fr/unantes/software/construction/DepositOperation.java +++ b/src/main/java/fr/unantes/software/construction/DepositOperation.java @@ -6,14 +6,13 @@ import java.time.LocalTime; public class DepositOperation extends Operation { /** - * Calls the constructor of super class with the parameter amount + * @param amount + * @param i */ - public DepositOperation(float amount, LocalTime i) { - super(amount, i); - } + public DepositOperation(float amount, LocalTime i) { super(amount, i); } /** - * returns "Deposit" + * @return Deposit */ public String getOperationType() { return "Deposit"; diff --git a/src/main/java/fr/unantes/software/construction/Entreprise.java b/src/main/java/fr/unantes/software/construction/Entreprise.java index acf1e79b..9755dc32 100644 --- a/src/main/java/fr/unantes/software/construction/Entreprise.java +++ b/src/main/java/fr/unantes/software/construction/Entreprise.java @@ -13,15 +13,32 @@ public class Entreprise extends Client { */ private CompanyAddress addressEntreprise; + /** + * @param name + * @param role + * @param address + * @throws InvalidClassException + */ public Entreprise(String name, String role, CompanyAddress address ) throws InvalidClassException { super(name, role); addressEntreprise = address; } + /** + * @return addressEntreprise + */ public CompanyAddress getAddressEntreprise() { return addressEntreprise; } + /** + * @role set l'adresse + * @param address + */ public void setAddressEntreprise(CompanyAddress address) { this.addressEntreprise = address; } + /** + * @role set la carte + * @param c + */ public void setCard(Card c){ if(c.getClass().equals(CompanyCard.class)){ getCardReference().set(c); diff --git a/src/main/java/fr/unantes/software/construction/Operation.java b/src/main/java/fr/unantes/software/construction/Operation.java index 79434cc3..b887a121 100755 --- a/src/main/java/fr/unantes/software/construction/Operation.java +++ b/src/main/java/fr/unantes/software/construction/Operation.java @@ -4,6 +4,9 @@ import java.time.*; public abstract class Operation { + /** + * Attributes + */ private AccountReference account; private LocalTime time; @@ -14,14 +17,19 @@ public abstract class Operation { /** * @uml.property name="amount" + * @return amount */ public float getAmount() { return amount; } + /** + * @return time + */ public LocalTime getTime(){ return time; } /** + * @role set amount * @uml.property name="amount" */ public void setAmount(float amount) { @@ -29,7 +37,8 @@ public abstract class Operation { } /** - * Sets the amount with the parameter + * @param amount + * @param i */ public Operation(float amount, LocalTime i) { this.amount = amount; @@ -42,9 +51,9 @@ public abstract class Operation { */ public abstract String getOperationType(); - - - + /** + * @role classe de reference + */ public class AccountReference { private Account acc; public AccountReference(){ diff --git a/src/main/java/fr/unantes/software/construction/Particulier.java b/src/main/java/fr/unantes/software/construction/Particulier.java index 27bec104..d0b39e73 100644 --- a/src/main/java/fr/unantes/software/construction/Particulier.java +++ b/src/main/java/fr/unantes/software/construction/Particulier.java @@ -13,15 +13,32 @@ public class Particulier extends Client { */ private PrivateAddress addressParticular; + /** + * @param name + * @param role + * @param address + * @throws InvalidClassException + */ public Particulier(String name, String role, PrivateAddress address) throws InvalidClassException { super(name,role); addressParticular = address; } + /** + * @return adressParticular + */ public PrivateAddress getAddressParticular() { return addressParticular; } + /** + * @role set l'address du particulier + * @param address + */ public void setAddressParticular(PrivateAddress address) { this.addressParticular = address; } + /** + * @role set la carte + * @param c + */ public void setCard(Card c){ if(c.getClass().equals(PrivateCard.class)){ getCardReference().set(c); diff --git a/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java b/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java index 78e61547..2bb7210d 100644 --- a/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java +++ b/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java @@ -4,52 +4,72 @@ import java.util.ArrayList; import java.util.Iterator; public class ReferenceUniDi{ + + /** + * Attributes + */ private ArrayList list; - public ReferenceUniDi(){ - list = new ArrayList(); - } - public ArrayList get(){ - return list; - } + /** + * Constructor empty + */ + public ReferenceUniDi(){ list = new ArrayList(); } + + /** + * @return list + */ + public ArrayList get(){ return list; } - public void set(ArrayList v){ - list = v; - } + /** + * @role set list + * @param v + */ + public void set(ArrayList v){ list = v; } - public Iterator iterator(){ - return list.iterator(); - } + /** + * @return iterator + */ + public Iterator iterator(){ return list.iterator(); } - public void add(T obj){ - list.add(obj); - } + /** + * @role ajouter + * @param obj + */ + public void add(T obj){ list.add(obj); } - public void remove(T obj){ - list.remove(obj); - } + /** + * @role retirer + * @param obj + */ + public void remove(T obj){ list.remove(obj); } - public boolean isEmpty(){ - return list.isEmpty(); - } + /** + * @role savoir si la liste est vide + */ + public boolean isEmpty(){ return list.isEmpty(); } - public void clear(){ - list.clear(); - } + /** + * @role clear la liste + */ + public void clear(){ list.clear(); } - public boolean contains(T ele){ - return list.contains(ele); - } + /** + * @role savoir si la liste contient l'element + * @param ele + */ + public boolean contains(T ele){ return list.contains(ele); } - public boolean containsAll(ArrayList ele){ - return list.containsAll(ele); - } + /** + * @role savoir si la liste contient une autre liste + * @param ele + */ + public boolean containsAll(ArrayList ele){ return list.containsAll(ele); } - public int size(){ - return list.size(); - } + /** + * @role taille de la liste + * @return + */ + public int size(){ return list.size(); } - public T[] toArray(){ - return (T[])list.toArray(); - } + public T[] toArray(){ return (T[])list.toArray(); } } diff --git a/src/main/java/fr/unantes/software/construction/WithdrawOperation.java b/src/main/java/fr/unantes/software/construction/WithdrawOperation.java index 53b9d220..4ac3a325 100755 --- a/src/main/java/fr/unantes/software/construction/WithdrawOperation.java +++ b/src/main/java/fr/unantes/software/construction/WithdrawOperation.java @@ -6,14 +6,13 @@ import java.time.LocalTime; public class WithdrawOperation extends Operation { /** - * calls the super constructor with the amount + * @param amount + * @param i */ - public WithdrawOperation(float amount, LocalTime i) { - super(amount, i); - } + public WithdrawOperation(float amount, LocalTime i) { super(amount, i); } /** - * returns "Withdraw" + * @return withdraw */ public String getOperationType() { return "Withdraw"; diff --git a/src/main/java/fr/unantes/software/construction/address/Address.java b/src/main/java/fr/unantes/software/construction/address/Address.java index 003ec3d1..9165597c 100755 --- a/src/main/java/fr/unantes/software/construction/address/Address.java +++ b/src/main/java/fr/unantes/software/construction/address/Address.java @@ -1,27 +1,31 @@ package fr.unantes.software.construction.address; /** - * * @author * @version 1.0 * @date 17/12/2004. */ public abstract class Address { + /** + * Attributes + */ private int _voie; private String _rue; private City _ville; private int _code_postal; private String _comAd; + /** + * Constructor empty + */ public Address() { _voie = 0; _code_postal = 0; } /** - * - * @param uneVoie le numero de la voie + * @param uneVoie le numero de la voie * @param rue le nom de la rue * @param ville le nom de la ville * @param code_postal le numero de code postal @@ -36,9 +40,7 @@ public abstract class Address { } /** - * - * - * @param f une adresse + * @param f une address */ public Address(Address f) { this._voie = f.getVoie(); @@ -47,22 +49,21 @@ public abstract class Address { this._code_postal = f.getCode_postal(); } - - /* - * @return _voie le numetro de la voie + /** + * @return _voie le numero de la voie */ public int getVoie() { return _voie; } - /* + /** * @return _rue le nom de la rue */ public String getRue() { return _rue; } - /* + /** * @return _ville le nom de la ville */ public City getVille() { @@ -77,13 +78,14 @@ public abstract class Address { } /** - * @return _lieu_dit le nom du lieu dit + * @return _comAd commentaire address */ public String getComAd() { return _comAd; } /** + * @role set le nom de la voie * @param voie */ public void setVoie(int voie) { @@ -91,42 +93,42 @@ public abstract class Address { } /** - * @param rue le nom de la rue + * @role set le nom de la rue + * @param rue */ public void setRue(String rue) { _rue = rue; } /** - * @param comAd le nom du lieu dit + * @role set le nom du lieu dit + * @param comAd */ public void setComAd(String comAd) { _comAd = comAd; } /** + * @role set le nom de la ville * @param ville - * le nom de la ville */ public void setVille(City ville) { _ville = ville; } /** - * @param code_postal le numero de code postal + * @role set le numero de code postal + * @param code_postal */ public void setCode_postal(int code_postal) { _code_postal = code_postal; } - /** - * - */ + public String toString() { return ("" + _voie + ", " + _rue + " " + _ville + " " + _code_postal ); } - - + public abstract String toXML(); } diff --git a/src/main/java/fr/unantes/software/construction/address/AddressBook.java b/src/main/java/fr/unantes/software/construction/address/AddressBook.java index aa5c64e9..c9c0e4af 100755 --- a/src/main/java/fr/unantes/software/construction/address/AddressBook.java +++ b/src/main/java/fr/unantes/software/construction/address/AddressBook.java @@ -1,7 +1,6 @@ package fr.unantes.software.construction.address; /** - * * @author * @version 1.0 * @date 17/12/2004. @@ -9,43 +8,64 @@ package fr.unantes.software.construction.address; public class AddressBook { - + /** + * Attributes + */ private String _nom; private CardList fiches; + /** + * Constructor empty + */ public AddressBook() { fiches = new CardList(); } + /** + * @param nom nom de l'adresseBook + * @param lF liste de cartes + */ public AddressBook(String nom, CardList lF) { _nom = nom; fiches = new CardList(); fiches.setListeCard(lF.getListeCard()); } + /** + * @return _nom le nom + */ public String getNom() { return _nom; } + /** + * @return fiches la liste de cartes + */ public CardList getListe() { return fiches; } + /** + * @role set le nom + * @param nom + */ public void setNom(String nom) { _nom = nom; } + /** + * @role set la liste de cartes + * @param lF + */ public void setListe(CardList lF) { fiches.setListeCard(lF.getListeCard()); } - /** - * Fusione deux reprtoires. Rend un nouvel objet. - * - * @param r - * @param nom - * @return + * @role Fusionne deux repertoires + * @param r adressBook + * @param nom un nom + * @return res fusion des deux répertoires */ public AddressBook merge(AddressBook r, String nom) { AddressBook res = new AddressBook(); diff --git a/src/main/java/fr/unantes/software/construction/address/AddressList.java b/src/main/java/fr/unantes/software/construction/address/AddressList.java index d6d7c33f..4e149f65 100755 --- a/src/main/java/fr/unantes/software/construction/address/AddressList.java +++ b/src/main/java/fr/unantes/software/construction/address/AddressList.java @@ -1,7 +1,6 @@ package fr.unantes.software.construction.address; /** - * * @author * @version 1.0 * @date 17/12/2004. @@ -11,17 +10,20 @@ import java.util.*; public class AddressList { - /** Les attributs d'instance */ + /** + * Attributes + */ private Vector adresses; - /** Les Constructeurs */ - + /** + * Constructor empty + */ public AddressList() { adresses = new Vector(); } /** - * @param lA un objet adresse que l'on veut copier + * @param lA une adresse */ public AddressList(AddressList lA) { adresses = new Vector(); @@ -31,17 +33,15 @@ public class AddressList { } } - /** Accesseur */ /** - * @return _listeAdresse + * @return adresses la liste d'adresses */ public Vector getListeAdresse() { return adresses; } - /** Modificateur */ - /** + * @role set la liste d'adresses * @param lA */ public void setListeAdresse(Vector lA) { @@ -51,7 +51,8 @@ public class AddressList { } /** - * @param a adresse a ajouter dans la liste + * @role ajoute une address + * @param a une address */ public void ajouter(Address a) { if (!rechercher(a)) @@ -59,7 +60,8 @@ public class AddressList { } /** - * @param a adresse a supprimer de la liste + * @role delete une address + * @param a une address */ public void supprimer(Address a) { if (rechercher(a)) @@ -69,25 +71,23 @@ public class AddressList { } /** - * @param a c'est l'adresse recherchee + * @role recherche une address + * @param a une address */ public boolean rechercher(Address a) { return adresses.contains(a); } /** - * fusion entre 2 listes dans une nouvelle. - * - * @param lA l'autre liste. - * @return une nouvelle liste, fusion des deux autres. - * + * @role : fusion entre deux listes + * @param lA liste a fusionner + * @return res fusion des deux listes */ public AddressList fusion(AddressList lA) { AddressList res = new AddressList(); /** - * on met toute les adresses de la premiere liste dans la liste de - * retour + * on met toutes les adresses de la premiere liste dans la liste de retour */ for (Enumeration e = adresses.elements(); e .hasMoreElements();) { @@ -95,8 +95,7 @@ public class AddressList { } /** - * on compare les adresses de liste de retour (adresse de la liste 1) - * avec la deuxieme liste + * on compare les adresses de liste de retour (adresses de la première liste ) avec la deuxieme liste */ for (Enumeration e1 = lA.getListeAdresse().elements(); e1 .hasMoreElements();) { diff --git a/src/main/java/fr/unantes/software/construction/address/Card.java b/src/main/java/fr/unantes/software/construction/address/Card.java index 3bb9c624..7f82b8a8 100755 --- a/src/main/java/fr/unantes/software/construction/address/Card.java +++ b/src/main/java/fr/unantes/software/construction/address/Card.java @@ -9,7 +9,9 @@ import fr.unantes.software.construction.Client; */ public abstract class Card { - + /** + * Attributes + */ private String identification; private GroupList _grp = new GroupList(); private AddressList _ad = new AddressList(); @@ -18,7 +20,7 @@ public abstract class Card { private ClientReference client; /** - * Constructeur sans parametres + * Constructor empty */ public Card(String nom) { identification = nom; @@ -27,122 +29,134 @@ public abstract class Card { /** - * @return _ad + * @return _ad la liste d'adresses */ public AddressList getListeAdresse() { return _ad; } /** - * @return _tel + * @return _tel la liste de telephones */ public PhoneList getListeTel() { return _tel; } /** - * @return _mail + * @return _mail la lite de mails */ public MailList getListeMail() { return _mail; } /** - * @return _grp + * @return _grp la liste des groupes */ public GroupList getListeGroupe() { return _grp; } - /** - * @param ad + * @role set la liste d'adresses + * @param ad une liste d'adresses */ public void setListeAdresse(AddressList ad) { _ad.setListeAdresse(ad.getListeAdresse()); } /** - * @param a + * @role ajoute une adresse + * @param a une adresse */ public void addAddress(Address a) { _ad.ajouter(a); } /** - * @param a + * @role supprime une adresse + * @param a une adresse */ public void deleteAddress(Address a) { _ad.supprimer(a); } /** - * @param tel + * @role set la liste de telephones + * @param tel une liste de telephones */ public void setListeTel(PhoneList tel) { _tel = tel; } /** - * @param mail + * @role set la liste de mails + * @param mail une liste de mails */ public void setListeMail(MailList mail) { _mail = mail; } /** - * @param grp + * @role set la liste de groupes + * @param grp une liste de groupes */ public void setListeGroupe(GroupList grp) { _grp.setListeGroupe(grp.getListeGroupe()); } /** - * @param grp + * @role ajoute un groupe + * @param grp un groupe */ public void addGroupe(Group grp) { _grp.add(grp); } /** - * @param grp + * @role supprimer une groupe + * @param grp un groupe */ public void deleteGroupe(Group grp) { _grp.delete(grp); } - /** - * Renvoie une fusion de deux fiches. - * @param f - * @return - */ public abstract Card merge(Card f); public abstract CompanyCard mergeCompanyCard(CompanyCard f); public abstract PrivateCard fusionFichePart(PrivateCard f); - public abstract String toXML(); + + /** + * @param f + * @return + */ public boolean memeFiche(Card f) { return (identification.equals(f.getIdentification())); } - /** - * @return _nomF nom de la fiche + * @return identification l'identificateur */ public String getIdentification() { return identification; } - + /** + * @role set l'identificateur + * @param str + */ public void setIdentification(String str) { identification = str; } - + + /** + * @param other + * @return + */ public boolean equals(Object other) { if (other instanceof Card) { return identification.equals(((Card) other).identification); @@ -151,12 +165,13 @@ public abstract class Card { } - - - - + /** + * @role classe de reference + */ public class ClientReference { private Client client; + + public ClientReference(){ client = null; } diff --git a/src/main/java/fr/unantes/software/construction/address/CardList.java b/src/main/java/fr/unantes/software/construction/address/CardList.java index 9db3238f..155cf6eb 100755 --- a/src/main/java/fr/unantes/software/construction/address/CardList.java +++ b/src/main/java/fr/unantes/software/construction/address/CardList.java @@ -4,17 +4,20 @@ import java.util.*; public class CardList { - /** Les attributs d'instance */ + /** + * Attributes + */ private Vector _listeCard; - /** Les Constructeurs */ - + /** + * Constructor empty + */ public CardList(){ _listeCard = new Vector(); } /** - * @param lF un objet adresse que l'on veux copier + * @param lF */ public CardList (CardList lF){ _listeCard = new Vector(); @@ -23,18 +26,16 @@ public class CardList { } } - /** Accesseur */ /** - * @return _listeCard + * @return _listeCard la liste de cartes */ public Vector getListeCard(){ return _listeCard; } - /** Modificateur */ - /** - * @param lF + * @role set la liste de cartes + * @param lF une liste de cartes */ public void setListeCard(Vector lF){ for (Enumeration e = lF.elements() ; e.hasMoreElements() ;) { @@ -43,13 +44,16 @@ public class CardList { } /** - * @param f fiche à ajouter dans la liste + * @role ajouter une carte + * @param f carte à ajouter dans la liste */ public void add(Card f){ if(!find(f)) _listeCard.add(f); } + /** - * @param f fiche à supprimer de la liste + * @role supprime une carte + * @param f carte à supprimer de la liste */ public void delete(Card f){ if (find(f)) _listeCard.remove(f); @@ -57,17 +61,17 @@ public class CardList { } /** - * @param f c'est la fiche rechercher + * @role recherche une carte + * @param f une carte */ public boolean find(Card f){ return _listeCard.contains(f); } - /** - * fusion entre 2 listes dans un 3° que l'on crée - * @param lF 2° liste a faire fusionner - * @return Liste la 3° liste fusion de la liste courante et de la liste passé en paramètre + *@role fusion entre deux listes de cartes + * @param lF liste a faire fusionner + * @return res la liste fusion de la liste courante et de la liste passé en paramètre */ public CardList merge(CardList lF){ CardList res = new CardList(); @@ -89,6 +93,9 @@ public class CardList { return res; } + /** + * @return res + */ public String toXML(){ String res = ""; Enumeration e = _listeCard.elements(); diff --git a/src/main/java/fr/unantes/software/construction/address/City.java b/src/main/java/fr/unantes/software/construction/address/City.java index e186cf59..2a4c4460 100644 --- a/src/main/java/fr/unantes/software/construction/address/City.java +++ b/src/main/java/fr/unantes/software/construction/address/City.java @@ -4,26 +4,48 @@ package fr.unantes.software.construction.address; * A city */ public class City { + + /** + * Attributes + */ private String country; private String name; + /** + * @param country le pays + * @param name le nom de la ville + */ public City(String country, String name) { this.country = country; this.name = name; } + /** + * @return country le pays + */ public String getCountry() { return country; } + /** + * @role set la country + * @param country un pays + */ public void setCountry(String country) { this.country = country; } + /** + * @return name le nom de la ville + */ public String getName() { return name; } + /** + * @role set le nom de la ville + * @param name le nom de la ville + */ public void setName(String name) { this.name = name; } diff --git a/src/main/java/fr/unantes/software/construction/address/CompanyAddress.java b/src/main/java/fr/unantes/software/construction/address/CompanyAddress.java index f09ffe32..fa36e524 100755 --- a/src/main/java/fr/unantes/software/construction/address/CompanyAddress.java +++ b/src/main/java/fr/unantes/software/construction/address/CompanyAddress.java @@ -9,21 +9,19 @@ package fr.unantes.software.construction.address; */ public class CompanyAddress extends Address { - /** Les attributs d'intance */ + /** + * Attributes + */ private String _secteur; - /** Les Constructeurs */ - /** - * Constructeur vide + * Constructor empty */ public CompanyAddress() { super(); } /** - * - * * @param voie le numero de la voie * @param rue le nom de la rue * @param secteur le secteur de la rue @@ -37,7 +35,6 @@ public class CompanyAddress extends Address { } /** - * * @param f une adresse */ public CompanyAddress(CompanyAddress f) { @@ -46,20 +43,21 @@ public class CompanyAddress extends Address { } /** - * @return _lieu_dit le nom du lieu dit + * @return _secteur le nom du secteur */ public String getSecteur() { return _secteur; } - /** - * @param secteur le nom du lieu dit + * @role set le secteur + * @param secteur le nom du secteur */ public void setSecteur(String secteur) { _secteur = secteur; } + public String toString() { return super.toString() + " " + getSecteur(); diff --git a/src/main/java/fr/unantes/software/construction/address/CompanyCard.java b/src/main/java/fr/unantes/software/construction/address/CompanyCard.java index 6c9b2fca..66851678 100755 --- a/src/main/java/fr/unantes/software/construction/address/CompanyCard.java +++ b/src/main/java/fr/unantes/software/construction/address/CompanyCard.java @@ -5,22 +5,38 @@ import fr.unantes.software.construction.Entreprise; public class CompanyCard extends Card { + /** + * Attributes + */ private String _raison_social; + /** + * @param raison_social + */ public CompanyCard(String raison_social) { super(raison_social); _raison_social = raison_social; - } + /** + * @return _raison_social + */ public String getRaisonSocial() { return _raison_social; } + /** + * @role set la raison social + * @param raison_social + */ public void setRaisonSocial(String raison_social) { _raison_social = raison_social; } + /** + * @param f + * @return res + */ public CompanyCard mergeCompanyCard(CompanyCard f) { CompanyCard res = new CompanyCard(getIdentification()); f.setIdentification(getIdentification()); @@ -33,9 +49,10 @@ public class CompanyCard extends Card { } /** - * Fusione deux fiches en une troisieme. - * + * @role Fusionne deux cartes en une troisieme. * @see Card#merge(Card) + * @param f une carte + * @return res la fusion des deux cartes */ public Card merge(Card f) { Card res = new PrivateCard(getIdentification()); @@ -43,7 +60,11 @@ public class CompanyCard extends Card { res = f.mergeCompanyCard(this); return res; } - + + /** + * @param f + * @return null + */ public PrivateCard fusionFichePart(PrivateCard f) { return null; } diff --git a/src/main/java/fr/unantes/software/construction/address/Group.java b/src/main/java/fr/unantes/software/construction/address/Group.java index d91a3e38..572fa0bf 100755 --- a/src/main/java/fr/unantes/software/construction/address/Group.java +++ b/src/main/java/fr/unantes/software/construction/address/Group.java @@ -8,22 +8,27 @@ package fr.unantes.software.construction.address; */ public class Group { - /** Attributs d'instance */ - + /** + * Attributes + */ private String _grp; private String _comGrp; - /** Constructeurs */ + /** + * Constructor empty + */ public Group() { } + /** + * @param grp le nom du groupe + * @param comGrp commentaire sur le groupe + */ public Group(String grp, String comGrp) { _grp = grp; _comGrp = comGrp; } - /** Accesseurs */ - /** * @return _grp retroune le nom du groupe */ @@ -38,35 +43,34 @@ public class Group { return _comGrp; } - /** Les Modificateurs */ /** - * @param grp - * nom du groupe + * @role set le nom du groupe + * @param grp nom du groupe */ public void setGrp(String grp) { _grp = grp; } /** - * @param comGrp - * commentaire sur le group + * @role set commentaire sur le groupe + * @param comGrp commentaire sur le group */ public void setComGrp(String comGrp) { _comGrp = comGrp; } /** - * - */ + * @param g + * @return + */ public boolean sameGroup(Group g) { return (_grp.equals(g.getGrp())); } /** - * Fusione deux groups en un troisieme. - * - * @param g fiche a faire fusionner avec la fiche courante - * @return fiche resultant de la fusion de la fiche courante et celle passee en parametre + * @role Fusionne deux groupes en un troisieme + * @param g un groupe + * @return res fusion des deux groupes */ public Group merge(Group g) { Group res = null; diff --git a/src/main/java/fr/unantes/software/construction/address/GroupList.java b/src/main/java/fr/unantes/software/construction/address/GroupList.java index faa378a0..530a1e7c 100755 --- a/src/main/java/fr/unantes/software/construction/address/GroupList.java +++ b/src/main/java/fr/unantes/software/construction/address/GroupList.java @@ -4,12 +4,21 @@ import java.util.*; public class GroupList { + /** + * Attributes + */ private Vector _listeGroup; + /** + * constructor empty + */ public GroupList() { _listeGroup = new Vector(); } + /** + * @param lG liste de groupes + */ public GroupList(GroupList lG) { _listeGroup = new Vector(); for (Enumeration e = lG.getListeGroupe().elements(); e.hasMoreElements();) { @@ -18,14 +27,15 @@ public class GroupList { } /** - * @return _listeGroupe + * @return _listeGroupe la liste des groupes */ public Vector getListeGroupe() { return _listeGroup; } /** - * @param lG + * @role set la liste de groupes + * @param lG une groupe */ public void setListeGroupe(Vector lG) { for (Enumeration e = lG.elements(); e.hasMoreElements();) { @@ -34,8 +44,8 @@ public class GroupList { } /** - * @param g - * element a ajouter dans la liste + * @role ajoute un groupe + * @param g groupe a ajouter dans la liste */ public void add(Group g) { if (!find(g)) @@ -43,8 +53,8 @@ public class GroupList { } /** - * @param g - * element a supprimer de la liste + * @role supprime un groupe + * @param g groupe a supprimer de la liste */ public void delete(Group g) { if (find(g)) @@ -54,8 +64,8 @@ public class GroupList { } /** - * @param g - * c'est l'element recherche + * @role recherche un groupe + * @param g c'est l'element recherche */ public boolean find(Group g) { boolean res = false; @@ -68,28 +78,23 @@ public class GroupList { } /** - * Fusion entre 2 listes dans un 3eme que l'on cree. - * - * @param lg - * 2eme liste a faire fusionner - * @return La 3eme liste fusion de la liste courante et de la liste passee - * en parametre + * @role Fusion entre 2 listes de groupes + * @param lg 2eme liste a faire fusionner + * @return res La 3eme liste fusion de la liste courante et de la liste passee en parametre */ public GroupList merge(GroupList lg) { GroupList res = new GroupList(); - /* - * on met toute les adresses de la premiere liste dans la liste de - * retour + /** + * on met tous les groupes de la premiere liste dans la liste de retour */ for (Enumeration e = _listeGroup.elements(); e .hasMoreElements();) { res.add((Group) e.nextElement()); } - /* - * on compare les adresses de liste de retour (adresse de la liste 1) - * avec la 2eme liste + /** + * on compare les groupes de liste de retour (groupes de la liste 1) avec la 2eme liste */ for (Enumeration e1 = lg.getListeGroupe().elements(); e1 .hasMoreElements();) { @@ -100,6 +105,9 @@ public class GroupList { return res; } + /** + * @return res + */ public String toXML() { String res = ""; Enumeration e = _listeGroup.elements(); diff --git a/src/main/java/fr/unantes/software/construction/address/Mail.java b/src/main/java/fr/unantes/software/construction/address/Mail.java index bd2dd1b1..451b9319 100755 --- a/src/main/java/fr/unantes/software/construction/address/Mail.java +++ b/src/main/java/fr/unantes/software/construction/address/Mail.java @@ -2,29 +2,37 @@ package fr.unantes.software.construction.address; public class Mail { + /** + * Attributes + */ private String home; private String work; + /** + * @param mail + * @param com + */ public Mail(String mail, String com) { home = mail; work = com; } /** - * @return _maill + * @return home */ public String getHome() { return home; } /** - * @return _com_mail + * @return work */ public String getWork() { return work; } /** + * @role set le home * @param mail */ public void setHome(String mail) { @@ -32,6 +40,7 @@ public class Mail { } /** + * @role set le work * @param com */ public void setWork(String com) { @@ -39,8 +48,7 @@ public class Mail { } /** - * Cree un nouvel objet Mail, fusion des deux mails. - * + * @role fusionne des deux mails * @param m mail a faire fusionner avec l'objet mail courant. */ public void fusion(Mail m) { diff --git a/src/main/java/fr/unantes/software/construction/address/MailList.java b/src/main/java/fr/unantes/software/construction/address/MailList.java index 57bb0541..122315a4 100755 --- a/src/main/java/fr/unantes/software/construction/address/MailList.java +++ b/src/main/java/fr/unantes/software/construction/address/MailList.java @@ -11,15 +11,20 @@ import java.util.*; public class MailList { + /** + * Attributes + */ private Vector _listeMail; + /** + * Constructor empty + */ public MailList() { _listeMail = new Vector(); } /** * @param lM - * un objet adresse que l'on veut copier */ public MailList(MailList lM) { _listeMail = new Vector(); @@ -38,6 +43,7 @@ public class MailList { /** + * @role set la liste de mails * @param lM */ public void setListeMail(Vector lM) { @@ -47,8 +53,8 @@ public class MailList { } /** - * @param m - * mail a ajouter dans la liste + * @role ajouter un mail + * @param m mail a ajouter dans la liste de mails */ public void ajouter(Mail m) { if (!find(m)) @@ -62,8 +68,8 @@ public class MailList { } /** - * @param m - * mail a supprimer de la liste + * @role supprime un mail + * @param m mail a supprimer de la liste de mails */ public void delete(Mail m) { if (find(m)) @@ -73,8 +79,8 @@ public class MailList { } /** - * @param m - * c'est le mail recherche + * @role recherche un mail + * @param m c'est le mail recherche */ public boolean find(Mail m) { boolean res = false; @@ -86,27 +92,22 @@ public class MailList { } /** - * fusion entre 2 listes dans une 3eme que l'on cree - * - * @param lM - * 2eme liste a faire fusionner - * @return Liste la 3eme liste fusion de la liste courante et de la liste - * passee en parametre + * @role fusion entre 2 listes de mails + * @param lM 2eme liste a faire fusionner + * @return res la 3eme liste fusion de la liste courante et de la liste passee en parametre */ public MailList merge(MailList lM) { MailList res = new MailList(); /** - * on met toute les adresses de la premiere liste dans la liste de - * retour + * on met tous les mails de la premiere liste dans la liste de retour */ for (Enumeration e = _listeMail.elements(); e.hasMoreElements();) { res.ajouter((Mail) e.nextElement()); } /** - * on compare les adresses de liste de retour (adresse de la liste 1) - * avec la 2eme liste + * on compare les mails de liste de retour (mails de la liste 1) avec la 2eme liste */ for (Enumeration e1 = lM.getListeMail().elements(); e1 .hasMoreElements();) { @@ -117,6 +118,9 @@ public class MailList { return res; } + /** + * @return res + */ public String toXML() { String res = ""; Enumeration e = _listeMail.elements(); diff --git a/src/main/java/fr/unantes/software/construction/address/Phone.java b/src/main/java/fr/unantes/software/construction/address/Phone.java index 20b94cdd..93917987 100755 --- a/src/main/java/fr/unantes/software/construction/address/Phone.java +++ b/src/main/java/fr/unantes/software/construction/address/Phone.java @@ -7,29 +7,37 @@ package fr.unantes.software.construction.address; */ public class Phone { + /** + * Attributes + */ private int number = 0; private String comment; + /** + * @param num + * @param com + */ public Phone(int num, String com) { number = num; comment = com; } /** - * @return _num_tel + * @return number */ public int getNumTel() { return number; } /** - * @return _com_tel + * @return comment */ public String getComTel() { return comment; } /** + * @role set le numero de telephone * @param num_tel */ public void setNumTel(int num_tel) { @@ -37,6 +45,7 @@ public class Phone { } /** + * @role set le commentaire de tel * @param com */ public void setComTel(String com) { @@ -44,9 +53,7 @@ public class Phone { } /** - * Rend un nouvel objet Tel, qui est une fusion des deux numeros - * de telephone - * + * @role fusion de deux numeros de telephones * @param t tel a faire fusionner avec l'objet tel courant. */ public Phone merge(Phone t) { diff --git a/src/main/java/fr/unantes/software/construction/address/PhoneList.java b/src/main/java/fr/unantes/software/construction/address/PhoneList.java index 3424ae2e..8a4dbc29 100755 --- a/src/main/java/fr/unantes/software/construction/address/PhoneList.java +++ b/src/main/java/fr/unantes/software/construction/address/PhoneList.java @@ -4,14 +4,20 @@ import java.util.*; public class PhoneList { + /** + * Attributes + */ private Vector telephones; + /** + * Constructor empty + */ public PhoneList() { telephones = new Vector(); } /** - * @param lT un objet adresse que l'on veux copier + * @param lT */ public PhoneList(PhoneList lT) { telephones = new Vector(); @@ -22,7 +28,7 @@ public class PhoneList { } /** - * @return _listeTel + * @return telephones */ public Vector getListeTel() { return telephones; @@ -30,6 +36,7 @@ public class PhoneList { /** + * @role set la liste de telephones * @param lT */ public void setListeTel(Vector lT) { @@ -39,13 +46,12 @@ public class PhoneList { } /** - * @param t adresse a ajouter dans la liste + * @role ajouter un tel + * @param t tel a ajouter dans la liste de telephones */ public void add(Phone t) { if (!find(t)) telephones.add(t); - // si existe deja faire la fusion des deux dans celle deja enregistrer - // dans le vecteur. /** * else Tel b = listeTel.recupere(a); a = fusion (a, b); * listeTel.remplacer(a); @@ -53,6 +59,7 @@ public class PhoneList { } /** + * @role supprimer un tel * @param t telephone a supprimer de la liste */ public void delete(Phone t) { @@ -63,7 +70,9 @@ public class PhoneList { } /** + * @role rechercher un tel * @param t c'est le telephone recherche + * @return res */ public boolean find(Phone t) { boolean res = false; @@ -75,25 +84,22 @@ public class PhoneList { } /** - * Fusion entre 2 listes dans une 3eme que l'on cree. - * - * @param lT 2eme liste a faire fusionner - * @return La 3eme liste fusion de la liste courante et de la liste passee en parametre + * @role Fusion entre 2 listes de telephones + * @param lT liste de tel a faire fusionner + * @return res La fusion de la liste courante et de la liste passee en parametre */ public PhoneList merge(PhoneList lT) { PhoneList res = new PhoneList(); /** - * on met toute les adresses de la premiere liste dans la liste de - * retour + * on met touts les telephones de la premiere liste dans la liste de retour */ for (Enumeration e = telephones.elements(); e.hasMoreElements();) { res.add((Phone) e.nextElement()); } /** - * on compare les adresses de liste de retour (adresse de la liste 1) - * avec la 2eme liste + * on compare les telephones de liste de retour (telephones de la liste 1) avec la 2eme liste */ for (Enumeration e1 = lT.getListeTel().elements(); e1 .hasMoreElements();) { @@ -104,6 +110,9 @@ public class PhoneList { return res; } + /** + * @return res + */ public String toXML() { String res = ""; Enumeration e = telephones.elements(); diff --git a/src/main/java/fr/unantes/software/construction/address/PrivateAddress.java b/src/main/java/fr/unantes/software/construction/address/PrivateAddress.java index 379b612a..41f6f021 100755 --- a/src/main/java/fr/unantes/software/construction/address/PrivateAddress.java +++ b/src/main/java/fr/unantes/software/construction/address/PrivateAddress.java @@ -7,15 +7,19 @@ package fr.unantes.software.construction.address; */ public class PrivateAddress extends Address { + /** + * Attributes + */ private String lieuDit; + /** + * Constructor empty + */ public PrivateAddress() { super(); } /** - * - * * @param voie le numero de la voie * @param rue le nom de la rue * @param lieu_dit le lieu dit de la rue @@ -29,7 +33,6 @@ public class PrivateAddress extends Address { } /** - * * @param f une adresse */ public PrivateAddress(PrivateAddress f) { @@ -37,18 +40,15 @@ public class PrivateAddress extends Address { lieuDit = f.getLieu_dit(); } - /** Les accesseurs */ - - /* - * @return _lieu_dit le nom du lieu dit + /** + * @return lieuDit le nom du lieu dit */ public String getLieu_dit() { return lieuDit; } - /** Les modificateurs */ - /** + * @role set le nom du lieu dit * @param lieu_dit le nom du lieu dit */ public void setLieu_dit(String lieu_dit) { diff --git a/src/main/java/fr/unantes/software/construction/address/PrivateCard.java b/src/main/java/fr/unantes/software/construction/address/PrivateCard.java index 0cb774ca..b5fd706b 100755 --- a/src/main/java/fr/unantes/software/construction/address/PrivateCard.java +++ b/src/main/java/fr/unantes/software/construction/address/PrivateCard.java @@ -11,17 +11,25 @@ import fr.unantes.software.construction.Particulier; public class PrivateCard extends Card { - /** attributs d'insatance */ + /** + * Attributes + */ private String _prenom; private String _nomP; - + /** + * @param nom le nom + * @param prenom le prenom + */ public PrivateCard(String nom, String prenom) { super(nom + prenom); _nomP = nom; _prenom = prenom; } + /** + * @param id l'id + */ public PrivateCard(String id) { super(id); _nomP = ""; @@ -29,40 +37,38 @@ public class PrivateCard extends Card { } /** - * @return _nomP nom de la personne de la fiche + * @return _nomP nom de la personne de la carte */ public String getNomP() { return _nomP; } /** - * @return _prenom prenom de la personne de la fiche + * @return _prenom prenom de la personne de la carte */ public String getPrenom() { return _prenom; } /** - * @return _nom nom de la personne de la fiche + * @return _nom nom de la personne de la carte */ public void setNomP(String nom) { _nomP = nom; } /** - * @param prenom - * prenom de la personne de la fiche + * @role set le prenom + * @param prenom prenom de la personne de la carte */ public void setPrenom(String prenom) { _prenom = prenom; } /** - * permet la fusion entre la fiche courante et une fiche passee en parametre - * dans une troisieme fiche - * - * @param f fiche a faire fusionner avec la fiche courante - * @return fiche resultant de la fusion de la fiche courante et celle passee en parametre + * @role fusion entre la carte courante et une carte passee en parametre + * @param f carte a faire fusionner avec la carte courante + * @return carte resultant de la fusion de la carte courante et celle passee en parametre */ public Card merge(Card f) { Card res = new PrivateCard(getIdentification()); @@ -71,10 +77,18 @@ public class PrivateCard extends Card { return res; } + /** + * @param f + * @return null + */ public CompanyCard mergeCompanyCard(CompanyCard f) { return null; } + /** + * @param f + * @return res + */ public PrivateCard fusionFichePart(PrivateCard f) { PrivateCard res = new PrivateCard(getIdentification()); res.setIdentification(getIdentification()); @@ -95,6 +109,10 @@ public class PrivateCard extends Card { + getListeTel().toXML() + getListeMail().toXML() + getListeGroupe().toXML() + ""); } + /** + * @role set le client + * @param c + */ public void setClient(Client c){ if(c.getClass().equals(Particulier.class)){ getClientReference().set(c); -- GitLab From 51d6003a13bbb75e600da290a7467b606065cfe8 Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Thu, 2 Apr 2020 18:12:08 +0200 Subject: [PATCH 18/35] Interface graphique : creer compte + connexion --- .../fr/unantes/software/construction/ui/CreateInterface.java | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/main/java/fr/unantes/software/construction/ui/CreateInterface.java diff --git a/src/main/java/fr/unantes/software/construction/ui/CreateInterface.java b/src/main/java/fr/unantes/software/construction/ui/CreateInterface.java new file mode 100644 index 00000000..3fab80c9 --- /dev/null +++ b/src/main/java/fr/unantes/software/construction/ui/CreateInterface.java @@ -0,0 +1,4 @@ +package fr.unantes.software.construction.ui; + +public class CreateInterface { +} -- GitLab From 7343a1924ac864891bb53dfb46362aae0cdcde67 Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Thu, 2 Apr 2020 18:14:01 +0200 Subject: [PATCH 19/35] Interface graphique : creer compte + connexion --- .../association/BankToClientTest.java | 2 + .../security/ClientControllerTest.java | 24 +++ .../unantes/software/construction/Bank.java | 3 +- .../unantes/software/construction/Main.java | 2 +- .../security/ClientController.java | 2 +- .../construction/ui/CreateInterface.java | 29 ++- .../ui/GraphicalUserInterface.java | 183 +++++++++++++++++- 7 files changed, 232 insertions(+), 13 deletions(-) diff --git a/src/Test/java/fr/unantes/software/construction/association/BankToClientTest.java b/src/Test/java/fr/unantes/software/construction/association/BankToClientTest.java index 97a24c8c..d3f56763 100644 --- a/src/Test/java/fr/unantes/software/construction/association/BankToClientTest.java +++ b/src/Test/java/fr/unantes/software/construction/association/BankToClientTest.java @@ -11,6 +11,7 @@ import org.junit.Test; import java.io.InvalidClassException; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class BankToClientTest { private Bank b; @@ -24,6 +25,7 @@ public class BankToClientTest { assertEquals(1,b.getClientRef().size()); b.getClientRef().add(particulier); assertEquals(2,b.getClientRef().size()); + assertTrue(b.getClient("test1") != null); b.getClientRef().remove(entreprise); assertEquals(1,b.getClientRef().size()); b.getClientRef().remove(entreprise); diff --git a/src/Test/java/fr/unantes/software/construction/security/ClientControllerTest.java b/src/Test/java/fr/unantes/software/construction/security/ClientControllerTest.java index 8867f07c..d6c80bf8 100644 --- a/src/Test/java/fr/unantes/software/construction/security/ClientControllerTest.java +++ b/src/Test/java/fr/unantes/software/construction/security/ClientControllerTest.java @@ -1,4 +1,28 @@ package fr.unantes.software.construction.security; +import fr.unantes.software.construction.Client; +import fr.unantes.software.construction.Particulier; +import fr.unantes.software.construction.address.PrivateAddress; +import org.junit.Before; +import org.junit.Test; + +import java.io.InvalidClassException; +import static org.junit.Assert.*; + public class ClientControllerTest { + private ClientController controller; + private Client p; + + @SuppressWarnings("static-access") + @Test + public void Test() { + assertTrue(controller.addUser(p,"test")); + assertTrue(controller.hasUser(p)); + } + + @Before + public void initBeforeTest() throws InvalidClassException { + controller = new ClientController(); + p = new Particulier("Phillipe", "private", new PrivateAddress()); + } } diff --git a/src/main/java/fr/unantes/software/construction/Bank.java b/src/main/java/fr/unantes/software/construction/Bank.java index e63d5281..91acd037 100755 --- a/src/main/java/fr/unantes/software/construction/Bank.java +++ b/src/main/java/fr/unantes/software/construction/Bank.java @@ -123,8 +123,9 @@ public class Bank { public Client getClient(String name) { Iterator it = this.clients.iterator(); while (it.hasNext()){ + System.out.println("iterator"); Client p = (Client)it.next(); - if(p.getName()==name){ + if(p.getName().equals(name)){ return p; } diff --git a/src/main/java/fr/unantes/software/construction/Main.java b/src/main/java/fr/unantes/software/construction/Main.java index 34e1e277..a8a37eba 100644 --- a/src/main/java/fr/unantes/software/construction/Main.java +++ b/src/main/java/fr/unantes/software/construction/Main.java @@ -6,6 +6,6 @@ import javafx.application.Application; public class Main { public static void main(String[] args) { // launch the GUI - //Application.launch(GraphicalUserInterface.class); + Application.launch(GraphicalUserInterface.class); } } diff --git a/src/main/java/fr/unantes/software/construction/security/ClientController.java b/src/main/java/fr/unantes/software/construction/security/ClientController.java index 4b09cac9..f2518712 100644 --- a/src/main/java/fr/unantes/software/construction/security/ClientController.java +++ b/src/main/java/fr/unantes/software/construction/security/ClientController.java @@ -36,7 +36,7 @@ public class ClientController { if (namesToUsers.containsKey(person.getName())) { throw new IllegalArgumentException("Invalid argument: the person is already registered."); } - namesToUsers.put(person.toString(), person); + namesToUsers.put(person.getName(), person); usersToPasswords.put(person.getName(), passwordEncrypted.encryptPassword(password)); return true; } diff --git a/src/main/java/fr/unantes/software/construction/ui/CreateInterface.java b/src/main/java/fr/unantes/software/construction/ui/CreateInterface.java index 3fab80c9..a662ed5c 100644 --- a/src/main/java/fr/unantes/software/construction/ui/CreateInterface.java +++ b/src/main/java/fr/unantes/software/construction/ui/CreateInterface.java @@ -1,4 +1,31 @@ package fr.unantes.software.construction.ui; -public class CreateInterface { +import fr.unantes.software.construction.Client; +import fr.unantes.software.construction.Entreprise; +import fr.unantes.software.construction.Particulier; +import fr.unantes.software.construction.address.Card; +import fr.unantes.software.construction.address.CompanyAddress; +import fr.unantes.software.construction.address.PrivateAddress; +import fr.unantes.software.construction.address.PrivateCard; +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.StackPane; +import javafx.stage.Modality; +import javafx.stage.Stage; + +import java.io.InvalidClassException; + +public class CreateInterface extends GraphicalUserInterface { + private Stage stage; + private GraphicalUserInterface gui; + public CreateInterface(Stage s,GraphicalUserInterface g) { + stage = s; + gui = g; + } + + } diff --git a/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java b/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java index e279aa73..acc019a5 100644 --- a/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java +++ b/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java @@ -1,14 +1,47 @@ package fr.unantes.software.construction.ui; +import fr.unantes.software.construction.Bank; +import fr.unantes.software.construction.Client; +import fr.unantes.software.construction.Entreprise; +import fr.unantes.software.construction.Particulier; +import fr.unantes.software.construction.address.CompanyAddress; +import fr.unantes.software.construction.address.PrivateAddress; +import fr.unantes.software.construction.security.ClientController; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.GridPane; +import javafx.stage.Modality; import javafx.stage.Stage; +import java.io.InvalidClassException; + public class GraphicalUserInterface extends Application { + /** + * + * @uml.property name="bank" + * @uml.associationEnd inverse="display:fr.unantes.software.construction.Bank" multiplicity="(1 1)" + * + */ + private Bank bank; + private ClientController controller; + + public GraphicalUserInterface(){ + bank = new Bank(); + controller = new ClientController(); + } + /** + * @uml.property name="bank" + */ + public Bank getBank() { + return bank; + } + + public ClientController getController() { + return controller; + } public void start(Stage stage) throws Exception { GridPane root = new GridPane(); @@ -17,29 +50,161 @@ public class GraphicalUserInterface extends Application { TextField field1 = new TextField(); Label lbl1 = new Label("Name:"); lbl1.setLabelFor(field1); - Button loginButton = new Button(); // password box TextField field2 = new TextField(); Label lbl2 = new Label("Password:"); - lbl1.setLabelFor(field2); + lbl2.setLabelFor(field2); + Button loginButton = new Button(); loginButton.setText("Login"); - /* + + Button createButton = new Button(); + createButton.setText("Create"); + + loginButton.setOnAction(event -> { - System.out.println("login with name=" + field1.getText() + " and password=" + field2.getText()); + if(connexion(field1.getText(),field2.getText())){ + compte(stage); + } + }); + + createButton.setOnAction(event -> { + create(stage); }); - */ + root.add(lbl1, 0, 0); - root.add(field1, 2, 0); + root.add(field1, 1, 0); root.add(lbl2, 0, 1); - root.add(field2, 2, 1); - root.add(loginButton, 0, 3); + root.add(field2, 1, 1); + root.add(loginButton, 0, 2); + root.add(createButton, 0, 3); - Scene scene = new Scene(root, 280, 200); + Scene scene = new Scene(root, 500, 460); stage.setScene(scene); stage.show(); + + } + + public void create(Stage stage){ + Label createLabel = new Label(); + + GridPane createRoot = new GridPane(); + createRoot.getChildren().add(createLabel); + + + // name box + TextField nameField = new TextField(); + Label name = new Label("Name:"); + name.setLabelFor(nameField); + + // role box + TextField roleField = new TextField(); + Label role = new Label("Role:"); + role.setLabelFor(roleField); + + // password box + TextField passwordField = new TextField(); + Label password = new Label("Password:"); + password.setLabelFor(passwordField); + + + Button createButton = new Button(); + createButton.setText("Create"); + + + createRoot.add(name, 0, 0); + createRoot.add(nameField, 1, 0); + createRoot.add(role, 0, 1); + createRoot.add(roleField, 1, 1); + createRoot.add(password, 0, 2); + createRoot.add(passwordField, 1, 2); + createRoot.add(createButton, 0, 3); + + Scene createScene = new Scene(createRoot, 300, 260); + + // New window (Stage) + Stage newWindow = new Stage(); + newWindow.setTitle("Créer un nouveau compte"); + newWindow.setScene(createScene); + + // Specifies the modality for new window. + newWindow.initModality(Modality.WINDOW_MODAL); + + // Specifies the owner Window (parent) for new window + newWindow.initOwner(stage); + + // Set position of second window, related to primary window. + newWindow.setX(stage.getX() + 100); + newWindow.setY(stage.getY() + 100); + newWindow.show(); + + createButton.setOnAction(event -> { + try { + creerCompte(nameField.getText(),roleField.getText(),passwordField.getText()); + } catch (InvalidClassException e) { + e.printStackTrace(); + } + newWindow.close(); + }); + } + + public void compte(Stage stage){ + Label compteLabel = new Label(); + + GridPane compteRoot = new GridPane(); + compteRoot.getChildren().add(compteLabel); + + Scene compteScene = new Scene(compteRoot, 500, 460); + + // New window (Stage) + Stage newWindow = new Stage(); + newWindow.setTitle("Compte"); + newWindow.setScene(compteScene); + + // Specifies the modality for new window. + newWindow.initModality(Modality.WINDOW_MODAL); + + // Specifies the owner Window (parent) for new window + newWindow.initOwner(stage); + + // Set position of second window, related to primary window. + newWindow.setX(stage.getX()); + newWindow.setY(stage.getY()); + newWindow.show(); + } + + public void creerCompte(String name, String role, String password) throws InvalidClassException { + Client p; + if (role.equals("private")){ + p = new Particulier(name,role,new PrivateAddress()); + bank.getClientRef().add(p); + controller.addUser(p,password); + } else if(role.equals("company")){ + p = new Entreprise(name,role,new CompanyAddress()); + bank.getClientRef().add(p); + controller.addUser(p,password); + } + } + + public boolean connexion(String identifiant, String password) { + Client p = bank.getClient(identifiant); + if (p != null) { + if (controller.hasUser(p)) { + if (getController().validatePassword(p, password)) { + System.out.println("bon mdp"); + return true; + } else { + System.out.println("mauvais mdp"); + return false; + } + } else { + System.out.println("mauvais identifiant"); + return false; + } + } + return false; } } -- GitLab From e01bb3a2ff777f8d7e5d84a0a80c3f74a6fcf5b1 Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Thu, 2 Apr 2020 18:17:53 +0200 Subject: [PATCH 20/35] Suppr class inutile --- .../construction/ui/CreateInterface.java | 31 ------------------- 1 file changed, 31 deletions(-) delete mode 100644 src/main/java/fr/unantes/software/construction/ui/CreateInterface.java diff --git a/src/main/java/fr/unantes/software/construction/ui/CreateInterface.java b/src/main/java/fr/unantes/software/construction/ui/CreateInterface.java deleted file mode 100644 index a662ed5c..00000000 --- a/src/main/java/fr/unantes/software/construction/ui/CreateInterface.java +++ /dev/null @@ -1,31 +0,0 @@ -package fr.unantes.software.construction.ui; - -import fr.unantes.software.construction.Client; -import fr.unantes.software.construction.Entreprise; -import fr.unantes.software.construction.Particulier; -import fr.unantes.software.construction.address.Card; -import fr.unantes.software.construction.address.CompanyAddress; -import fr.unantes.software.construction.address.PrivateAddress; -import fr.unantes.software.construction.address.PrivateCard; -import javafx.application.Application; -import javafx.scene.Scene; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.control.TextField; -import javafx.scene.layout.GridPane; -import javafx.scene.layout.StackPane; -import javafx.stage.Modality; -import javafx.stage.Stage; - -import java.io.InvalidClassException; - -public class CreateInterface extends GraphicalUserInterface { - private Stage stage; - private GraphicalUserInterface gui; - public CreateInterface(Stage s,GraphicalUserInterface g) { - stage = s; - gui = g; - } - - -} -- GitLab From 88143c0bb5fb6254eddfc2083eb42a21a1c0a26a Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Thu, 2 Apr 2020 18:30:16 +0200 Subject: [PATCH 21/35] Test connexion + ajustement --- .../association/BankToAccountTest.java | 1 - .../construction/ui/GraphiqueUiTest.java | 31 +++++++++++++++++++ .../unantes/software/construction/Bank.java | 1 - .../ui/GraphicalUserInterface.java | 8 +++++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/Test/java/fr/unantes/software/construction/association/BankToAccountTest.java b/src/Test/java/fr/unantes/software/construction/association/BankToAccountTest.java index 7ca04c2a..773e83b6 100644 --- a/src/Test/java/fr/unantes/software/construction/association/BankToAccountTest.java +++ b/src/Test/java/fr/unantes/software/construction/association/BankToAccountTest.java @@ -30,7 +30,6 @@ public class BankToAccountTest { b.getAccountRef().remove(acc1); b.getAccountRef().remove(acc2); assertEquals(0,b.getAccountRef().size()); - } @Before diff --git a/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java b/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java index 33aea173..ad6aca82 100644 --- a/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java +++ b/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java @@ -1,4 +1,35 @@ package fr.unantes.software.construction.ui; +import fr.unantes.software.construction.Account; +import fr.unantes.software.construction.Bank; +import fr.unantes.software.construction.Entreprise; +import fr.unantes.software.construction.Particulier; +import fr.unantes.software.construction.address.CompanyAddress; +import fr.unantes.software.construction.address.PrivateAddress; +import org.junit.Before; +import org.junit.Test; + +import java.io.InvalidClassException; + +import static org.junit.Assert.*; + public class GraphiqueUiTest { + GraphicalUserInterface graph; + + @SuppressWarnings("static-access") + @Test + public void ConnexionTest() { + assertFalse(graph.connexion("test","test")); + assertTrue(graph.connexion("Jean Michel","JeanM")); + assertTrue(graph.connexion("JeanCorporation","JeanC")); + assertFalse(graph.connexion("Jean Michel","JeanP")); + } + + @Before + public void initBeforeTest() throws InvalidClassException { + graph = new GraphicalUserInterface(); + graph.creerCompte("Jean Michel","private","JeanM"); + graph.creerCompte("Jean Pierre","private","JeanP"); + graph.creerCompte("JeanCorporation","company","JeanC"); + } } diff --git a/src/main/java/fr/unantes/software/construction/Bank.java b/src/main/java/fr/unantes/software/construction/Bank.java index ee725f90..f8b3acf0 100755 --- a/src/main/java/fr/unantes/software/construction/Bank.java +++ b/src/main/java/fr/unantes/software/construction/Bank.java @@ -130,7 +130,6 @@ public class Bank { public Client getClient(String name) { Iterator it = this.clients.iterator(); while (it.hasNext()){ - System.out.println("iterator"); Client p = (Client)it.next(); if(p.getName().equals(name)){ return p; diff --git a/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java b/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java index acc019a5..1c822680 100644 --- a/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java +++ b/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java @@ -39,10 +39,18 @@ public class GraphicalUserInterface extends Application { return bank; } + public void setBank(Bank b) { + bank = b; + } + public ClientController getController() { return controller; } + public void setController(ClientController c) { + controller = c; + } + public void start(Stage stage) throws Exception { GridPane root = new GridPane(); -- GitLab From a24cdf8bda78065a3774a1b8f53be1f91edd5b39 Mon Sep 17 00:00:00 2001 From: Curtis Meda Date: Thu, 2 Apr 2020 19:19:49 +0200 Subject: [PATCH 22/35] Assertion - Account --- .../software/construction/Account.java | 93 ++++++------------- .../unantes/software/construction/Client.java | 3 +- .../software/construction/Operation.java | 4 +- 3 files changed, 31 insertions(+), 69 deletions(-) diff --git a/src/main/java/fr/unantes/software/construction/Account.java b/src/main/java/fr/unantes/software/construction/Account.java index 5fab56ce..b8ce8d7e 100755 --- a/src/main/java/fr/unantes/software/construction/Account.java +++ b/src/main/java/fr/unantes/software/construction/Account.java @@ -47,6 +47,7 @@ public class Account { * The method also initializes the history with a new empty Vector */ public Account(Client p, float amount, float overdraft, int n, String type) throws InvalidClassException { + this.overdraft = overdraft; this.balance = amount; this.history = new Vector(); this.number = n; @@ -65,8 +66,12 @@ public class Account { * Adds this operation in the history */ public void deposit(float amount) { + if (amount < 0){ + throw new IllegalArgumentException("The amount cannot be negative"); + } balance = balance + amount; - //Operation o = new DepositOperation(amount); + Operation o = new DepositOperation(amount, LocalTime.now()); + addHistory(o); } /** @@ -99,87 +104,64 @@ public class Account { /** * @return owner */ - public Client getOwner(){ - return owner; - } + public Client getOwner(){ return owner; } /** * @uml.property name="history" */ - public java.util.Collection getHistory() { - return history; - } + public java.util.Collection getHistory() { return history; } /** * @role set l'history * @uml.property name="history" */ - public void setHistory(java.util.Collection value) { - history = value; - } + public void setHistory(java.util.Collection value) { history = value; } /** * @uml.property name="history" */ - public Iterator historyIterator() { - return history.iterator(); - } + public Iterator historyIterator() { return history.iterator(); } /** * @role ajoute une operation * @uml.property name="history" */ - public boolean addHistory(Operation element) { - return history.add(element); - } + public boolean addHistory(Operation element) { return history.add(element); } /** * @role retire une operation * @uml.property name="history" */ - public boolean removeHistory(Operation element) { - return history.remove(element); - } + public boolean removeHistory(Operation element) { return history.remove(element); } /** * @role Savoir si l'history est vide * @uml.property name="history" */ - public boolean isHistoryEmpty() { - return history.isEmpty(); - } + public boolean isHistoryEmpty() { return history.isEmpty(); } /** * @role vider l'history * @uml.property name="history" */ - public void clearHistory() { - history.clear(); - } + public void clearHistory() { history.clear(); } /** * @role savoir si l'history contient une operation * @uml.property name="history" */ - public boolean containsHistory(Operation element) { - return history.contains(element); - } + public boolean containsHistory(Operation element) { return history.contains(element); } /** - * * @uml.property name="history" */ - public boolean containsAllHistory(Collection elements) { - return history.containsAll(elements); - } + public boolean containsAllHistory(Collection elements) { return history.containsAll(elements); } /** * @role avoir la taille de l'history * @uml.property name="history" */ - public int historySize() { - return history.size(); - } + public int historySize() { return history.size(); } /** * @uml.property name="history" @@ -204,15 +186,16 @@ public class Account { * @uml.property name="overdraft" * @return overdraft */ - public float getOverdraft() { - return overdraft; - } + public float getOverdraft() { return overdraft; } /** * @role set le overdraft * @uml.property name="overdraft" */ public void setOverdraft(float overdraft) { + if (overdraft < 0) { + throw new IllegalArgumentException("The overdraft cannot be negative"); + } this.overdraft = overdraft; } @@ -220,34 +203,25 @@ public class Account { * @uml.property name="balance" * @return balance */ - public float getBalance() { - return balance; - } + public float getBalance() { return balance; } /** * @role set balance * @uml.property name="balance" */ - public void setBalance(float balance) { - this.balance = balance; - } + public void setBalance(float balance) { this.balance = balance; } /** * @uml.property name="number" * @return number */ - public int getNumber() { - return number; - } + public int getNumber() { return number; } /** * @role set le number * @uml.property name="number" */ - public void setNumber(int number) { - this.number = number; - } - + public void setNumber(int number) { this.number = number; } /** * @role classe de reference @@ -285,9 +259,7 @@ public class Account { * @uml.property name="clients" * @return clients */ - public ClientReference getClients() { - return clients; - } + public ClientReference getClients() { return clients; } /** * @role ajouter un client @@ -324,26 +296,19 @@ public class Account { * @role vider client * @uml.property name="clients" */ - public void clearClients() { - clients.clients.clear(); - } + public void clearClients() { clients.clients.clear(); } /** * @role savoir si un client est deja client * @uml.property name="clients" */ - public boolean containsClients(Client element) { - return clients.clients.contains(element); - } + public boolean containsClients(Client element) { return clients.clients.contains(element); } /** * @role taille de client * @uml.property name="clients" */ - public int clientsSize() { - return clients.clients.size(); - } - + public int clientsSize() { return clients.clients.size(); } /** * @role classe de reference diff --git a/src/main/java/fr/unantes/software/construction/Client.java b/src/main/java/fr/unantes/software/construction/Client.java index d384d24a..b7a7c061 100644 --- a/src/main/java/fr/unantes/software/construction/Client.java +++ b/src/main/java/fr/unantes/software/construction/Client.java @@ -162,6 +162,7 @@ public abstract class Client { } /** + * * @uml.property name="accounts" */ public boolean containsAccounts(Account element) { @@ -176,12 +177,10 @@ public abstract class Client { return account.account.size(); } - public Account[] accountsToArray(){ return (Account[]) account.account.toArray(); } - /** * @role classe de reference */ diff --git a/src/main/java/fr/unantes/software/construction/Operation.java b/src/main/java/fr/unantes/software/construction/Operation.java index b887a121..1464fb8e 100755 --- a/src/main/java/fr/unantes/software/construction/Operation.java +++ b/src/main/java/fr/unantes/software/construction/Operation.java @@ -32,9 +32,7 @@ public abstract class Operation { * @role set amount * @uml.property name="amount" */ - public void setAmount(float amount) { - this.amount = amount; - } + public void setAmount(float amount) { this.amount = amount; } /** * @param amount -- GitLab From 522ff2a0fb7a23afd9972a027081ce4cb90638af Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Thu, 2 Apr 2020 19:39:38 +0200 Subject: [PATCH 23/35] Precondition 1 --- .../software/construction/Account.java | 81 ++++++++++++------- .../unantes/software/construction/Bank.java | 13 +-- .../unantes/software/construction/Client.java | 29 +++---- .../construction/DepositOperation.java | 4 +- .../software/construction/Entreprise.java | 7 +- .../software/construction/Operation.java | 12 +-- .../software/construction/Particulier.java | 7 +- .../software/construction/ReferenceUniDi.java | 10 ++- .../construction/WithdrawOperation.java | 4 +- .../construction/address/Address.java | 41 +++++++--- .../construction/address/AddressBook.java | 10 ++- .../construction/address/AddressList.java | 12 +-- .../software/construction/address/Card.java | 37 ++++----- .../construction/address/CardList.java | 16 ++-- .../software/construction/address/City.java | 8 +- .../construction/address/CompanyAddress.java | 12 ++- .../construction/address/CompanyCard.java | 13 +-- .../software/construction/address/Group.java | 12 +-- .../construction/address/GroupList.java | 14 ++-- .../software/construction/address/Mail.java | 12 +-- .../construction/address/MailList.java | 14 ++-- .../software/construction/address/Phone.java | 24 ++++-- .../construction/address/PhoneList.java | 14 ++-- .../construction/address/PrivateAddress.java | 10 ++- .../construction/address/PrivateCard.java | 17 ++-- .../security/ClientController.java | 9 ++- .../construction/security/Password.java | 6 +- .../ui/GraphicalUserInterface.java | 15 ++-- 28 files changed, 282 insertions(+), 181 deletions(-) diff --git a/src/main/java/fr/unantes/software/construction/Account.java b/src/main/java/fr/unantes/software/construction/Account.java index b8ce8d7e..6b265ae3 100755 --- a/src/main/java/fr/unantes/software/construction/Account.java +++ b/src/main/java/fr/unantes/software/construction/Account.java @@ -1,5 +1,7 @@ package fr.unantes.software.construction; +import com.sun.istack.internal.NotNull; + import java.io.InvalidClassException; import java.time.LocalTime; import java.util.ArrayList; @@ -46,11 +48,23 @@ public class Account { * Initializes the owner, amount, overdraft and the account number with parameters * The method also initializes the history with a new empty Vector */ - public Account(Client p, float amount, float overdraft, int n, String type) throws InvalidClassException { - this.overdraft = overdraft; - this.balance = amount; + public Account(@NotNull Client p, @NotNull float amount, @NotNull float overdraft, @NotNull int n, @NotNull String type) throws InvalidClassException { + if(overdraft < 0){ + throw new IllegalArgumentException("overdraft < 0"); + } else { + this.overdraft = overdraft; + } + if(amount < (0-overdraft)){ + throw new IllegalArgumentException("amount < 0-overdraft"); + } else { + this.balance = amount; + } this.history = new Vector(); - this.number = n; + if(n < 0){ + throw new IllegalArgumentException("n < 0"); + } else { + this.number = n; + } operation = new OperationReference(); this.type = type; if (!type.equals("private") && !type.equals("company")) { @@ -65,7 +79,7 @@ public class Account { * Adds the amount to the current balance * Adds this operation in the history */ - public void deposit(float amount) { + public void deposit(@NotNull float amount) { if (amount < 0){ throw new IllegalArgumentException("The amount cannot be negative"); } @@ -81,7 +95,7 @@ public class Account { * If the amount is lower than the overdraft, *the amount is not withdrawn and exception is thrown to indicate that there is not enough credit. */ - public void withdraw(float amount) throws Exception { + public void withdraw(@NotNull float amount) throws Exception { float newBalance = balance - amount; if (newBalance > 0){ balance = newBalance; @@ -115,7 +129,7 @@ public class Account { * @role set l'history * @uml.property name="history" */ - public void setHistory(java.util.Collection value) { history = value; } + public void setHistory(@NotNull java.util.Collection value) { history = value; } /** * @uml.property name="history" @@ -126,13 +140,13 @@ public class Account { * @role ajoute une operation * @uml.property name="history" */ - public boolean addHistory(Operation element) { return history.add(element); } + public boolean addHistory(@NotNull Operation element) { return history.add(element); } /** * @role retire une operation * @uml.property name="history" */ - public boolean removeHistory(Operation element) { return history.remove(element); } + public boolean removeHistory(@NotNull Operation element) { return history.remove(element); } /** * @role Savoir si l'history est vide @@ -150,12 +164,12 @@ public class Account { * @role savoir si l'history contient une operation * @uml.property name="history" */ - public boolean containsHistory(Operation element) { return history.contains(element); } + public boolean containsHistory(@NotNull Operation element) { return history.contains(element); } /** * @uml.property name="history" */ - public boolean containsAllHistory(Collection elements) { return history.containsAll(elements); } + public boolean containsAllHistory(@NotNull Collection elements) { return history.containsAll(elements); } /** * @role avoir la taille de l'history @@ -180,7 +194,7 @@ public class Account { * @role set le type * @param t */ - public void setType(String t){ type = t; } + public void setType(@NotNull String t){ type = t; } /** * @uml.property name="overdraft" @@ -192,7 +206,7 @@ public class Account { * @role set le overdraft * @uml.property name="overdraft" */ - public void setOverdraft(float overdraft) { + public void setOverdraft(@NotNull float overdraft) { if (overdraft < 0) { throw new IllegalArgumentException("The overdraft cannot be negative"); } @@ -209,7 +223,12 @@ public class Account { * @role set balance * @uml.property name="balance" */ - public void setBalance(float balance) { this.balance = balance; } + public void setBalance(@NotNull float balance) { + if (balance < 0) { + throw new IllegalArgumentException("The balance cannot be negative"); + } + this.balance = balance; + } /** * @uml.property name="number" @@ -221,7 +240,11 @@ public class Account { * @role set le number * @uml.property name="number" */ - public void setNumber(int number) { this.number = number; } + public void setNumber(@NotNull int number) { + if (number < 0) { + throw new IllegalArgumentException("The number cannot be negative"); + } + this.number = number; } /** * @role classe de reference @@ -232,25 +255,25 @@ public class Account { clients = new ArrayList(); } - public void add(Client c){ + public void add(@NotNull Client c){ basicAdd(c); c.getAccounts().basicAdd(Account.this); } - public void remove(Client c){ + public void remove(@NotNull Client c){ basicRemove(c); c.getAccounts().basicRemove(Account.this); } - public void basicAdd(Client c){ + public void basicAdd(@NotNull Client c){ clients.add(c); } - public void basicRemove(Client c){ + public void basicRemove(@NotNull Client c){ clients.remove(c); } - public Client get(int i){ + public Client get(@NotNull int i){ return clients.get(i); } } @@ -265,7 +288,7 @@ public class Account { * @role ajouter un client * @uml.property name="clients" */ - public void addClients(Client element) { + public void addClients(@NotNull Client element) { if(!containsClients(element)){ clients.add(element); } @@ -275,7 +298,7 @@ public class Account { * @role retire un client * @uml.property name="clients" */ - public void removeClients(Client element) { + public void removeClients(@NotNull Client element) { if(containsClients(element)){ clients.remove(element); } @@ -302,7 +325,7 @@ public class Account { * @role savoir si un client est deja client * @uml.property name="clients" */ - public boolean containsClients(Client element) { return clients.clients.contains(element); } + public boolean containsClients(@NotNull Client element) { return clients.clients.contains(element); } /** * @role taille de client @@ -319,30 +342,30 @@ public class Account { operations = new ArrayList(); } - public void add(Operation o){ + public void add(@NotNull Operation o){ basicAdd(o); o.getAccountReference().basicSet(Account.this); } - public void remove(Operation o){ + public void remove(@NotNull Operation o){ basicRemove(o); o.getAccountReference().basicUnSet(); } - public void basicAdd(Operation o){ + public void basicAdd(@NotNull Operation o){ operations.add(o); } - public void basicRemove(Operation o){ + public void basicRemove(@NotNull Operation o){ operations.remove(o); } } - public void addOperation(Operation o) { + public void addOperation(@NotNull Operation o) { operation.add(o); } - public boolean containsOperation(Operation o){ + public boolean containsOperation(@NotNull Operation o){ return operation.operations.contains(o); } diff --git a/src/main/java/fr/unantes/software/construction/Bank.java b/src/main/java/fr/unantes/software/construction/Bank.java index f8b3acf0..f9b72a6e 100755 --- a/src/main/java/fr/unantes/software/construction/Bank.java +++ b/src/main/java/fr/unantes/software/construction/Bank.java @@ -1,5 +1,6 @@ package fr.unantes.software.construction; +import com.sun.istack.internal.NotNull; import fr.unantes.software.construction.address.AddressBook; import java.io.InvalidClassException; @@ -106,7 +107,7 @@ public class Bank { * @role set ab * @param a */ - public void setAb(AddressBook a){ ab = a; } + public void setAb(@NotNull AddressBook a){ ab = a; } /** * @return clients @@ -127,7 +128,7 @@ public class Bank { * Returns the Client object corresponding to the client if it exists * Returns null if there is no client named name */ - public Client getClient(String name) { + public Client getClient(@NotNull String name) { Iterator it = this.clients.iterator(); while (it.hasNext()){ Client p = (Client)it.next(); @@ -145,7 +146,7 @@ public class Bank { * Returns null if no account has the number accountNumber * The assumption is that there cannot be several accounts with the same number */ - public Account getAccount(int accountNumber) { + public Account getAccount(@NotNull int accountNumber) { Iterator it = this.accounts.iterator(); while (it.hasNext()){ Account a = (Account)it.next(); @@ -161,7 +162,7 @@ public class Bank { * Deposits the amount on the account number accountNumber * Throws an exception if there is no account number accountNumber */ - public void deposit(int accountNumber, float amount) throws Exception { + public void deposit(@NotNull int accountNumber, @NotNull float amount) throws Exception { Account a = getAccount(accountNumber); if (a!=null){ a.deposit(amount); @@ -176,7 +177,7 @@ public class Bank { * Withdraws the amount from the account number accountNumber * Throws an exception if there is no account number accountNumber */ - public void withdraw(int accountNumber, float amount) throws Exception { + public void withdraw(@NotNull int accountNumber, @NotNull float amount) throws Exception { Account a = getAccount(accountNumber); if (a!=null){ a.withdraw(amount); @@ -191,7 +192,7 @@ public class Bank { * Returns the collection of accounts of the client named name * If there is no client named name, the method returns null */ - public Account[] getAccountsOfClient(String name) { + public Account[] getAccountsOfClient(@NotNull String name) { Client client = getClient(name); if (client!=null){ return client.accountsToArray(); diff --git a/src/main/java/fr/unantes/software/construction/Client.java b/src/main/java/fr/unantes/software/construction/Client.java index b7a7c061..1ca4f9e3 100644 --- a/src/main/java/fr/unantes/software/construction/Client.java +++ b/src/main/java/fr/unantes/software/construction/Client.java @@ -1,5 +1,6 @@ package fr.unantes.software.construction; +import com.sun.istack.internal.NotNull; import fr.unantes.software.construction.address.Address; import fr.unantes.software.construction.address.Card; @@ -25,7 +26,7 @@ public abstract class Client { * @param role * @throws InvalidClassException */ - public Client(String name, String role) throws InvalidClassException { + public Client(@NotNull String name, @NotNull String role) throws InvalidClassException { if (!role.equals("private") && !role.equals("company")) { throw new InvalidClassException("Invalid role supplied. A person can only be private or company"); } @@ -47,7 +48,7 @@ public abstract class Client { * @role set le nom * @param name */ - public void setName(String name) { + public void setName(@NotNull String name) { this.name = name; } @@ -63,14 +64,14 @@ public abstract class Client { * @param role * @throws InvalidClassException */ - public void setRole(String role) throws InvalidClassException { + public void setRole(@NotNull String role) throws InvalidClassException { if (!role.equals("private") && !role.equals("company")) { throw new InvalidClassException("Invalid role supplied. A person can only be private or company"); } this.role = role; } - public boolean equals(Object o) { + public boolean equals(@NotNull Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Client person = (Client) o; @@ -94,21 +95,21 @@ public abstract class Client { account = new ArrayList(); } - public void add(Account a){ + public void add(@NotNull Account a){ basicAdd(a); a.getClients().basicAdd(Client.this); } - public void remove(Account a){ + public void remove(@NotNull Account a){ basicRemove(a); a.getClients().basicRemove(Client.this); } - public void basicAdd(Account a) { + public void basicAdd(@NotNull Account a) { account.add(a); } - public void basicRemove(Account a) { + public void basicRemove(@NotNull Account a) { account.remove(a); } } @@ -125,7 +126,7 @@ public abstract class Client { * @role ajouter un compte * @uml.property name="accounts" */ - public void addAccounts(Account element) { + public void addAccounts(@NotNull Account element) { if(!containsAccounts(element)){ account.add(element); } @@ -135,7 +136,7 @@ public abstract class Client { * @role retirer un compte * @uml.property name="accounts" */ - public void removeAccounts(Account element) { + public void removeAccounts(@NotNull Account element) { if(containsAccounts(element)){ account.remove(element); } @@ -165,7 +166,7 @@ public abstract class Client { * * @uml.property name="accounts" */ - public boolean containsAccounts(Account element) { + public boolean containsAccounts(@NotNull Account element) { return account.account.contains(element); } @@ -190,7 +191,7 @@ public abstract class Client { car = null; } - public void set(Card c){ + public void set(@NotNull Card c){ basicSet(c); c.getClientReference().basicSet(Client.this); } @@ -200,7 +201,7 @@ public abstract class Client { basicUnSet(); } - public void basicSet(Card c){ + public void basicSet(@NotNull Card c){ this.car = c; } @@ -209,7 +210,7 @@ public abstract class Client { } } - public void setCard(Card c){ + public void setCard(@NotNull Card c){ card.set(c); } diff --git a/src/main/java/fr/unantes/software/construction/DepositOperation.java b/src/main/java/fr/unantes/software/construction/DepositOperation.java index d6536fab..05802852 100755 --- a/src/main/java/fr/unantes/software/construction/DepositOperation.java +++ b/src/main/java/fr/unantes/software/construction/DepositOperation.java @@ -1,6 +1,8 @@ package fr.unantes.software.construction; +import com.sun.istack.internal.NotNull; + import java.time.LocalTime; public class DepositOperation extends Operation { @@ -9,7 +11,7 @@ public class DepositOperation extends Operation { * @param amount * @param i */ - public DepositOperation(float amount, LocalTime i) { super(amount, i); } + public DepositOperation(@NotNull float amount, @NotNull LocalTime i) { super(amount, i); } /** * @return Deposit diff --git a/src/main/java/fr/unantes/software/construction/Entreprise.java b/src/main/java/fr/unantes/software/construction/Entreprise.java index 9755dc32..436bdd51 100644 --- a/src/main/java/fr/unantes/software/construction/Entreprise.java +++ b/src/main/java/fr/unantes/software/construction/Entreprise.java @@ -1,5 +1,6 @@ package fr.unantes.software.construction; +import com.sun.istack.internal.NotNull; import fr.unantes.software.construction.address.Card; import fr.unantes.software.construction.address.CompanyAddress; import fr.unantes.software.construction.address.CompanyCard; @@ -19,7 +20,7 @@ public class Entreprise extends Client { * @param address * @throws InvalidClassException */ - public Entreprise(String name, String role, CompanyAddress address ) throws InvalidClassException { + public Entreprise(@NotNull String name, @NotNull String role, @NotNull CompanyAddress address ) throws InvalidClassException { super(name, role); addressEntreprise = address; } @@ -33,13 +34,13 @@ public class Entreprise extends Client { * @role set l'adresse * @param address */ - public void setAddressEntreprise(CompanyAddress address) { this.addressEntreprise = address; } + public void setAddressEntreprise(@NotNull CompanyAddress address) { this.addressEntreprise = address; } /** * @role set la carte * @param c */ - public void setCard(Card c){ + public void setCard(@NotNull Card c){ if(c.getClass().equals(CompanyCard.class)){ getCardReference().set(c); } diff --git a/src/main/java/fr/unantes/software/construction/Operation.java b/src/main/java/fr/unantes/software/construction/Operation.java index 1464fb8e..95ea1bb9 100755 --- a/src/main/java/fr/unantes/software/construction/Operation.java +++ b/src/main/java/fr/unantes/software/construction/Operation.java @@ -1,5 +1,7 @@ package fr.unantes.software.construction; +import com.sun.istack.internal.NotNull; + import java.time.*; public abstract class Operation { @@ -32,13 +34,13 @@ public abstract class Operation { * @role set amount * @uml.property name="amount" */ - public void setAmount(float amount) { this.amount = amount; } + public void setAmount(@NotNull float amount) { this.amount = amount; } /** * @param amount * @param i */ - public Operation(float amount, LocalTime i) { + public Operation(@NotNull float amount, @NotNull LocalTime i) { this.amount = amount; this.time = i; account = new AccountReference(); @@ -58,7 +60,7 @@ public abstract class Operation { acc = null; } - public void set(Account a){ + public void set(@NotNull Account a){ basicSet(a); a.getOperations().basicAdd(Operation.this); } @@ -68,7 +70,7 @@ public abstract class Operation { basicUnSet(); } - public void basicSet(Account a) { + public void basicSet(@NotNull Account a) { acc = a; } @@ -77,7 +79,7 @@ public abstract class Operation { } } - public void setAccount(Account a) { + public void setAccount(@NotNull Account a) { account.set(a); } diff --git a/src/main/java/fr/unantes/software/construction/Particulier.java b/src/main/java/fr/unantes/software/construction/Particulier.java index d0b39e73..bab2dec5 100644 --- a/src/main/java/fr/unantes/software/construction/Particulier.java +++ b/src/main/java/fr/unantes/software/construction/Particulier.java @@ -1,5 +1,6 @@ package fr.unantes.software.construction; +import com.sun.istack.internal.NotNull; import fr.unantes.software.construction.address.Card; import fr.unantes.software.construction.address.PrivateAddress; import fr.unantes.software.construction.address.PrivateCard; @@ -19,7 +20,7 @@ public class Particulier extends Client { * @param address * @throws InvalidClassException */ - public Particulier(String name, String role, PrivateAddress address) throws InvalidClassException { + public Particulier(@NotNull String name, @NotNull String role, @NotNull PrivateAddress address) throws InvalidClassException { super(name,role); addressParticular = address; } @@ -33,13 +34,13 @@ public class Particulier extends Client { * @role set l'address du particulier * @param address */ - public void setAddressParticular(PrivateAddress address) { this.addressParticular = address; } + public void setAddressParticular(@NotNull PrivateAddress address) { this.addressParticular = address; } /** * @role set la carte * @param c */ - public void setCard(Card c){ + public void setCard(@NotNull Card c){ if(c.getClass().equals(PrivateCard.class)){ getCardReference().set(c); } diff --git a/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java b/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java index 2bb7210d..faf81731 100644 --- a/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java +++ b/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java @@ -1,5 +1,7 @@ package fr.unantes.software.construction; +import com.sun.istack.internal.NotNull; + import java.util.ArrayList; import java.util.Iterator; @@ -35,13 +37,13 @@ public class ReferenceUniDi{ * @role ajouter * @param obj */ - public void add(T obj){ list.add(obj); } + public void add(@NotNull T obj){ list.add(obj); } /** * @role retirer * @param obj */ - public void remove(T obj){ list.remove(obj); } + public void remove(@NotNull T obj){ list.remove(obj); } /** * @role savoir si la liste est vide @@ -57,13 +59,13 @@ public class ReferenceUniDi{ * @role savoir si la liste contient l'element * @param ele */ - public boolean contains(T ele){ return list.contains(ele); } + public boolean contains(@NotNull T ele){ return list.contains(ele); } /** * @role savoir si la liste contient une autre liste * @param ele */ - public boolean containsAll(ArrayList ele){ return list.containsAll(ele); } + public boolean containsAll(@NotNull ArrayList ele){ return list.containsAll(ele); } /** * @role taille de la liste diff --git a/src/main/java/fr/unantes/software/construction/WithdrawOperation.java b/src/main/java/fr/unantes/software/construction/WithdrawOperation.java index 4ac3a325..25ec412c 100755 --- a/src/main/java/fr/unantes/software/construction/WithdrawOperation.java +++ b/src/main/java/fr/unantes/software/construction/WithdrawOperation.java @@ -1,6 +1,8 @@ package fr.unantes.software.construction; +import com.sun.istack.internal.NotNull; + import java.time.LocalTime; public class WithdrawOperation extends Operation { @@ -9,7 +11,7 @@ public class WithdrawOperation extends Operation { * @param amount * @param i */ - public WithdrawOperation(float amount, LocalTime i) { super(amount, i); } + public WithdrawOperation(@NotNull float amount, @NotNull LocalTime i) { super(amount, i); } /** * @return withdraw diff --git a/src/main/java/fr/unantes/software/construction/address/Address.java b/src/main/java/fr/unantes/software/construction/address/Address.java index 9165597c..19e12798 100755 --- a/src/main/java/fr/unantes/software/construction/address/Address.java +++ b/src/main/java/fr/unantes/software/construction/address/Address.java @@ -1,7 +1,9 @@ package fr.unantes.software.construction.address; +import com.sun.istack.internal.NotNull; + /** - * @author + * @author * @version 1.0 * @date 17/12/2004. */ @@ -29,13 +31,23 @@ public abstract class Address { * @param rue le nom de la rue * @param ville le nom de la ville * @param code_postal le numero de code postal + * @throws IllegalArgumentException if uneVoie < 0 + * @throws IllegalArgumentException if code_postal < 0 */ - public Address(int uneVoie, String rue, City ville, int code_postal, - String comAd) { - this._voie = uneVoie; + + public Address(@NotNull int uneVoie, @NotNull String rue, @NotNull City ville, int code_postal, String comAd){ + if(uneVoie < 0){ + throw new IllegalArgumentException("uneVoie négatif"); + } else { + this._voie = uneVoie; + } this._rue = rue; this._ville = ville; - this._code_postal = code_postal; + if(code_postal < 0){ + throw new IllegalArgumentException("code_postal négatif"); + } else { + this._code_postal = code_postal; + } this._comAd = comAd; } @@ -87,16 +99,22 @@ public abstract class Address { /** * @role set le nom de la voie * @param voie + * @throws IllegalArgumentException if voie < 0 */ public void setVoie(int voie) { - _voie = voie; + if(voie < 0){ + throw new IllegalArgumentException("voie négatif"); + } else { + _voie = voie; + } } /** * @role set le nom de la rue * @param rue */ - public void setRue(String rue) { + + public void setRue(@NotNull String rue) { _rue = rue; } @@ -112,16 +130,21 @@ public abstract class Address { * @role set le nom de la ville * @param ville */ - public void setVille(City ville) { + public void setVille(@NotNull City ville) { _ville = ville; } /** * @role set le numero de code postal * @param code_postal + * @throws IllegalArgumentException if code_postal < 0 */ public void setCode_postal(int code_postal) { - _code_postal = code_postal; + if(code_postal < 0){ + throw new IllegalArgumentException("code_postal négatif"); + } else { + _code_postal = code_postal; + } } diff --git a/src/main/java/fr/unantes/software/construction/address/AddressBook.java b/src/main/java/fr/unantes/software/construction/address/AddressBook.java index c9c0e4af..cfc714b3 100755 --- a/src/main/java/fr/unantes/software/construction/address/AddressBook.java +++ b/src/main/java/fr/unantes/software/construction/address/AddressBook.java @@ -1,5 +1,7 @@ package fr.unantes.software.construction.address; +import com.sun.istack.internal.NotNull; + /** * @author * @version 1.0 @@ -25,7 +27,7 @@ public class AddressBook { * @param nom nom de l'adresseBook * @param lF liste de cartes */ - public AddressBook(String nom, CardList lF) { + public AddressBook(@NotNull String nom, @NotNull CardList lF) { _nom = nom; fiches = new CardList(); fiches.setListeCard(lF.getListeCard()); @@ -49,7 +51,7 @@ public class AddressBook { * @role set le nom * @param nom */ - public void setNom(String nom) { + public void setNom(@NotNull String nom) { _nom = nom; } @@ -57,7 +59,7 @@ public class AddressBook { * @role set la liste de cartes * @param lF */ - public void setListe(CardList lF) { + public void setListe(@NotNull CardList lF) { fiches.setListeCard(lF.getListeCard()); } @@ -67,7 +69,7 @@ public class AddressBook { * @param nom un nom * @return res fusion des deux répertoires */ - public AddressBook merge(AddressBook r, String nom) { + public AddressBook merge(@NotNull AddressBook r, @NotNull String nom) { AddressBook res = new AddressBook(); CardList lF; lF = fiches.merge(r.getListe()); diff --git a/src/main/java/fr/unantes/software/construction/address/AddressList.java b/src/main/java/fr/unantes/software/construction/address/AddressList.java index 4e149f65..3181e903 100755 --- a/src/main/java/fr/unantes/software/construction/address/AddressList.java +++ b/src/main/java/fr/unantes/software/construction/address/AddressList.java @@ -6,6 +6,8 @@ package fr.unantes.software.construction.address; * @date 17/12/2004. */ +import com.sun.istack.internal.NotNull; + import java.util.*; public class AddressList { @@ -25,7 +27,7 @@ public class AddressList { /** * @param lA une adresse */ - public AddressList(AddressList lA) { + public AddressList(@NotNull AddressList lA) { adresses = new Vector(); for (Enumeration e = lA.getListeAdresse().elements(); e .hasMoreElements();) { @@ -44,7 +46,7 @@ public class AddressList { * @role set la liste d'adresses * @param lA */ - public void setListeAdresse(Vector lA) { + public void setListeAdresse(@NotNull Vector lA) { for (Enumeration e = lA.elements(); e.hasMoreElements();) { adresses.add((Address) e.nextElement()); } @@ -54,7 +56,7 @@ public class AddressList { * @role ajoute une address * @param a une address */ - public void ajouter(Address a) { + public void ajouter(@NotNull Address a) { if (!rechercher(a)) adresses.add(a); } @@ -63,7 +65,7 @@ public class AddressList { * @role delete une address * @param a une address */ - public void supprimer(Address a) { + public void supprimer(@NotNull Address a) { if (rechercher(a)) adresses.remove(a); else @@ -74,7 +76,7 @@ public class AddressList { * @role recherche une address * @param a une address */ - public boolean rechercher(Address a) { + public boolean rechercher(@NotNull Address a) { return adresses.contains(a); } diff --git a/src/main/java/fr/unantes/software/construction/address/Card.java b/src/main/java/fr/unantes/software/construction/address/Card.java index 7f82b8a8..96eeca7f 100755 --- a/src/main/java/fr/unantes/software/construction/address/Card.java +++ b/src/main/java/fr/unantes/software/construction/address/Card.java @@ -1,5 +1,6 @@ package fr.unantes.software.construction.address; +import com.sun.istack.internal.NotNull; import fr.unantes.software.construction.Client; /** @@ -22,7 +23,7 @@ public abstract class Card { /** * Constructor empty */ - public Card(String nom) { + public Card(@NotNull String nom) { identification = nom; client = new ClientReference(); } @@ -60,7 +61,7 @@ public abstract class Card { * @role set la liste d'adresses * @param ad une liste d'adresses */ - public void setListeAdresse(AddressList ad) { + public void setListeAdresse(@NotNull AddressList ad) { _ad.setListeAdresse(ad.getListeAdresse()); } @@ -68,7 +69,7 @@ public abstract class Card { * @role ajoute une adresse * @param a une adresse */ - public void addAddress(Address a) { + public void addAddress(@NotNull Address a) { _ad.ajouter(a); } @@ -76,7 +77,7 @@ public abstract class Card { * @role supprime une adresse * @param a une adresse */ - public void deleteAddress(Address a) { + public void deleteAddress(@NotNull Address a) { _ad.supprimer(a); } @@ -84,7 +85,7 @@ public abstract class Card { * @role set la liste de telephones * @param tel une liste de telephones */ - public void setListeTel(PhoneList tel) { + public void setListeTel(@NotNull PhoneList tel) { _tel = tel; } @@ -92,7 +93,7 @@ public abstract class Card { * @role set la liste de mails * @param mail une liste de mails */ - public void setListeMail(MailList mail) { + public void setListeMail(@NotNull MailList mail) { _mail = mail; } @@ -100,7 +101,7 @@ public abstract class Card { * @role set la liste de groupes * @param grp une liste de groupes */ - public void setListeGroupe(GroupList grp) { + public void setListeGroupe(@NotNull GroupList grp) { _grp.setListeGroupe(grp.getListeGroupe()); } @@ -108,7 +109,7 @@ public abstract class Card { * @role ajoute un groupe * @param grp un groupe */ - public void addGroupe(Group grp) { + public void addGroupe(@NotNull Group grp) { _grp.add(grp); } @@ -116,16 +117,16 @@ public abstract class Card { * @role supprimer une groupe * @param grp un groupe */ - public void deleteGroupe(Group grp) { + public void deleteGroupe(@NotNull Group grp) { _grp.delete(grp); } - public abstract Card merge(Card f); + public abstract Card merge(@NotNull Card f); - public abstract CompanyCard mergeCompanyCard(CompanyCard f); + public abstract CompanyCard mergeCompanyCard(@NotNull CompanyCard f); - public abstract PrivateCard fusionFichePart(PrivateCard f); + public abstract PrivateCard fusionFichePart(@NotNull PrivateCard f); public abstract String toXML(); @@ -134,7 +135,7 @@ public abstract class Card { * @param f * @return */ - public boolean memeFiche(Card f) { + public boolean memeFiche(@NotNull Card f) { return (identification.equals(f.getIdentification())); } @@ -149,7 +150,7 @@ public abstract class Card { * @role set l'identificateur * @param str */ - public void setIdentification(String str) { + public void setIdentification(@NotNull String str) { identification = str; } @@ -157,7 +158,7 @@ public abstract class Card { * @param other * @return */ - public boolean equals(Object other) { + public boolean equals(@NotNull Object other) { if (other instanceof Card) { return identification.equals(((Card) other).identification); } @@ -176,7 +177,7 @@ public abstract class Card { client = null; } - public void set(Client c){ + public void set(@NotNull Client c){ basicSet(c); c.getCardReference().basicSet(Card.this); } @@ -186,7 +187,7 @@ public abstract class Card { basicUnSet(); } - public void basicSet(Client c){ + public void basicSet(@NotNull Client c){ client = c; } @@ -195,7 +196,7 @@ public abstract class Card { } } - public void setClient(Client c){ + public void setClient(@NotNull Client c){ client.set(c); } diff --git a/src/main/java/fr/unantes/software/construction/address/CardList.java b/src/main/java/fr/unantes/software/construction/address/CardList.java index 155cf6eb..b2a9d08d 100755 --- a/src/main/java/fr/unantes/software/construction/address/CardList.java +++ b/src/main/java/fr/unantes/software/construction/address/CardList.java @@ -1,5 +1,7 @@ package fr.unantes.software.construction.address; +import com.sun.istack.internal.NotNull; + import java.util.*; public class CardList { @@ -19,7 +21,7 @@ public class CardList { /** * @param lF */ - public CardList (CardList lF){ + public CardList (@NotNull CardList lF){ _listeCard = new Vector(); for (Enumeration e = lF.getListeCard().elements() ; e.hasMoreElements() ;) { _listeCard.add(e.nextElement()); @@ -37,7 +39,7 @@ public class CardList { * @role set la liste de cartes * @param lF une liste de cartes */ - public void setListeCard(Vector lF){ + public void setListeCard(@NotNull Vector lF){ for (Enumeration e = lF.elements() ; e.hasMoreElements() ;) { _listeCard.add(e.nextElement()); } @@ -47,7 +49,7 @@ public class CardList { * @role ajouter une carte * @param f carte à ajouter dans la liste */ - public void add(Card f){ + public void add(@NotNull Card f){ if(!find(f)) _listeCard.add(f); } @@ -55,7 +57,7 @@ public class CardList { * @role supprime une carte * @param f carte à supprimer de la liste */ - public void delete(Card f){ + public void delete(@NotNull Card f){ if (find(f)) _listeCard.remove(f); else System.out.println("l'adresse a existe pas"); } @@ -64,7 +66,7 @@ public class CardList { * @role recherche une carte * @param f une carte */ - public boolean find(Card f){ + public boolean find(@NotNull Card f){ return _listeCard.contains(f); } @@ -73,7 +75,7 @@ public class CardList { * @param lF liste a faire fusionner * @return res la liste fusion de la liste courante et de la liste passé en paramètre */ - public CardList merge(CardList lF){ + public CardList merge(@NotNull CardList lF){ CardList res = new CardList(); boolean r; @@ -109,7 +111,7 @@ public class CardList { /** * @return res */ - public String toTring(){ + public String toString(){ String res = ""; for (Enumeration e = _listeCard.elements() ; e.hasMoreElements() ;) { res = res + "/n" + e.nextElement().toString(); diff --git a/src/main/java/fr/unantes/software/construction/address/City.java b/src/main/java/fr/unantes/software/construction/address/City.java index 2a4c4460..c9ee5607 100644 --- a/src/main/java/fr/unantes/software/construction/address/City.java +++ b/src/main/java/fr/unantes/software/construction/address/City.java @@ -1,5 +1,7 @@ package fr.unantes.software.construction.address; +import com.sun.istack.internal.NotNull; + /** * A city */ @@ -15,7 +17,7 @@ public class City { * @param country le pays * @param name le nom de la ville */ - public City(String country, String name) { + public City(@NotNull String country, @NotNull String name) { this.country = country; this.name = name; } @@ -31,7 +33,7 @@ public class City { * @role set la country * @param country un pays */ - public void setCountry(String country) { + public void setCountry(@NotNull String country) { this.country = country; } @@ -46,7 +48,7 @@ public class City { * @role set le nom de la ville * @param name le nom de la ville */ - public void setName(String name) { + public void setName(@NotNull String name) { this.name = name; } diff --git a/src/main/java/fr/unantes/software/construction/address/CompanyAddress.java b/src/main/java/fr/unantes/software/construction/address/CompanyAddress.java index fa36e524..3342fbde 100755 --- a/src/main/java/fr/unantes/software/construction/address/CompanyAddress.java +++ b/src/main/java/fr/unantes/software/construction/address/CompanyAddress.java @@ -1,5 +1,7 @@ package fr.unantes.software.construction.address; +import com.sun.istack.internal.NotNull; + /** * Cette Classe permet de fabriquer un objet Adresse. * @@ -27,9 +29,11 @@ public class CompanyAddress extends Address { * @param secteur le secteur de la rue * @param ville le nom de la ville * @param code_postal le numero de code postal + * @throws IllegalArgumentException if Voie < 0 + * @throws IllegalArgumentException if code_postal < 0 */ - public CompanyAddress(int voie, String rue, City ville, int code_postal, - String comAd, String secteur) { + public CompanyAddress(@NotNull int voie, @NotNull String rue, @NotNull City ville, int code_postal, + @NotNull String comAd, @NotNull String secteur) { super(voie, rue, ville, code_postal, comAd); _secteur = secteur; } @@ -37,7 +41,7 @@ public class CompanyAddress extends Address { /** * @param f une adresse */ - public CompanyAddress(CompanyAddress f) { + public CompanyAddress(@NotNull CompanyAddress f) { super(f.getVoie(),f.getRue(),f.getVille(),f.getCode_postal(),f.getComAd()); _secteur = f.getSecteur(); } @@ -53,7 +57,7 @@ public class CompanyAddress extends Address { * @role set le secteur * @param secteur le nom du secteur */ - public void setSecteur(String secteur) { + public void setSecteur(@NotNull String secteur) { _secteur = secteur; } diff --git a/src/main/java/fr/unantes/software/construction/address/CompanyCard.java b/src/main/java/fr/unantes/software/construction/address/CompanyCard.java index 66851678..02ed7f49 100755 --- a/src/main/java/fr/unantes/software/construction/address/CompanyCard.java +++ b/src/main/java/fr/unantes/software/construction/address/CompanyCard.java @@ -1,5 +1,6 @@ package fr.unantes.software.construction.address; +import com.sun.istack.internal.NotNull; import fr.unantes.software.construction.Client; import fr.unantes.software.construction.Entreprise; @@ -13,7 +14,7 @@ public class CompanyCard extends Card { /** * @param raison_social */ - public CompanyCard(String raison_social) { + public CompanyCard(@NotNull String raison_social) { super(raison_social); _raison_social = raison_social; } @@ -29,7 +30,7 @@ public class CompanyCard extends Card { * @role set la raison social * @param raison_social */ - public void setRaisonSocial(String raison_social) { + public void setRaisonSocial(@NotNull String raison_social) { _raison_social = raison_social; } @@ -37,7 +38,7 @@ public class CompanyCard extends Card { * @param f * @return res */ - public CompanyCard mergeCompanyCard(CompanyCard f) { + public CompanyCard mergeCompanyCard(@NotNull CompanyCard f) { CompanyCard res = new CompanyCard(getIdentification()); f.setIdentification(getIdentification()); f.setRaisonSocial(getRaisonSocial()); @@ -54,7 +55,7 @@ public class CompanyCard extends Card { * @param f une carte * @return res la fusion des deux cartes */ - public Card merge(Card f) { + public Card merge(@NotNull Card f) { Card res = new PrivateCard(getIdentification()); if (memeFiche(f)) res = f.mergeCompanyCard(this); @@ -65,7 +66,7 @@ public class CompanyCard extends Card { * @param f * @return null */ - public PrivateCard fusionFichePart(PrivateCard f) { + public PrivateCard fusionFichePart(@NotNull PrivateCard f) { return null; } @@ -74,7 +75,7 @@ public class CompanyCard extends Card { + getListeTel().toXML() + getListeMail().toXML() + getListeGroupe().toXML() + ""); } - public void setClient(Client c){ + public void setClient(@NotNull Client c){ if(c.getClass().equals(Entreprise.class)){ getClientReference().set(c); } diff --git a/src/main/java/fr/unantes/software/construction/address/Group.java b/src/main/java/fr/unantes/software/construction/address/Group.java index 572fa0bf..931b5352 100755 --- a/src/main/java/fr/unantes/software/construction/address/Group.java +++ b/src/main/java/fr/unantes/software/construction/address/Group.java @@ -1,5 +1,7 @@ package fr.unantes.software.construction.address; +import com.sun.istack.internal.NotNull; + /** * * @author @@ -24,7 +26,7 @@ public class Group { * @param grp le nom du groupe * @param comGrp commentaire sur le groupe */ - public Group(String grp, String comGrp) { + public Group(@NotNull String grp,@NotNull String comGrp) { _grp = grp; _comGrp = comGrp; } @@ -47,7 +49,7 @@ public class Group { * @role set le nom du groupe * @param grp nom du groupe */ - public void setGrp(String grp) { + public void setGrp(@NotNull String grp) { _grp = grp; } @@ -55,7 +57,7 @@ public class Group { * @role set commentaire sur le groupe * @param comGrp commentaire sur le group */ - public void setComGrp(String comGrp) { + public void setComGrp(@NotNull String comGrp) { _comGrp = comGrp; } @@ -63,7 +65,7 @@ public class Group { * @param g * @return */ - public boolean sameGroup(Group g) { + public boolean sameGroup(@NotNull Group g) { return (_grp.equals(g.getGrp())); } @@ -72,7 +74,7 @@ public class Group { * @param g un groupe * @return res fusion des deux groupes */ - public Group merge(Group g) { + public Group merge(@NotNull Group g) { Group res = null; if (sameGroup(g)) { res = new Group(_grp, ""); diff --git a/src/main/java/fr/unantes/software/construction/address/GroupList.java b/src/main/java/fr/unantes/software/construction/address/GroupList.java index 530a1e7c..19f0c14e 100755 --- a/src/main/java/fr/unantes/software/construction/address/GroupList.java +++ b/src/main/java/fr/unantes/software/construction/address/GroupList.java @@ -1,5 +1,7 @@ package fr.unantes.software.construction.address; +import com.sun.istack.internal.NotNull; + import java.util.*; public class GroupList { @@ -19,7 +21,7 @@ public class GroupList { /** * @param lG liste de groupes */ - public GroupList(GroupList lG) { + public GroupList(@NotNull GroupList lG) { _listeGroup = new Vector(); for (Enumeration e = lG.getListeGroupe().elements(); e.hasMoreElements();) { _listeGroup.add((Group) e.nextElement()); @@ -37,7 +39,7 @@ public class GroupList { * @role set la liste de groupes * @param lG une groupe */ - public void setListeGroupe(Vector lG) { + public void setListeGroupe(@NotNull Vector lG) { for (Enumeration e = lG.elements(); e.hasMoreElements();) { _listeGroup.add((Group) e.nextElement()); } @@ -47,7 +49,7 @@ public class GroupList { * @role ajoute un groupe * @param g groupe a ajouter dans la liste */ - public void add(Group g) { + public void add(@NotNull Group g) { if (!find(g)) _listeGroup.add(g); } @@ -56,7 +58,7 @@ public class GroupList { * @role supprime un groupe * @param g groupe a supprimer de la liste */ - public void delete(Group g) { + public void delete(@NotNull Group g) { if (find(g)) _listeGroup.remove(g); else @@ -67,7 +69,7 @@ public class GroupList { * @role recherche un groupe * @param g c'est l'element recherche */ - public boolean find(Group g) { + public boolean find(@NotNull Group g) { boolean res = false; for (Enumeration e = _listeGroup.elements(); e .hasMoreElements();) { @@ -82,7 +84,7 @@ public class GroupList { * @param lg 2eme liste a faire fusionner * @return res La 3eme liste fusion de la liste courante et de la liste passee en parametre */ - public GroupList merge(GroupList lg) { + public GroupList merge(@NotNull GroupList lg) { GroupList res = new GroupList(); /** diff --git a/src/main/java/fr/unantes/software/construction/address/Mail.java b/src/main/java/fr/unantes/software/construction/address/Mail.java index 451b9319..c81e7e29 100755 --- a/src/main/java/fr/unantes/software/construction/address/Mail.java +++ b/src/main/java/fr/unantes/software/construction/address/Mail.java @@ -1,5 +1,7 @@ package fr.unantes.software.construction.address; +import com.sun.istack.internal.NotNull; + public class Mail { /** @@ -12,7 +14,7 @@ public class Mail { * @param mail * @param com */ - public Mail(String mail, String com) { + public Mail(@NotNull String mail,@NotNull String com) { home = mail; work = com; } @@ -35,7 +37,7 @@ public class Mail { * @role set le home * @param mail */ - public void setHome(String mail) { + public void setHome(@NotNull String mail) { home = mail; } @@ -43,7 +45,7 @@ public class Mail { * @role set le work * @param com */ - public void setWork(String com) { + public void setWork(@NotNull String com) { work = com; } @@ -51,7 +53,7 @@ public class Mail { * @role fusionne des deux mails * @param m mail a faire fusionner avec l'objet mail courant. */ - public void fusion(Mail m) { + public void fusion(@NotNull Mail m) { if (home == null) home = m.getHome(); if (work == null) @@ -66,7 +68,7 @@ public class Mail { return ("" + home + " " + work); } - public boolean equals(Object another) { + public boolean equals(@NotNull Object another) { if (this == another) return true; if (!(another instanceof Mail)) diff --git a/src/main/java/fr/unantes/software/construction/address/MailList.java b/src/main/java/fr/unantes/software/construction/address/MailList.java index 122315a4..d2984e75 100755 --- a/src/main/java/fr/unantes/software/construction/address/MailList.java +++ b/src/main/java/fr/unantes/software/construction/address/MailList.java @@ -7,6 +7,8 @@ package fr.unantes.software.construction.address; * @date 17/12/2004. */ +import com.sun.istack.internal.NotNull; + import java.util.*; public class MailList { @@ -26,7 +28,7 @@ public class MailList { /** * @param lM */ - public MailList(MailList lM) { + public MailList(@NotNull MailList lM) { _listeMail = new Vector(); for (Enumeration e = lM.getListeMail().elements(); e .hasMoreElements();) { @@ -46,7 +48,7 @@ public class MailList { * @role set la liste de mails * @param lM */ - public void setListeMail(Vector lM) { + public void setListeMail(@NotNull Vector lM) { for (Enumeration e = lM.elements(); e.hasMoreElements();) { _listeMail.add((Mail) e.nextElement()); } @@ -56,7 +58,7 @@ public class MailList { * @role ajouter un mail * @param m mail a ajouter dans la liste de mails */ - public void ajouter(Mail m) { + public void ajouter(@NotNull Mail m) { if (!find(m)) _listeMail.add(m); // si existe deja faire la fusion des deux dans celle deja enregistree @@ -71,7 +73,7 @@ public class MailList { * @role supprime un mail * @param m mail a supprimer de la liste de mails */ - public void delete(Mail m) { + public void delete(@NotNull Mail m) { if (find(m)) _listeMail.remove(m); else @@ -82,7 +84,7 @@ public class MailList { * @role recherche un mail * @param m c'est le mail recherche */ - public boolean find(Mail m) { + public boolean find(@NotNull Mail m) { boolean res = false; for (Enumeration e = _listeMail.elements(); e.hasMoreElements();) { if (((Mail) e.nextElement()).getHome().equals(m.getHome())) @@ -96,7 +98,7 @@ public class MailList { * @param lM 2eme liste a faire fusionner * @return res la 3eme liste fusion de la liste courante et de la liste passee en parametre */ - public MailList merge(MailList lM) { + public MailList merge(@NotNull MailList lM) { MailList res = new MailList(); /** diff --git a/src/main/java/fr/unantes/software/construction/address/Phone.java b/src/main/java/fr/unantes/software/construction/address/Phone.java index 93917987..f23580d8 100755 --- a/src/main/java/fr/unantes/software/construction/address/Phone.java +++ b/src/main/java/fr/unantes/software/construction/address/Phone.java @@ -1,5 +1,7 @@ package fr.unantes.software.construction.address; +import com.sun.istack.internal.NotNull; + /** * @author * @version 1.0 @@ -16,9 +18,14 @@ public class Phone { /** * @param num * @param com + * @throws IllegalArgumentException if num < 0 */ - public Phone(int num, String com) { - number = num; + public Phone(@NotNull int num, @NotNull String com) { + if(num < 0){ + throw new IllegalArgumentException("num negatif"); + } else { + number = num; + } comment = com; } @@ -39,16 +46,21 @@ public class Phone { /** * @role set le numero de telephone * @param num_tel + * @throws IllegalArgumentException if num_tel < 0 */ public void setNumTel(int num_tel) { - number = num_tel; + if(num_tel < 0){ + throw new IllegalArgumentException("num_tel negatif"); + } else { + number = num_tel; + } } /** * @role set le commentaire de tel * @param com */ - public void setComTel(String com) { + public void setComTel(@NotNull String com) { comment = com; } @@ -56,7 +68,7 @@ public class Phone { * @role fusion de deux numeros de telephones * @param t tel a faire fusionner avec l'objet tel courant. */ - public Phone merge(Phone t) { + public Phone merge(@NotNull Phone t) { int i = (number == 0 ? t.number : number); String s = (comment == null ? t.comment : comment); @@ -67,7 +79,7 @@ public class Phone { return ("" + number + comment + ""); } - public boolean equals(Object another){ + public boolean equals(@NotNull Object another){ if (this == another) return true; if (!(another instanceof Phone)) diff --git a/src/main/java/fr/unantes/software/construction/address/PhoneList.java b/src/main/java/fr/unantes/software/construction/address/PhoneList.java index 8a4dbc29..eec1f9b3 100755 --- a/src/main/java/fr/unantes/software/construction/address/PhoneList.java +++ b/src/main/java/fr/unantes/software/construction/address/PhoneList.java @@ -1,5 +1,7 @@ package fr.unantes.software.construction.address; +import com.sun.istack.internal.NotNull; + import java.util.*; public class PhoneList { @@ -19,7 +21,7 @@ public class PhoneList { /** * @param lT */ - public PhoneList(PhoneList lT) { + public PhoneList(@NotNull PhoneList lT) { telephones = new Vector(); for (Enumeration e = lT.getListeTel().elements(); e .hasMoreElements();) { @@ -39,7 +41,7 @@ public class PhoneList { * @role set la liste de telephones * @param lT */ - public void setListeTel(Vector lT) { + public void setListeTel(@NotNull Vector lT) { for (Enumeration e = lT.elements(); e.hasMoreElements();) { telephones.add((Phone) e.nextElement()); } @@ -49,7 +51,7 @@ public class PhoneList { * @role ajouter un tel * @param t tel a ajouter dans la liste de telephones */ - public void add(Phone t) { + public void add(@NotNull Phone t) { if (!find(t)) telephones.add(t); /** @@ -62,7 +64,7 @@ public class PhoneList { * @role supprimer un tel * @param t telephone a supprimer de la liste */ - public void delete(Phone t) { + public void delete(@NotNull Phone t) { if (find(t)) telephones.remove(t); else @@ -74,7 +76,7 @@ public class PhoneList { * @param t c'est le telephone recherche * @return res */ - public boolean find(Phone t) { + public boolean find(@NotNull Phone t) { boolean res = false; for (Enumeration e = telephones.elements(); e.hasMoreElements();) { if (((Phone) e.nextElement()).getNumTel() == t.getNumTel()) @@ -88,7 +90,7 @@ public class PhoneList { * @param lT liste de tel a faire fusionner * @return res La fusion de la liste courante et de la liste passee en parametre */ - public PhoneList merge(PhoneList lT) { + public PhoneList merge(@NotNull PhoneList lT) { PhoneList res = new PhoneList(); /** diff --git a/src/main/java/fr/unantes/software/construction/address/PrivateAddress.java b/src/main/java/fr/unantes/software/construction/address/PrivateAddress.java index 41f6f021..c3f8015d 100755 --- a/src/main/java/fr/unantes/software/construction/address/PrivateAddress.java +++ b/src/main/java/fr/unantes/software/construction/address/PrivateAddress.java @@ -1,5 +1,7 @@ package fr.unantes.software.construction.address; +import com.sun.istack.internal.NotNull; + /** * @author * @version 1.0 @@ -26,8 +28,8 @@ public class PrivateAddress extends Address { * @param ville le nom de la ville * @param code_postal le numero de code postal */ - public PrivateAddress(int voie, String rue, City ville, int code_postal, - String comAd, String lieu_dit) { + public PrivateAddress(@NotNull int voie, @NotNull String rue, @NotNull City ville, int code_postal, + String comAd, @NotNull String lieu_dit) { super(voie, rue, ville, code_postal, comAd); lieuDit = lieu_dit; } @@ -35,7 +37,7 @@ public class PrivateAddress extends Address { /** * @param f une adresse */ - public PrivateAddress(PrivateAddress f) { + public PrivateAddress(@NotNull PrivateAddress f) { super(f.getVoie(),f.getRue(),f.getVille(),f.getCode_postal(),f.getComAd()); lieuDit = f.getLieu_dit(); } @@ -51,7 +53,7 @@ public class PrivateAddress extends Address { * @role set le nom du lieu dit * @param lieu_dit le nom du lieu dit */ - public void setLieu_dit(String lieu_dit) { + public void setLieu_dit(@NotNull String lieu_dit) { lieuDit = lieu_dit; } diff --git a/src/main/java/fr/unantes/software/construction/address/PrivateCard.java b/src/main/java/fr/unantes/software/construction/address/PrivateCard.java index b5fd706b..95e5c1b0 100755 --- a/src/main/java/fr/unantes/software/construction/address/PrivateCard.java +++ b/src/main/java/fr/unantes/software/construction/address/PrivateCard.java @@ -1,5 +1,6 @@ package fr.unantes.software.construction.address; +import com.sun.istack.internal.NotNull; import fr.unantes.software.construction.Client; import fr.unantes.software.construction.Particulier; @@ -21,7 +22,7 @@ public class PrivateCard extends Card { * @param nom le nom * @param prenom le prenom */ - public PrivateCard(String nom, String prenom) { + public PrivateCard(@NotNull String nom, @NotNull String prenom) { super(nom + prenom); _nomP = nom; _prenom = prenom; @@ -30,7 +31,7 @@ public class PrivateCard extends Card { /** * @param id l'id */ - public PrivateCard(String id) { + public PrivateCard(@NotNull String id) { super(id); _nomP = ""; _prenom = ""; @@ -53,7 +54,7 @@ public class PrivateCard extends Card { /** * @return _nom nom de la personne de la carte */ - public void setNomP(String nom) { + public void setNomP(@NotNull String nom) { _nomP = nom; } @@ -61,7 +62,7 @@ public class PrivateCard extends Card { * @role set le prenom * @param prenom prenom de la personne de la carte */ - public void setPrenom(String prenom) { + public void setPrenom(@NotNull String prenom) { _prenom = prenom; } @@ -70,7 +71,7 @@ public class PrivateCard extends Card { * @param f carte a faire fusionner avec la carte courante * @return carte resultant de la fusion de la carte courante et celle passee en parametre */ - public Card merge(Card f) { + public Card merge(@NotNull Card f) { Card res = new PrivateCard(getIdentification()); if (memeFiche(f)) res = f.fusionFichePart(this); @@ -81,7 +82,7 @@ public class PrivateCard extends Card { * @param f * @return null */ - public CompanyCard mergeCompanyCard(CompanyCard f) { + public CompanyCard mergeCompanyCard(@NotNull CompanyCard f) { return null; } @@ -89,7 +90,7 @@ public class PrivateCard extends Card { * @param f * @return res */ - public PrivateCard fusionFichePart(PrivateCard f) { + public PrivateCard fusionFichePart(@NotNull PrivateCard f) { PrivateCard res = new PrivateCard(getIdentification()); res.setIdentification(getIdentification()); res.setNomP(_nomP); @@ -113,7 +114,7 @@ public class PrivateCard extends Card { * @role set le client * @param c */ - public void setClient(Client c){ + public void setClient(@NotNull Client c){ if(c.getClass().equals(Particulier.class)){ getClientReference().set(c); } diff --git a/src/main/java/fr/unantes/software/construction/security/ClientController.java b/src/main/java/fr/unantes/software/construction/security/ClientController.java index f2518712..23e6f887 100644 --- a/src/main/java/fr/unantes/software/construction/security/ClientController.java +++ b/src/main/java/fr/unantes/software/construction/security/ClientController.java @@ -1,5 +1,6 @@ package fr.unantes.software.construction.security; +import com.sun.istack.internal.NotNull; import fr.unantes.software.construction.Client; import java.util.HashMap; @@ -21,7 +22,7 @@ public class ClientController { * @param person - User to search for * @return True if the user is registered, False otherwise */ - public boolean hasUser(Client person) { + public boolean hasUser(@NotNull Client person) { return namesToUsers.containsKey(person.getName()); } @@ -32,7 +33,7 @@ public class ClientController { * @return True if everything went smoothly, False otherwise * @throws IllegalArgumentException */ - public boolean addUser(Client person, String password) throws IllegalArgumentException { + public boolean addUser(@NotNull Client person, @NotNull String password) throws IllegalArgumentException { if (namesToUsers.containsKey(person.getName())) { throw new IllegalArgumentException("Invalid argument: the person is already registered."); } @@ -46,7 +47,7 @@ public class ClientController { * @param person - User to remove * @return True if everything went smoothly, False otherwise */ - public boolean removeUser(Client person) { + public boolean removeUser(@NotNull Client person) { if (namesToUsers.containsKey(person.getName())) { Client p = (Client) namesToUsers.get(person.getName()); usersToPasswords.remove(p.getName()); @@ -61,7 +62,7 @@ public class ClientController { * @param password - password to validate * @return True if the password is valid, false otherwise */ - public boolean validatePassword(Client person, String password) { + public boolean validatePassword(@NotNull Client person, @NotNull String password) { if (namesToUsers.containsKey(person.getName())) { Client p = (Client) namesToUsers.get(person.getName()); String reference = (String) usersToPasswords.get(p.getName()); diff --git a/src/main/java/fr/unantes/software/construction/security/Password.java b/src/main/java/fr/unantes/software/construction/security/Password.java index 81c13d76..55fa20b0 100644 --- a/src/main/java/fr/unantes/software/construction/security/Password.java +++ b/src/main/java/fr/unantes/software/construction/security/Password.java @@ -1,5 +1,7 @@ package fr.unantes.software.construction.security; +import com.sun.istack.internal.NotNull; + import java.security.spec.KeySpec; import java.util.Base64; import javax.crypto.Cipher; @@ -25,7 +27,7 @@ public class Password { * @throws IllegalArgumentException */ - public static String encryptPassword(String password) { + public static String encryptPassword(@NotNull String password) { try { byte[] iv = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; IvParameterSpec ivspec = new IvParameterSpec(iv); @@ -51,7 +53,7 @@ public class Password { * @param encrypted - Password to decrypt * @return Decrypted password */ - public static String decryptPassword(String encrypted) { + public static String decryptPassword(@NotNull String encrypted) { try { byte[] iv = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; IvParameterSpec ivspec = new IvParameterSpec(iv); diff --git a/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java b/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java index 1c822680..d99a030d 100644 --- a/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java +++ b/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java @@ -1,5 +1,6 @@ package fr.unantes.software.construction.ui; +import com.sun.istack.internal.NotNull; import fr.unantes.software.construction.Bank; import fr.unantes.software.construction.Client; import fr.unantes.software.construction.Entreprise; @@ -39,7 +40,7 @@ public class GraphicalUserInterface extends Application { return bank; } - public void setBank(Bank b) { + public void setBank(@NotNull Bank b) { bank = b; } @@ -47,11 +48,11 @@ public class GraphicalUserInterface extends Application { return controller; } - public void setController(ClientController c) { + public void setController(@NotNull ClientController c) { controller = c; } - public void start(Stage stage) throws Exception { + public void start(@NotNull Stage stage) throws Exception { GridPane root = new GridPane(); // name box @@ -96,7 +97,7 @@ public class GraphicalUserInterface extends Application { } - public void create(Stage stage){ + public void create(@NotNull Stage stage){ Label createLabel = new Label(); GridPane createRoot = new GridPane(); @@ -159,7 +160,7 @@ public class GraphicalUserInterface extends Application { }); } - public void compte(Stage stage){ + public void compte(@NotNull Stage stage){ Label compteLabel = new Label(); GridPane compteRoot = new GridPane(); @@ -184,7 +185,7 @@ public class GraphicalUserInterface extends Application { newWindow.show(); } - public void creerCompte(String name, String role, String password) throws InvalidClassException { + public void creerCompte(@NotNull String name, @NotNull String role, @NotNull String password) throws InvalidClassException { Client p; if (role.equals("private")){ p = new Particulier(name,role,new PrivateAddress()); @@ -197,7 +198,7 @@ public class GraphicalUserInterface extends Application { } } - public boolean connexion(String identifiant, String password) { + public boolean connexion(@NotNull String identifiant, @NotNull String password) { Client p = bank.getClient(identifiant); if (p != null) { if (controller.hasUser(p)) { -- GitLab From f065a1ade39bd21b04d4b8f52a4ab4e60e86ee99 Mon Sep 17 00:00:00 2001 From: Curtis Meda Date: Thu, 2 Apr 2020 19:55:01 +0200 Subject: [PATCH 24/35] Documentation-GraphicalUser&TextualUser --- pom.xml | 6 +++ .../ui/GraphicalUserInterface.java | 52 +++++++++++++++---- .../construction/ui/TextualUserInterface.java | 6 --- 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index 35648905..ffc8bb2b 100644 --- a/pom.xml +++ b/pom.xml @@ -90,6 +90,12 @@ RELEASE test + + org.jetbrains + annotations + 19.0.0 + compile + diff --git a/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java b/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java index d99a030d..6d067eba 100644 --- a/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java +++ b/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java @@ -1,6 +1,5 @@ package fr.unantes.software.construction.ui; -import com.sun.istack.internal.NotNull; import fr.unantes.software.construction.Bank; import fr.unantes.software.construction.Client; import fr.unantes.software.construction.Entreprise; @@ -16,6 +15,7 @@ import javafx.scene.control.TextField; import javafx.scene.layout.GridPane; import javafx.stage.Modality; import javafx.stage.Stage; +import org.jetbrains.annotations.NotNull; import java.io.InvalidClassException; @@ -29,29 +29,42 @@ public class GraphicalUserInterface extends Application { private Bank bank; private ClientController controller; + /** + * Constructor empty + */ public GraphicalUserInterface(){ bank = new Bank(); controller = new ClientController(); } /** * @uml.property name="bank" + * @return bank */ public Bank getBank() { return bank; } - public void setBank(@NotNull Bank b) { - bank = b; - } + /** + * @role set bank + * @param b + */ + public void setBank(@NotNull Bank b) { bank = b; } - public ClientController getController() { - return controller; - } + /** + * @return controller + */ + public ClientController getController() { return controller; } - public void setController(@NotNull ClientController c) { - controller = c; - } + /** + * @role set controller + * @param c + */ + public void setController(@NotNull ClientController c) { controller = c; } + /** + * @param stage + * @throws Exception + */ public void start(@NotNull Stage stage) throws Exception { GridPane root = new GridPane(); @@ -97,6 +110,9 @@ public class GraphicalUserInterface extends Application { } + /** + * @param stage + */ public void create(@NotNull Stage stage){ Label createLabel = new Label(); @@ -160,6 +176,9 @@ public class GraphicalUserInterface extends Application { }); } + /** + * @param stage + */ public void compte(@NotNull Stage stage){ Label compteLabel = new Label(); @@ -185,6 +204,13 @@ public class GraphicalUserInterface extends Application { newWindow.show(); } + /** + * @role créer un compte + * @param name + * @param role + * @param password + * @throws InvalidClassException + */ public void creerCompte(@NotNull String name, @NotNull String role, @NotNull String password) throws InvalidClassException { Client p; if (role.equals("private")){ @@ -198,6 +224,12 @@ public class GraphicalUserInterface extends Application { } } + /** + * @role etablir connexion + * @param identifiant + * @param password + * @return + */ public boolean connexion(@NotNull String identifiant, @NotNull String password) { Client p = bank.getClient(identifiant); if (p != null) { diff --git a/src/main/java/fr/unantes/software/construction/ui/TextualUserInterface.java b/src/main/java/fr/unantes/software/construction/ui/TextualUserInterface.java index c0a6fd76..143c831b 100755 --- a/src/main/java/fr/unantes/software/construction/ui/TextualUserInterface.java +++ b/src/main/java/fr/unantes/software/construction/ui/TextualUserInterface.java @@ -27,17 +27,13 @@ public class TextualUserInterface { private static final int stopCmd = -1; /** - * * @uml.property name="bank" * @uml.associationEnd inverse="display:fr.unantes.software.construction.Bank" multiplicity="(1 1)" - * */ private static Bank bank; /** - * * @uml.property name="bank" - * */ public static Bank getBank() { return bank; @@ -295,9 +291,7 @@ public class TextualUserInterface { } /** - * * @uml.property name="bank" - * */ public static void setBank(Bank bankParameter) { bank = bankParameter; -- GitLab From 1ab2110e4ca91e95591986e8f27a3186a551c4d9 Mon Sep 17 00:00:00 2001 From: Curtis Meda Date: Thu, 2 Apr 2020 20:07:47 +0200 Subject: [PATCH 25/35] Documentation general --- pom.xml | 6 ++++++ src/main/java/fr/unantes/software/construction/Account.java | 4 +++- src/main/java/fr/unantes/software/construction/Bank.java | 3 ++- src/main/java/fr/unantes/software/construction/Client.java | 3 ++- .../fr/unantes/software/construction/DepositOperation.java | 3 ++- .../java/fr/unantes/software/construction/Entreprise.java | 3 ++- .../java/fr/unantes/software/construction/Operation.java | 3 ++- .../java/fr/unantes/software/construction/Particulier.java | 3 ++- .../fr/unantes/software/construction/ReferenceUniDi.java | 4 +++- .../fr/unantes/software/construction/WithdrawOperation.java | 3 ++- .../fr/unantes/software/construction/address/Address.java | 3 ++- .../unantes/software/construction/address/AddressBook.java | 2 +- .../unantes/software/construction/address/AddressList.java | 2 +- .../java/fr/unantes/software/construction/address/Card.java | 2 +- .../fr/unantes/software/construction/address/CardList.java | 2 +- .../java/fr/unantes/software/construction/address/City.java | 2 +- .../software/construction/address/CompanyAddress.java | 3 ++- .../unantes/software/construction/address/CompanyCard.java | 2 +- .../fr/unantes/software/construction/address/Group.java | 4 ++-- .../fr/unantes/software/construction/address/GroupList.java | 2 +- .../java/fr/unantes/software/construction/address/Mail.java | 4 ++-- .../fr/unantes/software/construction/address/MailList.java | 3 ++- .../fr/unantes/software/construction/address/Phone.java | 2 +- .../fr/unantes/software/construction/address/PhoneList.java | 4 +++- .../software/construction/address/PrivateAddress.java | 2 +- .../unantes/software/construction/address/PrivateCard.java | 3 ++- .../software/construction/security/ClientController.java | 3 ++- .../fr/unantes/software/construction/security/Password.java | 3 ++- 28 files changed, 54 insertions(+), 29 deletions(-) diff --git a/pom.xml b/pom.xml index ffc8bb2b..319ed83a 100644 --- a/pom.xml +++ b/pom.xml @@ -96,6 +96,12 @@ 19.0.0 compile + + org.mockito + mockito-core + 2.23.4 + compile + diff --git a/src/main/java/fr/unantes/software/construction/Account.java b/src/main/java/fr/unantes/software/construction/Account.java index 6b265ae3..96cd5d88 100755 --- a/src/main/java/fr/unantes/software/construction/Account.java +++ b/src/main/java/fr/unantes/software/construction/Account.java @@ -1,6 +1,8 @@ package fr.unantes.software.construction; -import com.sun.istack.internal.NotNull; + + +import org.jetbrains.annotations.NotNull; import java.io.InvalidClassException; import java.time.LocalTime; diff --git a/src/main/java/fr/unantes/software/construction/Bank.java b/src/main/java/fr/unantes/software/construction/Bank.java index f9b72a6e..ce993bd0 100755 --- a/src/main/java/fr/unantes/software/construction/Bank.java +++ b/src/main/java/fr/unantes/software/construction/Bank.java @@ -1,7 +1,8 @@ package fr.unantes.software.construction; -import com.sun.istack.internal.NotNull; + import fr.unantes.software.construction.address.AddressBook; +import org.jetbrains.annotations.NotNull; import java.io.InvalidClassException; import java.util.Iterator; diff --git a/src/main/java/fr/unantes/software/construction/Client.java b/src/main/java/fr/unantes/software/construction/Client.java index 1ca4f9e3..04f25c5a 100644 --- a/src/main/java/fr/unantes/software/construction/Client.java +++ b/src/main/java/fr/unantes/software/construction/Client.java @@ -1,8 +1,9 @@ package fr.unantes.software.construction; -import com.sun.istack.internal.NotNull; + import fr.unantes.software.construction.address.Address; import fr.unantes.software.construction.address.Card; +import org.jetbrains.annotations.NotNull; import java.io.InvalidClassException; import java.util.ArrayList; diff --git a/src/main/java/fr/unantes/software/construction/DepositOperation.java b/src/main/java/fr/unantes/software/construction/DepositOperation.java index 05802852..2107d27d 100755 --- a/src/main/java/fr/unantes/software/construction/DepositOperation.java +++ b/src/main/java/fr/unantes/software/construction/DepositOperation.java @@ -1,7 +1,8 @@ package fr.unantes.software.construction; -import com.sun.istack.internal.NotNull; + +import org.jetbrains.annotations.NotNull; import java.time.LocalTime; diff --git a/src/main/java/fr/unantes/software/construction/Entreprise.java b/src/main/java/fr/unantes/software/construction/Entreprise.java index 436bdd51..34301c17 100644 --- a/src/main/java/fr/unantes/software/construction/Entreprise.java +++ b/src/main/java/fr/unantes/software/construction/Entreprise.java @@ -1,9 +1,10 @@ package fr.unantes.software.construction; -import com.sun.istack.internal.NotNull; + import fr.unantes.software.construction.address.Card; import fr.unantes.software.construction.address.CompanyAddress; import fr.unantes.software.construction.address.CompanyCard; +import org.jetbrains.annotations.NotNull; import java.io.InvalidClassException; diff --git a/src/main/java/fr/unantes/software/construction/Operation.java b/src/main/java/fr/unantes/software/construction/Operation.java index 95ea1bb9..12e3a677 100755 --- a/src/main/java/fr/unantes/software/construction/Operation.java +++ b/src/main/java/fr/unantes/software/construction/Operation.java @@ -1,6 +1,7 @@ package fr.unantes.software.construction; -import com.sun.istack.internal.NotNull; + +import org.jetbrains.annotations.NotNull; import java.time.*; diff --git a/src/main/java/fr/unantes/software/construction/Particulier.java b/src/main/java/fr/unantes/software/construction/Particulier.java index bab2dec5..77622e2d 100644 --- a/src/main/java/fr/unantes/software/construction/Particulier.java +++ b/src/main/java/fr/unantes/software/construction/Particulier.java @@ -1,9 +1,10 @@ package fr.unantes.software.construction; -import com.sun.istack.internal.NotNull; + import fr.unantes.software.construction.address.Card; import fr.unantes.software.construction.address.PrivateAddress; import fr.unantes.software.construction.address.PrivateCard; +import org.jetbrains.annotations.NotNull; import java.io.InvalidClassException; diff --git a/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java b/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java index faf81731..9c225ea3 100644 --- a/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java +++ b/src/main/java/fr/unantes/software/construction/ReferenceUniDi.java @@ -1,6 +1,8 @@ package fr.unantes.software.construction; -import com.sun.istack.internal.NotNull; + + +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Iterator; diff --git a/src/main/java/fr/unantes/software/construction/WithdrawOperation.java b/src/main/java/fr/unantes/software/construction/WithdrawOperation.java index 25ec412c..0349f9da 100755 --- a/src/main/java/fr/unantes/software/construction/WithdrawOperation.java +++ b/src/main/java/fr/unantes/software/construction/WithdrawOperation.java @@ -1,7 +1,8 @@ package fr.unantes.software.construction; -import com.sun.istack.internal.NotNull; + +import org.jetbrains.annotations.NotNull; import java.time.LocalTime; diff --git a/src/main/java/fr/unantes/software/construction/address/Address.java b/src/main/java/fr/unantes/software/construction/address/Address.java index 19e12798..9cf99ac5 100755 --- a/src/main/java/fr/unantes/software/construction/address/Address.java +++ b/src/main/java/fr/unantes/software/construction/address/Address.java @@ -1,6 +1,7 @@ package fr.unantes.software.construction.address; -import com.sun.istack.internal.NotNull; + +import org.jetbrains.annotations.NotNull; /** * @author diff --git a/src/main/java/fr/unantes/software/construction/address/AddressBook.java b/src/main/java/fr/unantes/software/construction/address/AddressBook.java index cfc714b3..0e04291e 100755 --- a/src/main/java/fr/unantes/software/construction/address/AddressBook.java +++ b/src/main/java/fr/unantes/software/construction/address/AddressBook.java @@ -1,6 +1,6 @@ package fr.unantes.software.construction.address; -import com.sun.istack.internal.NotNull; +import org.jetbrains.annotations.NotNull; /** * @author diff --git a/src/main/java/fr/unantes/software/construction/address/AddressList.java b/src/main/java/fr/unantes/software/construction/address/AddressList.java index 3181e903..338dd9fc 100755 --- a/src/main/java/fr/unantes/software/construction/address/AddressList.java +++ b/src/main/java/fr/unantes/software/construction/address/AddressList.java @@ -6,7 +6,7 @@ package fr.unantes.software.construction.address; * @date 17/12/2004. */ -import com.sun.istack.internal.NotNull; +import org.jetbrains.annotations.NotNull; import java.util.*; diff --git a/src/main/java/fr/unantes/software/construction/address/Card.java b/src/main/java/fr/unantes/software/construction/address/Card.java index 96eeca7f..5838c753 100755 --- a/src/main/java/fr/unantes/software/construction/address/Card.java +++ b/src/main/java/fr/unantes/software/construction/address/Card.java @@ -1,7 +1,7 @@ package fr.unantes.software.construction.address; -import com.sun.istack.internal.NotNull; import fr.unantes.software.construction.Client; +import org.jetbrains.annotations.NotNull; /** * @author diff --git a/src/main/java/fr/unantes/software/construction/address/CardList.java b/src/main/java/fr/unantes/software/construction/address/CardList.java index b2a9d08d..f0a3629b 100755 --- a/src/main/java/fr/unantes/software/construction/address/CardList.java +++ b/src/main/java/fr/unantes/software/construction/address/CardList.java @@ -1,6 +1,6 @@ package fr.unantes.software.construction.address; -import com.sun.istack.internal.NotNull; +import org.jetbrains.annotations.NotNull; import java.util.*; diff --git a/src/main/java/fr/unantes/software/construction/address/City.java b/src/main/java/fr/unantes/software/construction/address/City.java index c9ee5607..018cf47f 100644 --- a/src/main/java/fr/unantes/software/construction/address/City.java +++ b/src/main/java/fr/unantes/software/construction/address/City.java @@ -1,6 +1,6 @@ package fr.unantes.software.construction.address; -import com.sun.istack.internal.NotNull; +import org.jetbrains.annotations.NotNull; /** * A city diff --git a/src/main/java/fr/unantes/software/construction/address/CompanyAddress.java b/src/main/java/fr/unantes/software/construction/address/CompanyAddress.java index 3342fbde..30498e19 100755 --- a/src/main/java/fr/unantes/software/construction/address/CompanyAddress.java +++ b/src/main/java/fr/unantes/software/construction/address/CompanyAddress.java @@ -1,6 +1,7 @@ package fr.unantes.software.construction.address; -import com.sun.istack.internal.NotNull; + +import org.jetbrains.annotations.NotNull; /** * Cette Classe permet de fabriquer un objet Adresse. diff --git a/src/main/java/fr/unantes/software/construction/address/CompanyCard.java b/src/main/java/fr/unantes/software/construction/address/CompanyCard.java index 02ed7f49..a6880acf 100755 --- a/src/main/java/fr/unantes/software/construction/address/CompanyCard.java +++ b/src/main/java/fr/unantes/software/construction/address/CompanyCard.java @@ -1,8 +1,8 @@ package fr.unantes.software.construction.address; -import com.sun.istack.internal.NotNull; import fr.unantes.software.construction.Client; import fr.unantes.software.construction.Entreprise; +import org.jetbrains.annotations.NotNull; public class CompanyCard extends Card { diff --git a/src/main/java/fr/unantes/software/construction/address/Group.java b/src/main/java/fr/unantes/software/construction/address/Group.java index 931b5352..c2562bfe 100755 --- a/src/main/java/fr/unantes/software/construction/address/Group.java +++ b/src/main/java/fr/unantes/software/construction/address/Group.java @@ -1,6 +1,6 @@ package fr.unantes.software.construction.address; -import com.sun.istack.internal.NotNull; +import org.jetbrains.annotations.NotNull; /** * @@ -26,7 +26,7 @@ public class Group { * @param grp le nom du groupe * @param comGrp commentaire sur le groupe */ - public Group(@NotNull String grp,@NotNull String comGrp) { + public Group(@NotNull String grp, @NotNull String comGrp) { _grp = grp; _comGrp = comGrp; } diff --git a/src/main/java/fr/unantes/software/construction/address/GroupList.java b/src/main/java/fr/unantes/software/construction/address/GroupList.java index 19f0c14e..07b9566b 100755 --- a/src/main/java/fr/unantes/software/construction/address/GroupList.java +++ b/src/main/java/fr/unantes/software/construction/address/GroupList.java @@ -1,6 +1,6 @@ package fr.unantes.software.construction.address; -import com.sun.istack.internal.NotNull; +import org.jetbrains.annotations.NotNull; import java.util.*; diff --git a/src/main/java/fr/unantes/software/construction/address/Mail.java b/src/main/java/fr/unantes/software/construction/address/Mail.java index c81e7e29..ab493a77 100755 --- a/src/main/java/fr/unantes/software/construction/address/Mail.java +++ b/src/main/java/fr/unantes/software/construction/address/Mail.java @@ -1,6 +1,6 @@ package fr.unantes.software.construction.address; -import com.sun.istack.internal.NotNull; +import org.jetbrains.annotations.NotNull; public class Mail { @@ -14,7 +14,7 @@ public class Mail { * @param mail * @param com */ - public Mail(@NotNull String mail,@NotNull String com) { + public Mail(@NotNull String mail, @NotNull String com) { home = mail; work = com; } diff --git a/src/main/java/fr/unantes/software/construction/address/MailList.java b/src/main/java/fr/unantes/software/construction/address/MailList.java index d2984e75..5fd33ddf 100755 --- a/src/main/java/fr/unantes/software/construction/address/MailList.java +++ b/src/main/java/fr/unantes/software/construction/address/MailList.java @@ -7,7 +7,8 @@ package fr.unantes.software.construction.address; * @date 17/12/2004. */ -import com.sun.istack.internal.NotNull; + +import org.jetbrains.annotations.NotNull; import java.util.*; diff --git a/src/main/java/fr/unantes/software/construction/address/Phone.java b/src/main/java/fr/unantes/software/construction/address/Phone.java index f23580d8..fe6152b6 100755 --- a/src/main/java/fr/unantes/software/construction/address/Phone.java +++ b/src/main/java/fr/unantes/software/construction/address/Phone.java @@ -1,6 +1,6 @@ package fr.unantes.software.construction.address; -import com.sun.istack.internal.NotNull; +import org.jetbrains.annotations.NotNull; /** * @author diff --git a/src/main/java/fr/unantes/software/construction/address/PhoneList.java b/src/main/java/fr/unantes/software/construction/address/PhoneList.java index eec1f9b3..556238b3 100755 --- a/src/main/java/fr/unantes/software/construction/address/PhoneList.java +++ b/src/main/java/fr/unantes/software/construction/address/PhoneList.java @@ -1,6 +1,8 @@ package fr.unantes.software.construction.address; -import com.sun.istack.internal.NotNull; + + +import org.jetbrains.annotations.NotNull; import java.util.*; diff --git a/src/main/java/fr/unantes/software/construction/address/PrivateAddress.java b/src/main/java/fr/unantes/software/construction/address/PrivateAddress.java index c3f8015d..1b937cf6 100755 --- a/src/main/java/fr/unantes/software/construction/address/PrivateAddress.java +++ b/src/main/java/fr/unantes/software/construction/address/PrivateAddress.java @@ -1,6 +1,6 @@ package fr.unantes.software.construction.address; -import com.sun.istack.internal.NotNull; +import org.jetbrains.annotations.NotNull; /** * @author diff --git a/src/main/java/fr/unantes/software/construction/address/PrivateCard.java b/src/main/java/fr/unantes/software/construction/address/PrivateCard.java index 95e5c1b0..71321bd1 100755 --- a/src/main/java/fr/unantes/software/construction/address/PrivateCard.java +++ b/src/main/java/fr/unantes/software/construction/address/PrivateCard.java @@ -1,8 +1,9 @@ package fr.unantes.software.construction.address; -import com.sun.istack.internal.NotNull; + import fr.unantes.software.construction.Client; import fr.unantes.software.construction.Particulier; +import org.jetbrains.annotations.NotNull; /** * @author diff --git a/src/main/java/fr/unantes/software/construction/security/ClientController.java b/src/main/java/fr/unantes/software/construction/security/ClientController.java index 23e6f887..7d641230 100644 --- a/src/main/java/fr/unantes/software/construction/security/ClientController.java +++ b/src/main/java/fr/unantes/software/construction/security/ClientController.java @@ -1,7 +1,8 @@ package fr.unantes.software.construction.security; -import com.sun.istack.internal.NotNull; + import fr.unantes.software.construction.Client; +import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/fr/unantes/software/construction/security/Password.java b/src/main/java/fr/unantes/software/construction/security/Password.java index 55fa20b0..310c2748 100644 --- a/src/main/java/fr/unantes/software/construction/security/Password.java +++ b/src/main/java/fr/unantes/software/construction/security/Password.java @@ -1,6 +1,7 @@ package fr.unantes.software.construction.security; -import com.sun.istack.internal.NotNull; + +import org.jetbrains.annotations.NotNull; import java.security.spec.KeySpec; import java.util.Base64; -- GitLab From f81484d0cde1923b9c57ff89a466f87c9616033d Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Thu, 2 Apr 2020 21:03:25 +0200 Subject: [PATCH 26/35] encapsulation --- .../unantes/software/construction/Bank.java | 35 ++++++++++++++++--- .../software/construction/Operation.java | 12 +++++-- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/main/java/fr/unantes/software/construction/Bank.java b/src/main/java/fr/unantes/software/construction/Bank.java index ce993bd0..4a2f456e 100755 --- a/src/main/java/fr/unantes/software/construction/Bank.java +++ b/src/main/java/fr/unantes/software/construction/Bank.java @@ -53,7 +53,10 @@ public class Bank { * @role set le numero de compte * @uml.property name="accountNumbers" */ - public void setAccountNumbers(int accountNumbers) { + public void setAccountNumbers(@NotNull int accountNumbers) throws IllegalAccessException { + if(accountNumbers < 0){ + throw new IllegalAccessException("accountNumbers < 0"); + } this.accountNumbers = accountNumbers; } @@ -62,7 +65,13 @@ public class Bank { * If no client has this name, a new client object is created and is added to the list of clients, then the account is created * If the client exists the account is created, added to the bank's and the client's list of accounts */ - public int addAccount(String name, float amount, float overdraft, String type) { + public int addAccount(@NotNull String name,@NotNull float amount, @NotNull float overdraft, @NotNull String type) throws IllegalAccessException { + if(amount < 0-overdraft){ + throw new IllegalAccessException("amount < 0-overdraft"); + } + if(overdraft < 0){ + throw new IllegalAccessException("overdraft < 0"); + } Client p = getClient(name); //if a client named name already exists in the bank's set of clients if (p!=null){ @@ -83,7 +92,10 @@ public class Bank { * If the account exists, it is removed form the bank's list of accounts and from the owner's list of accounts. * If the account does not exist, an Exception is thrown. */ - public void closeAccount(int accountNumber) throws Exception { + public void closeAccount(@NotNull int accountNumber) throws Exception { + if(accountNumbers < 0){ + throw new IllegalAccessException("accountNumbers < 0"); + } Account a=getAccount(accountNumber); if (a!=null){ Account.ClientReference tmp = a.getClients(); @@ -147,7 +159,10 @@ public class Bank { * Returns null if no account has the number accountNumber * The assumption is that there cannot be several accounts with the same number */ - public Account getAccount(@NotNull int accountNumber) { + public Account getAccount(@NotNull int accountNumber) throws IllegalAccessException { + if(accountNumbers < 0){ + throw new IllegalAccessException("accountNumbers < 0"); + } Iterator it = this.accounts.iterator(); while (it.hasNext()){ Account a = (Account)it.next(); @@ -164,6 +179,12 @@ public class Bank { * Throws an exception if there is no account number accountNumber */ public void deposit(@NotNull int accountNumber, @NotNull float amount) throws Exception { + if(accountNumbers < 0){ + throw new IllegalAccessException("accountNumbers < 0"); + } + if(amount < 0){ + throw new IllegalAccessException("amount < 0"); + } Account a = getAccount(accountNumber); if (a!=null){ a.deposit(amount); @@ -179,6 +200,12 @@ public class Bank { * Throws an exception if there is no account number accountNumber */ public void withdraw(@NotNull int accountNumber, @NotNull float amount) throws Exception { + if(accountNumbers < 0){ + throw new IllegalAccessException("accountNumbers < 0"); + } + if(amount < 0){ + throw new IllegalAccessException("amount < 0"); + } Account a = getAccount(accountNumber); if (a!=null){ a.withdraw(amount); diff --git a/src/main/java/fr/unantes/software/construction/Operation.java b/src/main/java/fr/unantes/software/construction/Operation.java index 12e3a677..f1f23886 100755 --- a/src/main/java/fr/unantes/software/construction/Operation.java +++ b/src/main/java/fr/unantes/software/construction/Operation.java @@ -35,13 +35,21 @@ public abstract class Operation { * @role set amount * @uml.property name="amount" */ - public void setAmount(@NotNull float amount) { this.amount = amount; } + public void setAmount(@NotNull float amount) throws IllegalAccessException { + if(amount < 0){ + throw new IllegalAccessException("amount < 0"); + } + this.amount = amount; + } /** * @param amount * @param i */ - public Operation(@NotNull float amount, @NotNull LocalTime i) { + public Operation(@NotNull float amount, @NotNull LocalTime i) throws IllegalAccessException { + if(amount < 0){ + throw new IllegalAccessException("amount < 0"); + } this.amount = amount; this.time = i; account = new AccountReference(); -- GitLab From ca4635dd2cf94a4b5e9cbef4ae9d6b2d864ce0dc Mon Sep 17 00:00:00 2001 From: Curtis Meda Date: Fri, 3 Apr 2020 00:33:33 +0200 Subject: [PATCH 27/35] documentation-interface-test --- .../software/construction/AccountTest.java | 19 ++- .../AccountOperationTest.java | 2 +- .../construction/ui/GraphiqueUiTest.java | 19 +-- .../software/construction/Account.java | 2 +- .../unantes/software/construction/Client.java | 6 +- .../construction/DepositOperation.java | 2 +- .../construction/WithdrawOperation.java | 2 +- .../ui/GraphicalUserInterface.java | 116 +++++++++++++++++- .../construction/ui/TextualUserInterface.java | 10 +- 9 files changed, 152 insertions(+), 26 deletions(-) diff --git a/src/Test/java/fr/unantes/software/construction/AccountTest.java b/src/Test/java/fr/unantes/software/construction/AccountTest.java index 66b89fcc..095cfbde 100644 --- a/src/Test/java/fr/unantes/software/construction/AccountTest.java +++ b/src/Test/java/fr/unantes/software/construction/AccountTest.java @@ -1,9 +1,26 @@ package fr.unantes.software.construction; -import static org.junit.Assert.assertEquals; +import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + public class AccountTest { private Account account; + @Test + public void depositTest() throws IllegalAccessException { + account.setBalance(500); + account.deposit(100); + assertEquals(600,account.getBalance()); + } + + + @Test + public void withdrawTest() throws Exception { + account.setBalance(300); + account.withdraw(100); + assertEquals(200,account.getBalance()); + } } diff --git a/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountOperationTest.java b/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountOperationTest.java index 5a6fa73e..1c934ad2 100644 --- a/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountOperationTest.java +++ b/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountOperationTest.java @@ -38,7 +38,7 @@ public class AccountOperationTest { } @Before - public void initBeforeTest() throws InvalidClassException { + public void initBeforeTest() throws InvalidClassException, IllegalAccessException { account = new Account(new Particulier("test","private", new PrivateAddress()),1,1,1,"private"); operation1 = new DepositOperation(0,LocalTime.now()); operation2 = new WithdrawOperation(10, LocalTime.now()); diff --git a/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java b/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java index ad6aca82..9edf5845 100644 --- a/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java +++ b/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java @@ -1,17 +1,12 @@ package fr.unantes.software.construction.ui; -import fr.unantes.software.construction.Account; -import fr.unantes.software.construction.Bank; -import fr.unantes.software.construction.Entreprise; -import fr.unantes.software.construction.Particulier; -import fr.unantes.software.construction.address.CompanyAddress; -import fr.unantes.software.construction.address.PrivateAddress; import org.junit.Before; import org.junit.Test; import java.io.InvalidClassException; -import static org.junit.Assert.*; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class GraphiqueUiTest { GraphicalUserInterface graph; @@ -32,4 +27,14 @@ public class GraphiqueUiTest { graph.creerCompte("Jean Pierre","private","JeanP"); graph.creerCompte("JeanCorporation","company","JeanC"); } + + @SuppressWarnings("static-access") + @Test + public void VirementTest() throws Exception { + graph.getBank().addAccount("Jean Michel",500,100,"private"); + graph.getBank().addAccount("Jean Pierre",200,100,"private"); + graph.virement("Jean Michel", 100, "Jean Pierre"); + assertTrue(0 == graph.getBank().getAccountsOfClient("Jean Michel")[0].getBalance()); + assertTrue(300 == graph.getBank().getAccountsOfClient("Jean Pierre")[0].getBalance()); + } } diff --git a/src/main/java/fr/unantes/software/construction/Account.java b/src/main/java/fr/unantes/software/construction/Account.java index 96cd5d88..c55b52d1 100755 --- a/src/main/java/fr/unantes/software/construction/Account.java +++ b/src/main/java/fr/unantes/software/construction/Account.java @@ -81,7 +81,7 @@ public class Account { * Adds the amount to the current balance * Adds this operation in the history */ - public void deposit(@NotNull float amount) { + public void deposit(@NotNull float amount) throws IllegalAccessException { if (amount < 0){ throw new IllegalArgumentException("The amount cannot be negative"); } diff --git a/src/main/java/fr/unantes/software/construction/Client.java b/src/main/java/fr/unantes/software/construction/Client.java index 04f25c5a..c41e560f 100644 --- a/src/main/java/fr/unantes/software/construction/Client.java +++ b/src/main/java/fr/unantes/software/construction/Client.java @@ -1,15 +1,11 @@ package fr.unantes.software.construction; -import fr.unantes.software.construction.address.Address; import fr.unantes.software.construction.address.Card; import org.jetbrains.annotations.NotNull; import java.io.InvalidClassException; import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.Vector; public abstract class Client { @@ -113,6 +109,8 @@ public abstract class Client { public void basicRemove(@NotNull Account a) { account.remove(a); } + + public Account getAccount(int i){ return account.get(i); } } /** diff --git a/src/main/java/fr/unantes/software/construction/DepositOperation.java b/src/main/java/fr/unantes/software/construction/DepositOperation.java index 2107d27d..56aa46b7 100755 --- a/src/main/java/fr/unantes/software/construction/DepositOperation.java +++ b/src/main/java/fr/unantes/software/construction/DepositOperation.java @@ -12,7 +12,7 @@ public class DepositOperation extends Operation { * @param amount * @param i */ - public DepositOperation(@NotNull float amount, @NotNull LocalTime i) { super(amount, i); } + public DepositOperation(@NotNull float amount, @NotNull LocalTime i) throws IllegalAccessException { super(amount, i); } /** * @return Deposit diff --git a/src/main/java/fr/unantes/software/construction/WithdrawOperation.java b/src/main/java/fr/unantes/software/construction/WithdrawOperation.java index 0349f9da..08ff2a7f 100755 --- a/src/main/java/fr/unantes/software/construction/WithdrawOperation.java +++ b/src/main/java/fr/unantes/software/construction/WithdrawOperation.java @@ -12,7 +12,7 @@ public class WithdrawOperation extends Operation { * @param amount * @param i */ - public WithdrawOperation(@NotNull float amount, @NotNull LocalTime i) { super(amount, i); } + public WithdrawOperation(@NotNull float amount, @NotNull LocalTime i) throws IllegalAccessException { super(amount, i); } /** * @return withdraw diff --git a/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java b/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java index 6d067eba..4671cba2 100644 --- a/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java +++ b/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java @@ -1,9 +1,6 @@ package fr.unantes.software.construction.ui; -import fr.unantes.software.construction.Bank; -import fr.unantes.software.construction.Client; -import fr.unantes.software.construction.Entreprise; -import fr.unantes.software.construction.Particulier; +import fr.unantes.software.construction.*; import fr.unantes.software.construction.address.CompanyAddress; import fr.unantes.software.construction.address.PrivateAddress; import fr.unantes.software.construction.security.ClientController; @@ -62,6 +59,7 @@ public class GraphicalUserInterface extends Application { public void setController(@NotNull ClientController c) { controller = c; } /** + * @role lancement * @param stage * @throws Exception */ @@ -111,6 +109,7 @@ public class GraphicalUserInterface extends Application { } /** + * @role interface graphique * @param stage */ public void create(@NotNull Stage stage){ @@ -119,7 +118,6 @@ public class GraphicalUserInterface extends Application { GridPane createRoot = new GridPane(); createRoot.getChildren().add(createLabel); - // name box TextField nameField = new TextField(); Label name = new Label("Name:"); @@ -177,6 +175,7 @@ public class GraphicalUserInterface extends Application { } /** + * @role interface graphique * @param stage */ public void compte(@NotNull Stage stage){ @@ -192,6 +191,17 @@ public class GraphicalUserInterface extends Application { newWindow.setTitle("Compte"); newWindow.setScene(compteScene); + // partie virement + Button virementButton = new Button(); + virementButton.setText("Effectuer un virement"); + + compteRoot.add(virementButton, 0, 2); + + virementButton.setOnAction(event -> { + interfaceVirement(stage); + }); + + // Specifies the modality for new window. newWindow.initModality(Modality.WINDOW_MODAL); @@ -202,6 +212,101 @@ public class GraphicalUserInterface extends Application { newWindow.setX(stage.getX()); newWindow.setY(stage.getY()); newWindow.show(); + + //deconnexion + Button decoButton = new Button(); + decoButton.setText("Deconnexion"); + + compteRoot.add(decoButton, 0, 4); + + decoButton.setOnAction(event -> { + newWindow.close(); + }); + } + + /** + * @role inferface graphique + * @param stage + */ + public void interfaceVirement(@NotNull Stage stage){ + Label virementLabel = new Label(); + + GridPane virementRoot = new GridPane(); + virementRoot.getChildren().add(virementLabel); + + Scene virementScene = new Scene(virementRoot, 500, 100); + + // New window (Stage) + Stage newWindow = new Stage(); + newWindow.setTitle("Virement"); + newWindow.setScene(virementScene); + + // confrimation box + TextField field1 = new TextField(); + Label lbl1 = new Label("confirmation de votre identifiant"); + lbl1.setLabelFor(field1); + + virementRoot.add(lbl1, 0, 0); + virementRoot.add(field1, 1, 0); + + // montant box + TextField field2 = new TextField(); + Label lbl2 = new Label("Montant du virement"); + lbl2.setLabelFor(field2); + + virementRoot.add(lbl2, 0, 1); + virementRoot.add(field2, 1, 1); + + // destinataire box + TextField field3 = new TextField(); + Label lbl3 = new Label("Destinataire"); + lbl3.setLabelFor(field3); + + virementRoot.add(lbl3, 0, 2); + virementRoot.add(field3, 1, 2); + + // Valide button + Button valideButton = new Button(); + valideButton.setText("Valide"); + + virementRoot.add(valideButton, 0, 6); + + + // Specifies the modality for new window. + newWindow.initModality(Modality.WINDOW_MODAL); + + // Specifies the owner Window (parent) for new window + newWindow.initOwner(stage); + + // Set position of second window, related to primary window. + newWindow.setX(stage.getX()); + newWindow.setY(stage.getY()); + newWindow.show(); + + valideButton.setOnAction(event -> { + float c = Integer.parseInt(field2.getText()); + try { + virement(field1.getText(), c, field3.getText()); + } catch (Exception e) { + e.printStackTrace(); + } + newWindow.close(); + }); + + } + + /** + @Role effectue le virement entre les deux comptes + * @param identifiant + * @param amount + * @param dest + * @throws Exception + */ + public void virement (@NotNull String identifiant, @NotNull float amount, @NotNull String dest) throws Exception { + Account p = bank.getClient(identifiant).getAccounts().getAccount(0); + Account d = bank.getClient(dest).getAccounts().getAccount(0); + p.withdraw(amount); + d.deposit(amount); } /** @@ -224,6 +329,7 @@ public class GraphicalUserInterface extends Application { } } + /** * @role etablir connexion * @param identifiant diff --git a/src/main/java/fr/unantes/software/construction/ui/TextualUserInterface.java b/src/main/java/fr/unantes/software/construction/ui/TextualUserInterface.java index 143c831b..7e97a8a9 100755 --- a/src/main/java/fr/unantes/software/construction/ui/TextualUserInterface.java +++ b/src/main/java/fr/unantes/software/construction/ui/TextualUserInterface.java @@ -43,7 +43,7 @@ public class TextualUserInterface { * Processes the create account operation * Messages ask for the name of the owner, the initial balance and overdraft */ - public static void createAccount(){ + public static void createAccount() throws IllegalAccessException { System.out.println("Name of the owner"); String name = readLine(); System.out.println("Initial balance"); @@ -112,7 +112,7 @@ public class TextualUserInterface { * Displays the balance for an account. * A message asks for the number of the account. */ - public static void balance(){ + public static void balance() throws IllegalAccessException { System.out.println("Number of the account for balance"); int number = readInt(); Account acc = bank.getAccount(number); @@ -129,7 +129,7 @@ public class TextualUserInterface { * A message asks for the number of the account. * If the account with this number does not exist, an error message is displayed */ - public static void history(){ + public static void history() throws IllegalAccessException { System.out.println("Number of the account for history"); int number = readInt(); Account acc = bank.getAccount(number); @@ -260,7 +260,7 @@ public class TextualUserInterface { /** * displays the menu and processes the command while the user doesn't ask for stop */ - public static void main(String[] args) { + public static void main(String[] args) throws IllegalAccessException { menu(); int cmd = readInt(); @@ -275,7 +275,7 @@ public class TextualUserInterface { /** * Processes the command with the number command */ - public static void process(int command){ + public static void process(int command) throws IllegalAccessException { switch(command){ case createCmd : createAccount(); case closeCmd : closeAccount(); -- GitLab From cfc05aeb2a6fe6830ecdfa155849013f279b0a8c Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Fri, 3 Apr 2020 01:07:34 +0200 Subject: [PATCH 28/35] test --- .../unantes/software/construction/ui/GraphiqueUiTest.java | 6 ------ src/main/java/fr/unantes/software/construction/Account.java | 2 -- 2 files changed, 8 deletions(-) diff --git a/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java b/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java index ad6aca82..987c693f 100644 --- a/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java +++ b/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java @@ -1,11 +1,5 @@ package fr.unantes.software.construction.ui; -import fr.unantes.software.construction.Account; -import fr.unantes.software.construction.Bank; -import fr.unantes.software.construction.Entreprise; -import fr.unantes.software.construction.Particulier; -import fr.unantes.software.construction.address.CompanyAddress; -import fr.unantes.software.construction.address.PrivateAddress; import org.junit.Before; import org.junit.Test; diff --git a/src/main/java/fr/unantes/software/construction/Account.java b/src/main/java/fr/unantes/software/construction/Account.java index 96cd5d88..13941bfd 100755 --- a/src/main/java/fr/unantes/software/construction/Account.java +++ b/src/main/java/fr/unantes/software/construction/Account.java @@ -1,7 +1,5 @@ package fr.unantes.software.construction; - - import org.jetbrains.annotations.NotNull; import java.io.InvalidClassException; -- GitLab From ac4d5902e3af3ac88650f9b47faf33fb9a13d090 Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Fri, 3 Apr 2020 01:36:14 +0200 Subject: [PATCH 29/35] Graphique test + ajout compte --- .../software/construction/AccountTest.java | 6 +- .../construction/ui/GraphiqueUiTest.java | 24 ++-- .../software/construction/Account.java | 2 +- .../unantes/software/construction/Client.java | 2 +- .../ui/GraphicalUserInterface.java | 108 ++++++++++++++++-- 5 files changed, 112 insertions(+), 30 deletions(-) diff --git a/src/Test/java/fr/unantes/software/construction/AccountTest.java b/src/Test/java/fr/unantes/software/construction/AccountTest.java index 095cfbde..c4656de7 100644 --- a/src/Test/java/fr/unantes/software/construction/AccountTest.java +++ b/src/Test/java/fr/unantes/software/construction/AccountTest.java @@ -2,7 +2,7 @@ package fr.unantes.software.construction; import org.junit.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.Assert.*; public class AccountTest { @@ -12,7 +12,7 @@ public class AccountTest { public void depositTest() throws IllegalAccessException { account.setBalance(500); account.deposit(100); - assertEquals(600,account.getBalance()); + assertTrue(600 == account.getBalance()); } @@ -20,7 +20,7 @@ public class AccountTest { public void withdrawTest() throws Exception { account.setBalance(300); account.withdraw(100); - assertEquals(200,account.getBalance()); + assertTrue(200 == account.getBalance()); } } diff --git a/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java b/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java index 9edf5845..8cd67d8c 100644 --- a/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java +++ b/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java @@ -3,8 +3,6 @@ package fr.unantes.software.construction.ui; import org.junit.Before; import org.junit.Test; -import java.io.InvalidClassException; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -20,21 +18,21 @@ public class GraphiqueUiTest { assertFalse(graph.connexion("Jean Michel","JeanP")); } - @Before - public void initBeforeTest() throws InvalidClassException { - graph = new GraphicalUserInterface(); - graph.creerCompte("Jean Michel","private","JeanM"); - graph.creerCompte("Jean Pierre","private","JeanP"); - graph.creerCompte("JeanCorporation","company","JeanC"); - } - @SuppressWarnings("static-access") @Test public void VirementTest() throws Exception { - graph.getBank().addAccount("Jean Michel",500,100,"private"); - graph.getBank().addAccount("Jean Pierre",200,100,"private"); graph.virement("Jean Michel", 100, "Jean Pierre"); assertTrue(0 == graph.getBank().getAccountsOfClient("Jean Michel")[0].getBalance()); - assertTrue(300 == graph.getBank().getAccountsOfClient("Jean Pierre")[0].getBalance()); + assertTrue(200 == graph.getBank().getAccountsOfClient("Jean Pierre")[0].getBalance()); + } + + @Before + public void initBeforeTest() throws Exception { + graph = new GraphicalUserInterface(); + graph.creerCompte("Jean Michel","private","JeanM"); + graph.creerCompte("Jean Pierre","private","JeanP"); + graph.creerCompte("JeanCorporation","company","JeanC"); + graph.ajoutCompte("Jean Michel",100,100); + graph.ajoutCompte("Jean Pierre",100,100); } } diff --git a/src/main/java/fr/unantes/software/construction/Account.java b/src/main/java/fr/unantes/software/construction/Account.java index 6b9c6e49..a9fa2cc4 100755 --- a/src/main/java/fr/unantes/software/construction/Account.java +++ b/src/main/java/fr/unantes/software/construction/Account.java @@ -97,7 +97,7 @@ public class Account { */ public void withdraw(@NotNull float amount) throws Exception { float newBalance = balance - amount; - if (newBalance > 0){ + if (newBalance >= 0){ balance = newBalance; Operation o = new WithdrawOperation(amount, LocalTime.now()); addHistory(o); diff --git a/src/main/java/fr/unantes/software/construction/Client.java b/src/main/java/fr/unantes/software/construction/Client.java index c41e560f..ca2abfe0 100644 --- a/src/main/java/fr/unantes/software/construction/Client.java +++ b/src/main/java/fr/unantes/software/construction/Client.java @@ -178,7 +178,7 @@ public abstract class Client { } public Account[] accountsToArray(){ - return (Account[]) account.account.toArray(); + return account.account.toArray(new Account[0]); } /** diff --git a/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java b/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java index 4671cba2..1ada883a 100644 --- a/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java +++ b/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java @@ -86,7 +86,7 @@ public class GraphicalUserInterface extends Application { loginButton.setOnAction(event -> { if(connexion(field1.getText(),field2.getText())){ - compte(stage); + compte(stage, field1.getText()); } }); @@ -178,7 +178,7 @@ public class GraphicalUserInterface extends Application { * @role interface graphique * @param stage */ - public void compte(@NotNull Stage stage){ + public void compte(@NotNull Stage stage, @NotNull String id){ Label compteLabel = new Label(); GridPane compteRoot = new GridPane(); @@ -191,6 +191,17 @@ public class GraphicalUserInterface extends Application { newWindow.setTitle("Compte"); newWindow.setScene(compteScene); + + // partie ajouter compte + Button ajoutButton = new Button(); + ajoutButton.setText("Nouveau compte"); + + compteRoot.add(ajoutButton, 0, 1); + + ajoutButton.setOnAction(event -> { + interfaceAjout(stage,id); + }); + // partie virement Button virementButton = new Button(); virementButton.setText("Effectuer un virement"); @@ -296,17 +307,65 @@ public class GraphicalUserInterface extends Application { } /** - @Role effectue le virement entre les deux comptes - * @param identifiant - * @param amount - * @param dest - * @throws Exception + * @role inferface graphique + * @param stage */ - public void virement (@NotNull String identifiant, @NotNull float amount, @NotNull String dest) throws Exception { - Account p = bank.getClient(identifiant).getAccounts().getAccount(0); - Account d = bank.getClient(dest).getAccounts().getAccount(0); - p.withdraw(amount); - d.deposit(amount); + public void interfaceAjout(@NotNull Stage stage, @NotNull String id){ + Label ajoutLabel = new Label(); + + GridPane ajoutRoot = new GridPane(); + ajoutRoot.getChildren().add(ajoutLabel); + + Scene ajoutScene = new Scene(ajoutRoot, 500, 100); + + // New window (Stage) + Stage newWindow = new Stage(); + newWindow.setTitle("Nouveau compte"); + newWindow.setScene(ajoutScene); + + // amount box + TextField amountField = new TextField(); + Label amount = new Label("confirmation de votre identifiant"); + amount.setLabelFor(amountField); + + ajoutRoot.add(amount, 0, 0); + ajoutRoot.add(amountField, 1, 0); + + // overdraft box + TextField overdraftField = new TextField(); + Label overdraft = new Label("Montant du virement"); + overdraft.setLabelFor(overdraftField); + + ajoutRoot.add(overdraft, 0, 1); + ajoutRoot.add(overdraftField, 1, 1); + + // Valide button + Button valideButton = new Button(); + valideButton.setText("Valider"); + + ajoutRoot.add(valideButton, 0, 2); + + + // Specifies the modality for new window. + newWindow.initModality(Modality.WINDOW_MODAL); + + // Specifies the owner Window (parent) for new window + newWindow.initOwner(stage); + + // Set position of second window, related to primary window. + newWindow.setX(stage.getX()); + newWindow.setY(stage.getY()); + newWindow.show(); + + valideButton.setOnAction(event -> { + try { + ajoutCompte(id, Float.valueOf(amountField.getText()), Float.valueOf(overdraftField.getText())); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + newWindow.close(); + }); + } /** @@ -354,4 +413,29 @@ public class GraphicalUserInterface extends Application { } return false; } + + /** + @Role effectue le virement entre les deux comptes + * @param id + * @param amount + * @param overdraft + * @throws IllegalAccessException + */ + public void ajoutCompte(@NotNull String id, float amount, float overdraft) throws IllegalAccessException { + bank.addAccount(id,amount, overdraft,getBank().getClient(id).getRole()); + } + + /** + @Role effectue le virement entre les deux comptes + * @param identifiant + * @param amount + * @param dest + * @throws Exception + */ + public void virement (@NotNull String identifiant, @NotNull float amount, @NotNull String dest) throws Exception { + Account p = bank.getClient(identifiant).getAccounts().getAccount(0); + Account d = bank.getClient(dest).getAccounts().getAccount(0); + p.withdraw(amount); + d.deposit(amount); + } } -- GitLab From b534dac48810cd856bb335f6b09d99cf40c4f90b Mon Sep 17 00:00:00 2001 From: Anthony DA SILVA COSTA Date: Fri, 3 Apr 2020 01:38:07 +0200 Subject: [PATCH 30/35] =?UTF-8?q?Cr=C3=A9ation=20du=20rendu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RENDU.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 RENDU.md diff --git a/RENDU.md b/RENDU.md new file mode 100644 index 00000000..e69de29b -- GitLab From a02a08b5be33e4731e07136b7824dbb15675d3a6 Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Fri, 3 Apr 2020 02:19:34 +0200 Subject: [PATCH 31/35] Ajustement test, interface --- .../software/construction/AccountTest.java | 13 ++- .../association/BankToAddressBookTest.java | 7 +- .../association/CardToAddressTest.java | 9 +- .../association/CardToGroupTest.java | 11 ++- .../AccountClientTest.java | 35 +++++-- .../AccountOperationTest.java | 5 +- .../ClientCardTest.java | 1 + .../ui/GraphicalUserInterface.java | 99 ++++++++++++++----- 8 files changed, 128 insertions(+), 52 deletions(-) diff --git a/src/Test/java/fr/unantes/software/construction/AccountTest.java b/src/Test/java/fr/unantes/software/construction/AccountTest.java index c4656de7..4fc81146 100644 --- a/src/Test/java/fr/unantes/software/construction/AccountTest.java +++ b/src/Test/java/fr/unantes/software/construction/AccountTest.java @@ -1,15 +1,19 @@ package fr.unantes.software.construction; +import fr.unantes.software.construction.address.PrivateAddress; +import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.*; +import java.io.InvalidClassException; + +import static org.junit.Assert.assertTrue; public class AccountTest { private Account account; @Test - public void depositTest() throws IllegalAccessException { + public void depositTest() throws Exception { account.setBalance(500); account.deposit(100); assertTrue(600 == account.getBalance()); @@ -23,4 +27,9 @@ public class AccountTest { assertTrue(200 == account.getBalance()); } + @Before + public void initBeforeTest() throws InvalidClassException { + account = new Account(new Particulier("Jean Michel","private", new PrivateAddress()),1,1,1,"private"); + } + } diff --git a/src/Test/java/fr/unantes/software/construction/association/BankToAddressBookTest.java b/src/Test/java/fr/unantes/software/construction/association/BankToAddressBookTest.java index 870433a9..501611d3 100644 --- a/src/Test/java/fr/unantes/software/construction/association/BankToAddressBookTest.java +++ b/src/Test/java/fr/unantes/software/construction/association/BankToAddressBookTest.java @@ -5,9 +5,8 @@ import fr.unantes.software.construction.address.AddressBook; import org.junit.Before; import org.junit.Test; -import java.io.InvalidClassException; - -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; public class BankToAddressBookTest { private Bank b; @@ -26,7 +25,7 @@ public class BankToAddressBookTest { } @Before - public void initBeforeTest() throws InvalidClassException { + public void initBeforeTest() { b = new Bank(); ab1 = new AddressBook(); ab2 = new AddressBook(); diff --git a/src/Test/java/fr/unantes/software/construction/association/CardToAddressTest.java b/src/Test/java/fr/unantes/software/construction/association/CardToAddressTest.java index 85560dba..c1745866 100644 --- a/src/Test/java/fr/unantes/software/construction/association/CardToAddressTest.java +++ b/src/Test/java/fr/unantes/software/construction/association/CardToAddressTest.java @@ -1,11 +1,12 @@ package fr.unantes.software.construction.association; -import fr.unantes.software.construction.address.*; +import fr.unantes.software.construction.address.CompanyAddress; +import fr.unantes.software.construction.address.CompanyCard; +import fr.unantes.software.construction.address.PrivateAddress; +import fr.unantes.software.construction.address.PrivateCard; import org.junit.Before; import org.junit.Test; -import java.io.InvalidClassException; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -46,7 +47,7 @@ public class CardToAddressTest { } @Before - public void initBeforeTest() throws InvalidClassException { + public void initBeforeTest() { card1c = new CompanyCard("Company1"); card2c = new CompanyCard("Company2"); card1p = new PrivateCard("test","private"); diff --git a/src/Test/java/fr/unantes/software/construction/association/CardToGroupTest.java b/src/Test/java/fr/unantes/software/construction/association/CardToGroupTest.java index de9a3217..16f4791b 100644 --- a/src/Test/java/fr/unantes/software/construction/association/CardToGroupTest.java +++ b/src/Test/java/fr/unantes/software/construction/association/CardToGroupTest.java @@ -1,12 +1,13 @@ package fr.unantes.software.construction.association; -import fr.unantes.software.construction.address.*; +import fr.unantes.software.construction.address.CompanyCard; +import fr.unantes.software.construction.address.Group; +import fr.unantes.software.construction.address.PrivateCard; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.*; - -import java.io.InvalidClassException; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class CardToGroupTest { private CompanyCard card1c; @@ -43,7 +44,7 @@ public class CardToGroupTest { } @Before - public void initBeforeTest() throws InvalidClassException { + public void initBeforeTest() { card1c = new CompanyCard("Company1"); card2c = new CompanyCard("Company2"); card1p = new PrivateCard("test","private"); diff --git a/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountClientTest.java b/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountClientTest.java index 5691a70a..4fc70bc0 100644 --- a/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountClientTest.java +++ b/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountClientTest.java @@ -1,7 +1,5 @@ package fr.unantes.software.construction.bidirectionalAssociation; -import static org.junit.Assert.*; - import fr.unantes.software.construction.Account; import fr.unantes.software.construction.Client; import fr.unantes.software.construction.Entreprise; @@ -13,6 +11,8 @@ import org.junit.Test; import java.io.InvalidClassException; +import static org.junit.Assert.*; + public class AccountClientTest { private Account account; private Account account2; @@ -21,22 +21,29 @@ public class AccountClientTest { @SuppressWarnings("static-access") @Test - public void ClientToAccount() throws InvalidClassException { + public void clientAddTest() { assertEquals(2,client.accountsSize()); assertEquals(1,account.clientsSize()); client2.addAccounts(account); assertEquals(1,client2.accountsSize()); assertEquals(2,account.clientsSize()); - assertTrue(client.containsAccounts(account)); - client.addAccounts(account2); - assertEquals(2,client.accountsSize()); - assertEquals(1,account2.clientsSize()); + assertTrue(client2.containsAccounts(account)); + } + + @SuppressWarnings("static-access") + @Test + public void clientRemoveTest() { assertTrue(client.containsAccounts(account)); assertTrue(client.containsAccounts(account2)); client.removeAccounts(account2); assertEquals(1,client.accountsSize()); assertTrue(client.containsAccounts(account)); assertFalse(client.containsAccounts(account2)); + } + + @SuppressWarnings("static-access") + @Test + public void clientClearTest() { assertFalse(client.isAccountsEmpty()); client.clearAccounts(); assertTrue(client.isAccountsEmpty()); @@ -44,20 +51,30 @@ public class AccountClientTest { @SuppressWarnings("static-access") @Test - public void AccountToClient() throws InvalidClassException { + public void accountAddTest() { assertEquals(1,account.clientsSize()); assertEquals(2,client.accountsSize()); account.addClients(client2); assertEquals(2,account.clientsSize()); assertEquals(1,client2.accountsSize()); assertTrue(account.containsClients(client)); - assertEquals(2,client.accountsSize()); + } + + @SuppressWarnings("static-access") + @Test + public void accountRemoveTest() { + account.addClients(client2); assertTrue(account.containsClients(client)); assertTrue(account.containsClients(client2)); account.removeClients(client2); assertEquals(1,account.clientsSize()); assertTrue(account.containsClients(client)); assertFalse(account.containsClients(client2)); + } + + @SuppressWarnings("static-access") + @Test + public void accountClearTest() { assertFalse(account.isClientsEmpty()); account.clearClients(); assertTrue(account.isClientsEmpty()); diff --git a/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountOperationTest.java b/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountOperationTest.java index 1c934ad2..c52da186 100644 --- a/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountOperationTest.java +++ b/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/AccountOperationTest.java @@ -5,7 +5,6 @@ import fr.unantes.software.construction.address.PrivateAddress; import org.junit.Before; import org.junit.Test; -import java.io.InvalidClassException; import java.time.LocalTime; import static org.junit.Assert.*; @@ -28,7 +27,7 @@ public class AccountOperationTest { @SuppressWarnings("static-access") @Test - public void AccountToOperation() throws InvalidClassException { + public void AccountToOperation() { account.addOperation(operation1); assertTrue(account.containsOperation(operation1)); assertEquals(operation1.getAccount(),account); @@ -38,7 +37,7 @@ public class AccountOperationTest { } @Before - public void initBeforeTest() throws InvalidClassException, IllegalAccessException { + public void initBeforeTest() throws Exception { account = new Account(new Particulier("test","private", new PrivateAddress()),1,1,1,"private"); operation1 = new DepositOperation(0,LocalTime.now()); operation2 = new WithdrawOperation(10, LocalTime.now()); diff --git a/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/ClientCardTest.java b/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/ClientCardTest.java index 9715c665..81e1d5d2 100644 --- a/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/ClientCardTest.java +++ b/src/Test/java/fr/unantes/software/construction/bidirectionalAssociation/ClientCardTest.java @@ -42,6 +42,7 @@ public class ClientCardTest { assertEquals(card1.getClient(),client1); card1.unSetClient(); assertNotEquals(card1.getClient(),client1); + card2.setClient(client1); assertNotEquals(card2.getClient(),client1); card2.setClient(client2); diff --git a/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java b/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java index 1ada883a..51a9d23c 100644 --- a/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java +++ b/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java @@ -1,14 +1,11 @@ package fr.unantes.software.construction.ui; import fr.unantes.software.construction.*; -import fr.unantes.software.construction.address.CompanyAddress; -import fr.unantes.software.construction.address.PrivateAddress; +import fr.unantes.software.construction.address.*; import fr.unantes.software.construction.security.ClientController; import javafx.application.Application; import javafx.scene.Scene; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.control.TextField; +import javafx.scene.control.*; import javafx.scene.layout.GridPane; import javafx.stage.Modality; import javafx.stage.Stage; @@ -25,6 +22,7 @@ public class GraphicalUserInterface extends Application { */ private Bank bank; private ClientController controller; + private Stage stage; /** * Constructor empty @@ -64,6 +62,7 @@ public class GraphicalUserInterface extends Application { * @throws Exception */ public void start(@NotNull Stage stage) throws Exception { + this.stage = stage; GridPane root = new GridPane(); // name box @@ -86,12 +85,12 @@ public class GraphicalUserInterface extends Application { loginButton.setOnAction(event -> { if(connexion(field1.getText(),field2.getText())){ - compte(stage, field1.getText()); + compte(field1.getText()); } }); createButton.setOnAction(event -> { - create(stage); + create(); }); @@ -110,9 +109,8 @@ public class GraphicalUserInterface extends Application { /** * @role interface graphique - * @param stage */ - public void create(@NotNull Stage stage){ + public void create(){ Label createLabel = new Label(); GridPane createRoot = new GridPane(); @@ -166,19 +164,19 @@ public class GraphicalUserInterface extends Application { createButton.setOnAction(event -> { try { - creerCompte(nameField.getText(),roleField.getText(),passwordField.getText()); + if(creerCompte(nameField.getText(),roleField.getText(),passwordField.getText())){ + newWindow.close(); + } } catch (InvalidClassException e) { e.printStackTrace(); } - newWindow.close(); }); } /** * @role interface graphique - * @param stage */ - public void compte(@NotNull Stage stage, @NotNull String id){ + public void compte(@NotNull String id){ Label compteLabel = new Label(); GridPane compteRoot = new GridPane(); @@ -209,7 +207,7 @@ public class GraphicalUserInterface extends Application { compteRoot.add(virementButton, 0, 2); virementButton.setOnAction(event -> { - interfaceVirement(stage); + interfaceVirement(); }); @@ -237,9 +235,8 @@ public class GraphicalUserInterface extends Application { /** * @role inferface graphique - * @param stage */ - public void interfaceVirement(@NotNull Stage stage){ + public void interfaceVirement(){ Label virementLabel = new Label(); GridPane virementRoot = new GridPane(); @@ -278,7 +275,7 @@ public class GraphicalUserInterface extends Application { // Valide button Button valideButton = new Button(); - valideButton.setText("Valide"); + valideButton.setText("Valider"); virementRoot.add(valideButton, 0, 6); @@ -325,7 +322,7 @@ public class GraphicalUserInterface extends Application { // amount box TextField amountField = new TextField(); - Label amount = new Label("confirmation de votre identifiant"); + Label amount = new Label("Amount :"); amount.setLabelFor(amountField); ajoutRoot.add(amount, 0, 0); @@ -333,7 +330,7 @@ public class GraphicalUserInterface extends Application { // overdraft box TextField overdraftField = new TextField(); - Label overdraft = new Label("Montant du virement"); + Label overdraft = new Label("Overdraft :"); overdraft.setLabelFor(overdraftField); ajoutRoot.add(overdraft, 0, 1); @@ -375,16 +372,21 @@ public class GraphicalUserInterface extends Application { * @param password * @throws InvalidClassException */ - public void creerCompte(@NotNull String name, @NotNull String role, @NotNull String password) throws InvalidClassException { + public boolean creerCompte(@NotNull String name, @NotNull String role, @NotNull String password) throws InvalidClassException { Client p; if (role.equals("private")){ p = new Particulier(name,role,new PrivateAddress()); bank.getClientRef().add(p); controller.addUser(p,password); + return true; } else if(role.equals("company")){ p = new Entreprise(name,role,new CompanyAddress()); bank.getClientRef().add(p); controller.addUser(p,password); + return true; + } else { + erreur("role = company | private"); + return false; } } @@ -400,20 +402,63 @@ public class GraphicalUserInterface extends Application { if (p != null) { if (controller.hasUser(p)) { if (getController().validatePassword(p, password)) { - System.out.println("bon mdp"); return true; } else { - System.out.println("mauvais mdp"); + erreur("Mauvais mot de passe"); return false; } } else { - System.out.println("mauvais identifiant"); + erreur("Mauvais identifiant"); return false; } } return false; } + /** + @Role envoie un message d'erreur + * @param msg + */ + public void erreur(String msg) { + Label errorLabel = new Label(); + + GridPane errorRoot = new GridPane(); + errorRoot.getChildren().add(errorLabel); + + // name box + Label message = new Label(msg); + + + Button errorButton = new Button(); + errorButton.setText("Quit"); + + + errorRoot.add(message, 0, 0); + errorRoot.add(errorButton, 0, 1); + + Scene createScene = new Scene(errorRoot, 150, 50); + + // New window (Stage) + Stage newWindow = new Stage(); + newWindow.setTitle("Error"); + newWindow.setScene(createScene); + + // Specifies the modality for new window. + newWindow.initModality(Modality.WINDOW_MODAL); + + // Specifies the owner Window (parent) for new window + newWindow.initOwner(stage); + + // Set position of second window, related to primary window. + newWindow.setX(stage.getX() + 100); + newWindow.setY(stage.getY() + 100); + newWindow.show(); + + errorButton.setOnAction(event -> { + newWindow.close(); + }); + } + /** @Role effectue le virement entre les deux comptes * @param id @@ -421,8 +466,12 @@ public class GraphicalUserInterface extends Application { * @param overdraft * @throws IllegalAccessException */ - public void ajoutCompte(@NotNull String id, float amount, float overdraft) throws IllegalAccessException { - bank.addAccount(id,amount, overdraft,getBank().getClient(id).getRole()); + public void ajoutCompte(@NotNull String id, @NotNull float amount, @NotNull float overdraft) throws IllegalAccessException { + if(amount < 0 || overdraft < 0){ + erreur("Erreur valeur négative"); + } else { + bank.addAccount(id,amount, overdraft,getBank().getClient(id).getRole()); + } } /** -- GitLab From e248c114d720ef35f491a228a955dd325cf5930d Mon Sep 17 00:00:00 2001 From: Anthony Da Silva Costa Date: Fri, 3 Apr 2020 14:05:29 +0200 Subject: [PATCH 32/35] Ajustement interface --- .../construction/ui/GraphiqueUiTest.java | 2 +- .../ui/GraphicalUserInterface.java | 62 +++++-------------- 2 files changed, 18 insertions(+), 46 deletions(-) diff --git a/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java b/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java index 8cd67d8c..209e548f 100644 --- a/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java +++ b/src/Test/java/fr/unantes/software/construction/ui/GraphiqueUiTest.java @@ -12,7 +12,7 @@ public class GraphiqueUiTest { @SuppressWarnings("static-access") @Test public void ConnexionTest() { - assertFalse(graph.connexion("test","test")); + assertFalse(graph.connexion("test","JeanM")); assertTrue(graph.connexion("Jean Michel","JeanM")); assertTrue(graph.connexion("JeanCorporation","JeanC")); assertFalse(graph.connexion("Jean Michel","JeanP")); diff --git a/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java b/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java index 51a9d23c..8670a72b 100644 --- a/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java +++ b/src/main/java/fr/unantes/software/construction/ui/GraphicalUserInterface.java @@ -86,6 +86,8 @@ public class GraphicalUserInterface extends Application { loginButton.setOnAction(event -> { if(connexion(field1.getText(),field2.getText())){ compte(field1.getText()); + } else { + error(root,"Connexion impossible"); } }); @@ -144,7 +146,7 @@ public class GraphicalUserInterface extends Application { createRoot.add(passwordField, 1, 2); createRoot.add(createButton, 0, 3); - Scene createScene = new Scene(createRoot, 300, 260); + Scene createScene = new Scene(createRoot, 400, 360); // New window (Stage) Stage newWindow = new Stage(); @@ -166,6 +168,8 @@ public class GraphicalUserInterface extends Application { try { if(creerCompte(nameField.getText(),roleField.getText(),passwordField.getText())){ newWindow.close(); + } else { + error(createRoot,"role = private | company"); } } catch (InvalidClassException e) { e.printStackTrace(); @@ -189,12 +193,17 @@ public class GraphicalUserInterface extends Application { newWindow.setTitle("Compte"); newWindow.setScene(compteScene); + // partie text + Label idLabel = new Label(id); + compteRoot.add(idLabel, 1, 0); + Label roleLabel = new Label(bank.getClient(id).getRole()); + compteRoot.add(roleLabel, 0, 0); // partie ajouter compte Button ajoutButton = new Button(); ajoutButton.setText("Nouveau compte"); - compteRoot.add(ajoutButton, 0, 1); + compteRoot.add(ajoutButton, 0, 2); ajoutButton.setOnAction(event -> { interfaceAjout(stage,id); @@ -204,7 +213,7 @@ public class GraphicalUserInterface extends Application { Button virementButton = new Button(); virementButton.setText("Effectuer un virement"); - compteRoot.add(virementButton, 0, 2); + compteRoot.add(virementButton, 0, 3); virementButton.setOnAction(event -> { interfaceVirement(); @@ -385,7 +394,6 @@ public class GraphicalUserInterface extends Application { controller.addUser(p,password); return true; } else { - erreur("role = company | private"); return false; } } @@ -404,11 +412,9 @@ public class GraphicalUserInterface extends Application { if (getController().validatePassword(p, password)) { return true; } else { - erreur("Mauvais mot de passe"); return false; } } else { - erreur("Mauvais identifiant"); return false; } } @@ -416,47 +422,13 @@ public class GraphicalUserInterface extends Application { } /** - @Role envoie un message d'erreur - * @param msg + * @Role envoie un message d'erreur + * @param root */ - public void erreur(String msg) { - Label errorLabel = new Label(); - - GridPane errorRoot = new GridPane(); - errorRoot.getChildren().add(errorLabel); - + public void error(GridPane root,String msg) { // name box Label message = new Label(msg); - - - Button errorButton = new Button(); - errorButton.setText("Quit"); - - - errorRoot.add(message, 0, 0); - errorRoot.add(errorButton, 0, 1); - - Scene createScene = new Scene(errorRoot, 150, 50); - - // New window (Stage) - Stage newWindow = new Stage(); - newWindow.setTitle("Error"); - newWindow.setScene(createScene); - - // Specifies the modality for new window. - newWindow.initModality(Modality.WINDOW_MODAL); - - // Specifies the owner Window (parent) for new window - newWindow.initOwner(stage); - - // Set position of second window, related to primary window. - newWindow.setX(stage.getX() + 100); - newWindow.setY(stage.getY() + 100); - newWindow.show(); - - errorButton.setOnAction(event -> { - newWindow.close(); - }); + root.add(message, 10, 0); } /** @@ -468,7 +440,7 @@ public class GraphicalUserInterface extends Application { */ public void ajoutCompte(@NotNull String id, @NotNull float amount, @NotNull float overdraft) throws IllegalAccessException { if(amount < 0 || overdraft < 0){ - erreur("Erreur valeur négative"); + throw new IllegalAccessException("Valeur negative"); } else { bank.addAccount(id,amount, overdraft,getBank().getClient(id).getRole()); } -- GitLab From b99bac34a1f0a617492ca4b80e979291ff7f2596 Mon Sep 17 00:00:00 2001 From: Curtis Meda Date: Fri, 3 Apr 2020 15:49:15 +0200 Subject: [PATCH 33/35] compte rendu --- RENDU.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/RENDU.md b/RENDU.md index e69de29b..569eeb05 100644 --- a/RENDU.md +++ b/RENDU.md @@ -0,0 +1,27 @@ +Choix techniques : + +Nous avons dans un premier temps reparti les tickets, chacun avançait de son côté et puis lorsqu'on avait des difficultés, on demandait de l'aide. +Nous avons réalisé les tests à la toute fin du projet, bien qu'il aurait été plus rigoureux de les faire au même moment que l'avancement des tickets. + +Parties non traitées : + +Il doit sans doute manquer quelques tests unitaires ainsi que quelques tickets non traités. + + +Extensions non demandées : + +Dans l'interface user, nous avons fait en sorte que l'utilisateur puisse ajouter un nouveau compte bancaire. + + +Problèmes rencontrés : + +La difficulté principale que nous avons eu a été la compréhension du sujet ainsi que l'appropriation du code déjà existant. +Ce fut compliqué, car nous étions un peu perdu au début, par manque de sujet, et de directives précises. +Une fois le code approprier, il a fallu comprendre les liens entre les classes, les associations, etc… +Nous avons eu aussi des soucis avec l'interface de virement. Nous n'avons pas reussi à résoudre le bug. + + +Conclusion : + +Ce projet aura été intéressant, permettant d'approfondir nos connaissances et de mettre en pratique concrètes nos cours de construction et évolution de logiciel. +Ainsi qu'apprendre et mettre et utiliser de GIT. -- GitLab From d5885e797693e36010a2ec35c7ebe10f803969ce Mon Sep 17 00:00:00 2001 From: Curtis Meda Date: Fri, 3 Apr 2020 15:51:55 +0200 Subject: [PATCH 34/35] correction compte rendu --- RENDU.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RENDU.md b/RENDU.md index 569eeb05..f1763dbe 100644 --- a/RENDU.md +++ b/RENDU.md @@ -24,4 +24,4 @@ Nous avons eu aussi des soucis avec l'interface de virement. Nous n'avons pas re Conclusion : Ce projet aura été intéressant, permettant d'approfondir nos connaissances et de mettre en pratique concrètes nos cours de construction et évolution de logiciel. -Ainsi qu'apprendre et mettre et utiliser de GIT. +Ainsi qu'apprendre et utiliser GIT. -- GitLab From 69f988a247291eb922a7cf16cda874b7911d8f44 Mon Sep 17 00:00:00 2001 From: Curtis Meda Date: Fri, 3 Apr 2020 16:10:48 +0200 Subject: [PATCH 35/35] correction de rendu --- RENDU.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/RENDU.md b/RENDU.md index f1763dbe..4cdc8523 100644 --- a/RENDU.md +++ b/RENDU.md @@ -1,11 +1,13 @@ Choix techniques : Nous avons dans un premier temps reparti les tickets, chacun avançait de son côté et puis lorsqu'on avait des difficultés, on demandait de l'aide. -Nous avons réalisé les tests à la toute fin du projet, bien qu'il aurait été plus rigoureux de les faire au même moment que l'avancement des tickets. +Chaque fois qu'on modifiait le code, nous faisions en parallèle les tests unitaires, afin de ne pas perdre de temps et surtout ne pas en oublier. +Une fois l'approche de la fin du projet nous avons essayé de peaufiner le projet, régler quelques bugs, etc... + Parties non traitées : -Il doit sans doute manquer quelques tests unitaires ainsi que quelques tickets non traités. +Il manque quelques tests unitaires ainsi que quelques tickets non traités. Extensions non demandées : @@ -18,10 +20,10 @@ Problèmes rencontrés : La difficulté principale que nous avons eu a été la compréhension du sujet ainsi que l'appropriation du code déjà existant. Ce fut compliqué, car nous étions un peu perdu au début, par manque de sujet, et de directives précises. Une fois le code approprier, il a fallu comprendre les liens entre les classes, les associations, etc… -Nous avons eu aussi des soucis avec l'interface de virement. Nous n'avons pas reussi à résoudre le bug. +Nous avons eu des soucis au niveau des nouveaux comptes vide et des difficultés de compréhension avec le lien entre client, compte et compte bancaire. -Conclusion : +Conclusion : Ce projet aura été intéressant, permettant d'approfondir nos connaissances et de mettre en pratique concrètes nos cours de construction et évolution de logiciel. Ainsi qu'apprendre et utiliser GIT. -- GitLab