Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
f7f6582
Added skip to specs document to create space on terminal& 1st test ca…
Feb 21, 2017
0840db6
2nd test case passed
Feb 22, 2017
858f111
Fu=irst test case and 3 assertions passed
Feb 22, 2017
06dd983
first test case and 3 asserstions passed
Feb 22, 2017
72f2817
Withdraw test case passed
Feb 22, 2017
241938e
giving up for now
Feb 22, 2017
0e4b4d9
Yay, they passed, that pesky put slash print
Feb 22, 2017
4e5531d
Account.all returns an array, so exciteing, but my code is a hot mess
Feb 23, 2017
e097a96
refactoring spec code, to account for account hash
Feb 23, 2017
3c8be93
All of wave 1 is refactored for account hash
Feb 23, 2017
711fc66
5 of 6 .all assertions passed
Feb 23, 2017
60e0560
Started Account.find - code and test are broken though
Feb 23, 2017
fff6b59
Added before and @accounts to specs, 2 assertions in wave 2 pass
Feb 23, 2017
3198a9d
.find works in .rb file yayyyy
Feb 24, 2017
d8a3da0
Whooo return an account that exits, thanks chris
Feb 24, 2017
02c15ad
Wave 2 complete
Feb 24, 2017
feecde5
specs uncommented out
Feb 24, 2017
732ff2d
Created Savings and Checking class stubs
Feb 24, 2017
c40b4d5
refactored spec to account for hash, first test passed
Feb 24, 2017
d4af7a6
passed first savings account test
Feb 24, 2017
e63333c
Withdraw test writted for checking account
Feb 24, 2017
b34ced5
Withdraw applies 1 dollar fee in checking
Feb 24, 2017
7eec7ed
Balance is not modified on attempted overdraft in checking
Feb 24, 2017
654a604
Savings account starting balance less than 10 raises error
Feb 24, 2017
8920e59
Savings Withdaw applies 2 dollar fee
Feb 24, 2017
79d1cad
Outputs warning at attempted overdraft
Feb 24, 2017
bc499cd
Savings withdraw applies 2 dollar fee
Feb 24, 2017
3f36b43
savings outputs warning message on attempted overdraft
Feb 24, 2017
553a1bc
savings doesnt modify balance at attempted over draft
Feb 24, 2017
a50dacb
savings fee, will no modify or overdraft account
Feb 24, 2017
c354aba
check_withdraw reduces balance
Feb 24, 2017
a8ed7eb
check_withdraw returns modified balance
Feb 24, 2017
fc915f2
check_withdraw allows balance to reach -10
Feb 24, 2017
5f754b4
edit to check_withdraw method to allow balance to reach -10
Feb 24, 2017
9229fee
test commit with git add .
Feb 24, 2017
446e26c
checking account doesnt modify account in attempted overdraft
Feb 24, 2017
6497ef8
check_withdraw requires postive number
Feb 24, 2017
42093a0
check_withdraw allow 3 free uses
Feb 24, 2017
0e81240
check_withdraw method passed all tests
Feb 24, 2017
fa9c1b4
forgot to add checking.rb
Feb 24, 2017
86050bd
Specs for Checking_account subclass have all passed
Feb 24, 2017
b09c465
add_interest returns calculated interst
Feb 24, 2017
2170655
add_interest updates balance with interest
Feb 24, 2017
84b3933
all tests are complete for savings sub class
Feb 24, 2017
71347e6
Fixed savings withdraw false pass
Feb 24, 2017
45590b3
refactored account initialize
Feb 24, 2017
6309173
refactored savings.rb
Feb 24, 2017
5d1990b
checking if github is linked
ashtn Mar 6, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
91 changes: 91 additions & 0 deletions lib/account.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
require 'csv'
require 'pry'



module Bank

class Account

attr_accessor :balance
attr_accessor :id, :opendatetime#, :accounts

@@accounts = nil
def initialize(account_hash)

@id = account_hash[:id].to_i
@balance = account_hash[:balance].to_i
@opendatetime = account_hash[:opendatetime]

raise ArgumentError.new "Account balance should not start with a negative number" if @balance < 0
@balance = @balance

end #end of initialize


def self.all

if @@accounts == nil

@@accounts = []

CSV.read("support/accounts.csv").each do |row|
account = {
id: row[0],
balance: row[1],
opendatetime: row[2]
}

@@accounts << Bank::Account.new(account)

end
end
return @@accounts
end #end self.all


# def self.accounts
# @@accounts #= @@accounts
# end


def self.find(id)

@@accounts.find do |account|

if account.id == id
return account
end
end

raise ArgumentError.new "#{id} returned no results"
end #end self.find


def withdraw(amount)

if amount < 0
raise ArgumentError.new "Withdrawal amount cannot be negative number"
else
if @balance < amount
print "Your account is going to be overdrawn"
@balance = @balance
elsif @balance >= amount
return @balance -= amount
end
end
end #end of withdraw method

def deposit(deposit_amount)

if deposit_amount < 0
raise ArgumentError.new "Deposit amount cannot be negative number"
else
@balance += deposit_amount
end
end #end of deposit method


end #end of class

end #end of module
61 changes: 61 additions & 0 deletions lib/checking.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

require 'csv'
require 'pry'
require_relative 'account.rb'


module Bank
class CheckingAccount < Account

attr_accessor :checks

def initialize(account)
super
@checks = 3
end


def withdraw(amount)

if @balance - (amount + 1) < 1
print "Insufficient Funds"
return @balnace = @balance
end
super
return @balance -= 1

end


def check_withdraw(amount)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to call the withdraw method from within check_withdraw.


if amount < 0
print "Cannot enter negative amount"
return @balance
end

check_fee = 0

if @checks < 1
check_fee = 2
end

if @balance - (amount + check_fee) < (-10)
print "Insufficient Funds"
@balnace = @balance
else
@balance = @balance - (amount + check_fee)
@checks -= 1
return @balance
end

end


def reset_checks
@checks = 3
end


end
end
46 changes: 46 additions & 0 deletions lib/savings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require 'csv'
require 'pry'
require_relative 'account.rb'


module Bank
class SavingsAccount < Account

def initialize(account)

raise ArgumentError.new "Savings Accounts must have an Initial Balance of $10" if account[:balance] < 10
super

end

def withdraw(amount)

if (@balance - (amount + 2) ) < 10
puts "Insufficient Funds"
return @balance
end
super
return @balance - 2

end


def add_interest(rate)

if rate < 0
print "We do not accept negative rates"
return @balance
else
interest = @balance * (rate/100)
@balance += interest
return interest
end

end


end
end

new_account = Bank::SavingsAccount.new({balance: 10})
puts new_account.balance
Loading