From b79bdfe503a4328712f3ff1f93473a1f8a762833 Mon Sep 17 00:00:00 2001 From: Kari Bancroft Date: Thu, 8 Oct 2015 11:13:05 -0700 Subject: [PATCH 01/14] Add wave 3 --- README.md | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 25fd4d2a..b6e5c7b2 100644 --- a/README.md +++ b/README.md @@ -73,24 +73,23 @@ Create an `Account` class which should have the following functionality: **Account ID** - (Fixnum) a unique identifier corresponding to an account **Owner ID** - (Fixnum) a unique identifier corresponding to an owner - From 7267a0db699db76ffd3ba02c270e1eeba43de871 Mon Sep 17 00:00:00 2001 From: Jenna Nichols Date: Thu, 8 Oct 2015 13:46:13 -0700 Subject: [PATCH 02/14] created CheckingAccount class --- checking-account.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 checking-account.rb diff --git a/checking-account.rb b/checking-account.rb new file mode 100644 index 00000000..aff841aa --- /dev/null +++ b/checking-account.rb @@ -0,0 +1,8 @@ +require "./bank-accounts.rb" + +module Bank #maybe? + class SavingsAccount + + end + +end From cdbd57866f64105dcf41510f698116b1aea7e4ab Mon Sep 17 00:00:00 2001 From: Jenna Nichols Date: Thu, 8 Oct 2015 14:47:08 -0700 Subject: [PATCH 03/14] changed file name, added initialize and withdraw methods --- savings-account.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 savings-account.rb diff --git a/savings-account.rb b/savings-account.rb new file mode 100644 index 00000000..825fed9b --- /dev/null +++ b/savings-account.rb @@ -0,0 +1,19 @@ +require 'pry' +require "./bank-accounts.rb" + +module Bank + class SavingsAccount < Account + + def initialize(ident, open_date, balance) + super + min_balance = 1000 + raise ArgumentError.new("Your intial balance can't be less than #{min_balance}") if balance < min_balance + end + + def withdraw(withdraw_amount) + super(withdraw_amount + 1) + end + + end + +end From e0d00be41c5d316b6cee59f9675679b4106af9ca Mon Sep 17 00:00:00 2001 From: Jenna Nichols Date: Thu, 8 Oct 2015 15:05:05 -0700 Subject: [PATCH 04/14] introduced class variables and updated methods --- bank-accounts.rb | 13 ++++++++----- savings-account.rb | 10 ++-------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/bank-accounts.rb b/bank-accounts.rb index 8068530b..94998b38 100644 --- a/bank-accounts.rb +++ b/bank-accounts.rb @@ -6,13 +6,15 @@ module Bank class Account + @@min_balance = 0 + attr_reader :balance, :owner, :open_date, :ident - def initialize(ident, balance, open_date) + def initialize(ident, open_date, balance) @ident = ident - @balance = balance - raise ArgumentError.new("Your intial balance can't be negative") if balance < 0 @open_date = DateTime.strptime(open_date, '%Y-%m-%d %H:%M:%S %z') + @balance = balance + raise ArgumentError.new("Your intial balance can't be less than #{@@min_balance}") if balance < @@min_balance end def self.all @@ -53,8 +55,9 @@ def assign_to_owner(person) # pass in an instance of Owner end def withdraw(withdraw_amount) - if @balance - withdraw_amount < 0 - puts "Insufficient funds. Withdraw denied." + min_balance = 0 + if @balance - withdraw_amount < @@min_balance + puts "Insufficient new balance. Withdraw denied." @balance else @balance -= withdraw_amount diff --git a/savings-account.rb b/savings-account.rb index 825fed9b..d4a95ea9 100644 --- a/savings-account.rb +++ b/savings-account.rb @@ -3,17 +3,11 @@ module Bank class SavingsAccount < Account - - def initialize(ident, open_date, balance) - super - min_balance = 1000 - raise ArgumentError.new("Your intial balance can't be less than #{min_balance}") if balance < min_balance - end + @@min_balance = 1000 def withdraw(withdraw_amount) - super(withdraw_amount + 1) + super(withdraw_amount + 2) end end - end From e3227dfab111f106c386cce0db5750134bda2835 Mon Sep 17 00:00:00 2001 From: Jenna Nichols Date: Thu, 8 Oct 2015 15:17:25 -0700 Subject: [PATCH 05/14] made master file, updated withdraw method, added interest method --- bank-accounts.rb | 1 - bank-master.rb | 2 ++ savings-account.rb | 11 +++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 bank-master.rb diff --git a/bank-accounts.rb b/bank-accounts.rb index 94998b38..9c5f06d0 100644 --- a/bank-accounts.rb +++ b/bank-accounts.rb @@ -55,7 +55,6 @@ def assign_to_owner(person) # pass in an instance of Owner end def withdraw(withdraw_amount) - min_balance = 0 if @balance - withdraw_amount < @@min_balance puts "Insufficient new balance. Withdraw denied." @balance diff --git a/bank-master.rb b/bank-master.rb new file mode 100644 index 00000000..71e9382c --- /dev/null +++ b/bank-master.rb @@ -0,0 +1,2 @@ +require "./bank-accounts.rb" +require "./savings-account.rb" diff --git a/savings-account.rb b/savings-account.rb index d4a95ea9..0d88650f 100644 --- a/savings-account.rb +++ b/savings-account.rb @@ -1,12 +1,15 @@ -require 'pry' -require "./bank-accounts.rb" - module Bank class SavingsAccount < Account @@min_balance = 1000 def withdraw(withdraw_amount) - super(withdraw_amount + 2) + super(withdraw_amount + 200) + end + + def add_interest(rate) + interest = @balance * rate/100 + @balance += interest + return interest end end From 7b8cbc914ae5899cfb7873324c2d4d789e97d64c Mon Sep 17 00:00:00 2001 From: Jenna Nichols Date: Thu, 8 Oct 2015 15:21:25 -0700 Subject: [PATCH 06/14] updated initial error message, created CheckingAccount class --- bank-accounts.rb | 2 +- checking-account.rb | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/bank-accounts.rb b/bank-accounts.rb index 9c5f06d0..34dc7eaa 100644 --- a/bank-accounts.rb +++ b/bank-accounts.rb @@ -14,7 +14,7 @@ def initialize(ident, open_date, balance) @ident = ident @open_date = DateTime.strptime(open_date, '%Y-%m-%d %H:%M:%S %z') @balance = balance - raise ArgumentError.new("Your intial balance can't be less than #{@@min_balance}") if balance < @@min_balance + raise ArgumentError.new("Insufficient initial balance") if balance < @@min_balance end def self.all diff --git a/checking-account.rb b/checking-account.rb index aff841aa..99c88781 100644 --- a/checking-account.rb +++ b/checking-account.rb @@ -1,8 +1,6 @@ -require "./bank-accounts.rb" +module Bank + class CheckingAccount -module Bank #maybe? - class SavingsAccount - end end From f6dd3e88bde88740854fca45e3bfc56b7ca4980e Mon Sep 17 00:00:00 2001 From: Jenna Nichols Date: Thu, 8 Oct 2015 15:50:54 -0700 Subject: [PATCH 07/14] completed primary requirements for CheckingAccount class --- bank-master.rb | 1 + checking-account.rb | 31 ++++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/bank-master.rb b/bank-master.rb index 71e9382c..891d05b3 100644 --- a/bank-master.rb +++ b/bank-master.rb @@ -1,2 +1,3 @@ require "./bank-accounts.rb" require "./savings-account.rb" +require "./checking-account.rb" diff --git a/checking-account.rb b/checking-account.rb index 99c88781..20595aa5 100644 --- a/checking-account.rb +++ b/checking-account.rb @@ -1,5 +1,34 @@ module Bank - class CheckingAccount + class CheckingAccount < Account + attr_reader :used_checks + + def initialize(ident, open_date, balance) + super + @used_checks = 0 + end + + def withdraw(withdraw_amount) + super(withdraw_amount + 100) + end + + def withdraw_using_check(amount) + if @balance - amount < -1000 + puts "Insufficient new balance. Check denied." + @balance + else + @used_checks += 1 + if @used_checks > 3 + @balance = @balance - amount - 200 + else + @balance -= amount + end + end + end + + def reset_checks + @used_checks = 0 + end + end From ea664dee7e662a7cdc9b57b2357b743dbe4966d1 Mon Sep 17 00:00:00 2001 From: Jenna Nichols Date: Thu, 8 Oct 2015 16:19:23 -0700 Subject: [PATCH 08/14] created MoneyMarket class with initialize parameters --- bank-master.rb | 1 + money-market.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 money-market.rb diff --git a/bank-master.rb b/bank-master.rb index 891d05b3..d5f70217 100644 --- a/bank-master.rb +++ b/bank-master.rb @@ -1,3 +1,4 @@ require "./bank-accounts.rb" require "./savings-account.rb" require "./checking-account.rb" +require "./money-market.rb" diff --git a/money-market.rb b/money-market.rb new file mode 100644 index 00000000..21ac2ccf --- /dev/null +++ b/money-market.rb @@ -0,0 +1,16 @@ +module Bank + class MoneyMarketAccount < Account + attr_reader :used_checks + + @@min_balance = 1000000 + + def initialize(ident, open_date, balance) + super + @transaction_count = 0 + end + + + + + end +end From e1cdc2d1ee1b8e9e809c9bfcebd1c66d26f8c949 Mon Sep 17 00:00:00 2001 From: Jenna Nichols Date: Fri, 9 Oct 2015 12:07:10 -0700 Subject: [PATCH 09/14] first pass at withdraw method in MM class --- money-market.rb | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/money-market.rb b/money-market.rb index 21ac2ccf..e026f05e 100644 --- a/money-market.rb +++ b/money-market.rb @@ -1,15 +1,36 @@ module Bank class MoneyMarketAccount < Account - attr_reader :used_checks + attr_reader :transactions_permitted, :transaction_count @@min_balance = 1000000 def initialize(ident, open_date, balance) super @transaction_count = 0 + @transactions_permitted = true end - + +# If a withdrawal causes the balance to go below $10,000, +# a fee of $100 is imposed and no more transactions are allowed until the balance is increased using a deposit transaction. +# Each transaction will be counted against the maximum number of transactions + + def withdraw(withdraw_amount) + if @balance - withdraw_amount < @@min_balance # if balance will go below min balance + @transactions_permitted = false # no more transactions + @balance -= 10000 # fee of $100 + elsif + @transaction_count < 6 && @transactions_permitted + @transaction_count += 1 + @balance -= withdraw_amount + else + @balance + end + end + + # Updated deposit logic: + # Each transaction will be counted against the maximum number of transactions + # Exception to the above: A deposit performed to reach or exceed the minimum balance of $10,000 is not counted as part of the 6 transactions. end From a21b14aff7f685324e26a494c6991568a159db10 Mon Sep 17 00:00:00 2001 From: Jenna Nichols Date: Fri, 9 Oct 2015 12:26:18 -0700 Subject: [PATCH 10/14] updated withdraw method in MM class --- money-market.rb | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/money-market.rb b/money-market.rb index e026f05e..6c762c67 100644 --- a/money-market.rb +++ b/money-market.rb @@ -1,6 +1,6 @@ module Bank class MoneyMarketAccount < Account - attr_reader :transactions_permitted, :transaction_count + attr_reader :transactions_permitted, :transaction_count, :balance @@min_balance = 1000000 @@ -16,7 +16,10 @@ def initialize(ident, open_date, balance) # Each transaction will be counted against the maximum number of transactions def withdraw(withdraw_amount) - if @balance - withdraw_amount < @@min_balance # if balance will go below min balance + if @balance - withdraw_amount < 0 + puts "Insufficient new balance. Withdraw denied." + @balance + elsif @balance - withdraw_amount < @@min_balance # if balance will go below min balance @transactions_permitted = false # no more transactions @balance -= 10000 # fee of $100 elsif @@ -32,6 +35,26 @@ def withdraw(withdraw_amount) # Each transaction will be counted against the maximum number of transactions # Exception to the above: A deposit performed to reach or exceed the minimum balance of $10,000 is not counted as part of the 6 transactions. + def deposit(deposit_amount) + if !@transactions_permitted + @balance += deposit_amount + if @balance >= @@min_balance + @transactions_permitted = true + @balance + else + @transactions_permitted = false + @balance + end + elsif @transaction_count < 6 + @balance += deposit_amount + else + @balance + end + end + + def reset_transaction_count + @transaction_count = 0 + end end end From a3a89da08ce16f370403ddf2552d08904cf2c050 Mon Sep 17 00:00:00 2001 From: Jenna Nichols Date: Fri, 9 Oct 2015 14:10:03 -0700 Subject: [PATCH 11/14] updated MM deposit method --- money-market.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/money-market.rb b/money-market.rb index 6c762c67..88152b1d 100644 --- a/money-market.rb +++ b/money-market.rb @@ -2,7 +2,7 @@ module Bank class MoneyMarketAccount < Account attr_reader :transactions_permitted, :transaction_count, :balance - @@min_balance = 1000000 + @@min_balance = 10000 ### change this back def initialize(ident, open_date, balance) super @@ -19,9 +19,9 @@ def withdraw(withdraw_amount) if @balance - withdraw_amount < 0 puts "Insufficient new balance. Withdraw denied." @balance - elsif @balance - withdraw_amount < @@min_balance # if balance will go below min balance + elsif @balance - withdraw_amount < @@min_balance && @transactions_permitted # if balance will go below min balance @transactions_permitted = false # no more transactions - @balance -= 10000 # fee of $100 + @balance = @balance - withdraw_amount - 100 # change this back elsif @transaction_count < 6 && @transactions_permitted @transaction_count += 1 @@ -46,6 +46,7 @@ def deposit(deposit_amount) @balance end elsif @transaction_count < 6 + @transaction_count += 1 @balance += deposit_amount else @balance From e1ed3beb1044d42226ce21411b41d70480739732 Mon Sep 17 00:00:00 2001 From: Jenna Nichols Date: Fri, 9 Oct 2015 14:11:05 -0700 Subject: [PATCH 12/14] added MM interest method --- money-market.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/money-market.rb b/money-market.rb index 88152b1d..e884a16d 100644 --- a/money-market.rb +++ b/money-market.rb @@ -10,11 +10,6 @@ def initialize(ident, open_date, balance) @transactions_permitted = true end - -# If a withdrawal causes the balance to go below $10,000, -# a fee of $100 is imposed and no more transactions are allowed until the balance is increased using a deposit transaction. -# Each transaction will be counted against the maximum number of transactions - def withdraw(withdraw_amount) if @balance - withdraw_amount < 0 puts "Insufficient new balance. Withdraw denied." @@ -31,10 +26,6 @@ def withdraw(withdraw_amount) end end - # Updated deposit logic: - # Each transaction will be counted against the maximum number of transactions - # Exception to the above: A deposit performed to reach or exceed the minimum balance of $10,000 is not counted as part of the 6 transactions. - def deposit(deposit_amount) if !@transactions_permitted @balance += deposit_amount @@ -57,5 +48,11 @@ def reset_transaction_count @transaction_count = 0 end + def add_interest(rate) + interest = @balance * rate/100 + @balance += interest + return interest + end + end end From fe6b90f1143fedc4fec47efce7437ffd2eda30b3 Mon Sep 17 00:00:00 2001 From: Jenna Nichols Date: Fri, 9 Oct 2015 14:12:03 -0700 Subject: [PATCH 13/14] changed money back to cents format --- money-market.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/money-market.rb b/money-market.rb index e884a16d..08e893d9 100644 --- a/money-market.rb +++ b/money-market.rb @@ -2,7 +2,7 @@ module Bank class MoneyMarketAccount < Account attr_reader :transactions_permitted, :transaction_count, :balance - @@min_balance = 10000 ### change this back + @@min_balance = 1000000 def initialize(ident, open_date, balance) super @@ -16,7 +16,7 @@ def withdraw(withdraw_amount) @balance elsif @balance - withdraw_amount < @@min_balance && @transactions_permitted # if balance will go below min balance @transactions_permitted = false # no more transactions - @balance = @balance - withdraw_amount - 100 # change this back + @balance = @balance - withdraw_amount - 10000 elsif @transaction_count < 6 && @transactions_permitted @transaction_count += 1 From 054a1569ec6d7f17350d2f2d7880f6939fcc808a Mon Sep 17 00:00:00 2001 From: Jenna Nichols Date: Fri, 9 Oct 2015 14:58:14 -0700 Subject: [PATCH 14/14] minor chnages to comments --- money-market.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/money-market.rb b/money-market.rb index 08e893d9..ad61aaa3 100644 --- a/money-market.rb +++ b/money-market.rb @@ -2,20 +2,20 @@ module Bank class MoneyMarketAccount < Account attr_reader :transactions_permitted, :transaction_count, :balance - @@min_balance = 1000000 + @@min_balance = 1000000 def initialize(ident, open_date, balance) super @transaction_count = 0 - @transactions_permitted = true + @transactions_permitted = true # this only refers to minimum balance concerns, not to transaction count end def withdraw(withdraw_amount) - if @balance - withdraw_amount < 0 + if @balance - withdraw_amount < 0 # balance can never go negative puts "Insufficient new balance. Withdraw denied." @balance - elsif @balance - withdraw_amount < @@min_balance && @transactions_permitted # if balance will go below min balance - @transactions_permitted = false # no more transactions + elsif @balance - withdraw_amount < @@min_balance && @transactions_permitted + @transactions_permitted = false @balance = @balance - withdraw_amount - 10000 elsif @transaction_count < 6 && @transactions_permitted