diff --git a/Banks/Entities/Bank.cs b/Banks/Entities/Bank.cs index 3f9993a..488805b 100644 --- a/Banks/Entities/Bank.cs +++ b/Banks/Entities/Bank.cs @@ -109,7 +109,6 @@ public void Inform(string message) public void SetAccountCreator(IFactory accountCreator) { - accountCreator.AttachBank(this); _currentCreator = accountCreator; } @@ -121,7 +120,7 @@ public AbstractAccount CreateAccount(Client client) throw new BankException("Client not at Bank!"); } - AbstractAccount account = _currentCreator.CreateAccount(client); + AbstractAccount account = _currentCreator.CreateAccount(this, client); client.AddAccount(account); return account; } diff --git a/Banks/Entities/Factories/CreditAccountFactory.cs b/Banks/Entities/Factories/CreditAccountFactory.cs index 64ec56c..6cf223b 100644 --- a/Banks/Entities/Factories/CreditAccountFactory.cs +++ b/Banks/Entities/Factories/CreditAccountFactory.cs @@ -7,9 +7,7 @@ namespace Banks.Entities.Factories { public class CreditAccountFactory : IFactory { - private Bank _bank; - - public AbstractAccount CreateAccount(Client client) + public AbstractAccount CreateAccount(Bank bank, Client client) { if (client == null) { @@ -18,13 +16,8 @@ public AbstractAccount CreateAccount(Client client) return new CreditAccount( client, - DateTime.Today.AddYears(_bank.YearsLiveOfAccounts), - _bank.CreditCommission); - } - - public void AttachBank(Bank bank) - { - _bank = bank; + DateTime.Today.AddYears(bank.YearsLiveOfAccounts), + bank.CreditCommission); } } } \ No newline at end of file diff --git a/Banks/Entities/Factories/DebitAccountFactory.cs b/Banks/Entities/Factories/DebitAccountFactory.cs index dab495b..2e260e0 100644 --- a/Banks/Entities/Factories/DebitAccountFactory.cs +++ b/Banks/Entities/Factories/DebitAccountFactory.cs @@ -7,14 +7,7 @@ namespace Banks.Entities.Factories { public class DebitAccountFactory : IFactory { - private Bank _bank; - - public void AttachBank(Bank bank) - { - _bank = bank; - } - - public AbstractAccount CreateAccount(Client client) + public AbstractAccount CreateAccount(Bank bank, Client client) { if (client == null) { @@ -23,8 +16,8 @@ public AbstractAccount CreateAccount(Client client) return new DebitAccount( client, - DateTime.Today.AddYears(_bank.YearsLiveOfAccounts), - _bank.DebitInterestRate); + DateTime.Today.AddYears(bank.YearsLiveOfAccounts), + bank.DebitInterestRate); } } } \ No newline at end of file diff --git a/Banks/Entities/Factories/DepositAccountFactory.cs b/Banks/Entities/Factories/DepositAccountFactory.cs index 743cd3b..c6f9614 100644 --- a/Banks/Entities/Factories/DepositAccountFactory.cs +++ b/Banks/Entities/Factories/DepositAccountFactory.cs @@ -7,14 +7,7 @@ namespace Banks.Entities.Factories { public class DepositAccountFactory : IFactory { - private Bank _bank; - - public void AttachBank(Bank bank) - { - _bank = bank; - } - - public AbstractAccount CreateAccount(Client client) + public AbstractAccount CreateAccount(Bank bank, Client client) { if (client == null) { @@ -23,8 +16,8 @@ public AbstractAccount CreateAccount(Client client) return new DepositAccount( client, - DateTime.Today.AddYears(_bank.YearsLiveOfAccounts), - _bank.DepositHandler); + DateTime.Today.AddYears(bank.YearsLiveOfAccounts), + bank.DepositHandler); } } } \ No newline at end of file diff --git a/Banks/Services/IFactory.cs b/Banks/Services/IFactory.cs index 616f959..928c9ba 100644 --- a/Banks/Services/IFactory.cs +++ b/Banks/Services/IFactory.cs @@ -4,7 +4,6 @@ namespace Banks.Services { public interface IFactory { - void AttachBank(Bank bank); - AbstractAccount CreateAccount(Client client); + AbstractAccount CreateAccount(Bank bank, Client client); } } \ No newline at end of file