Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alison's Bank Accounts #47

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b092c16
sets up initial structure of module and class
AlisonZ Feb 22, 2017
a7faa32
adds show balance method and verifies that new objects are being inst…
AlisonZ Feb 22, 2017
8f64dba
working withdraw method, needs to be tested with spec file
AlisonZ Feb 22, 2017
9d1ca5b
withdraw method works and passes tests
AlisonZ Feb 22, 2017
5d96b68
deposit feature working and passes tests
AlisonZ Feb 22, 2017
66f4bf0
adds error for negative starting balances and all tests for Wave 1 ar…
AlisonZ Feb 22, 2017
546ff3b
phase one features are working
AlisonZ Feb 23, 2017
87df7fe
phase one is working and passes all tests
AlisonZ Feb 23, 2017
1131b7a
code and tests for self.all are working thanks to chris video
AlisonZ Feb 23, 2017
ae34958
find tests for verifying an account and that the first matches the cs…
AlisonZ Feb 23, 2017
d24e5e5
wave one working except for open dates
AlisonZ Feb 24, 2017
d9f47c4
there is a new class savings that inherits from account and passes th…
AlisonZ Feb 24, 2017
440ea50
holy cow the initialize works and i just wrote a test before code and…
AlisonZ Feb 24, 2017
e84065a
transaction fee is working and the test is all green
AlisonZ Feb 24, 2017
8184e59
withdraw fee tests and code works
AlisonZ Feb 24, 2017
339a8ca
not letting withdraws happen if fee would put account under 10; tests…
AlisonZ Feb 24, 2017
9030ecf
holy cow all of the tests and code for savings account work
AlisonZ Feb 24, 2017
cac59ee
savings account interest is being tracked and tests all work.
AlisonZ Feb 24, 2017
102fed7
changed interest to a local variable, tests still pass, savings accou…
AlisonZ Feb 24, 2017
e27d6b0
tests and code working for initializing and fee for withdraw method
AlisonZ Feb 24, 2017
b736ce5
trying to make variables of minimum and fee to share the load of with…
AlisonZ Feb 24, 2017
4fcfd35
woohooooooo savings and checking withdraw are inheriting stuff from t…
AlisonZ Feb 24, 2017
dbfd30d
withdraw tests all done for checking working
AlisonZ Feb 24, 2017
cb2b142
test for withdraw using check working and new balance is being returned
AlisonZ Feb 24, 2017
5008cf3
does not allow to go below -10
AlisonZ Feb 24, 2017
3994ad1
doesn't allow to withdraw below -10 and requires a positive withdraw …
AlisonZ Feb 24, 2017
760dae0
allows three free checks; there are some warnings about unused variab…
AlisonZ Feb 24, 2017
3417c20
withdraw_using_checks method is a go
AlisonZ Feb 24, 2017
88bacf4
reset checks method working
AlisonZ Feb 24, 2017
221f959
all working, no errors.
AlisonZ Feb 24, 2017
744f595
adds final forgotten test in savings spec. baseline is finished and e…
AlisonZ Feb 24, 2017
664da91
managed merge conflict
AlisonZ Feb 24, 2017
61f6739
submittinh hwk
AlisonZ Feb 27, 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
Prev Previous commit
Next Next commit
phase one is working and passes all tests
AlisonZ committed Feb 23, 2017

Verified

This commit was signed with the committer’s verified signature.
squid233 squid233
commit 87df7fed9340bf466eb8f4742f3152a61ad2c4e2
26 changes: 15 additions & 11 deletions lib/account.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
#this is the new, second try at this

module Bank
attr_accessor :id, :balance


class Account
attr_accessor :id, :balance
def initialize (id, balance)
raise ArgumentError.new("You need some positive cash flow to open an account") if balance < 0
@id = id
@balance = balance
raise ArgumentError.new("You need some positive cash flow to open an account") if balance < 0
@id = id
@balance = balance
end

def withdraw (amount)
if amount > 0
if @balance - amount < 0
raise ArgumentError.new ("You do not have enough money to withdraw this amount")
puts "You do not have enough money to withdraw this amount"
else
@balance -=amount
end
@balance -=amount
return @balance
else
"You can only withdraw a positive amount of money"
raise ArgumentError.new("You can only withdraw a positive amount of money")
end
return @balance
end


def deposit (amount)
if amount > 0
@balance +=amount
return @balance
else
raise ArgumentError.new("need positive amt")
end

end


@@ -39,7 +43,7 @@ def show_balance
end


my_account = Bank::Account.new(16, 1000)
# my_account = Bank::Account.new(16, 1000)
# puts my_account.show_balance
puts my_account.withdraw(0)
# puts my_account.withdraw(1200)
# puts my_account.deposit(200)
8 changes: 7 additions & 1 deletion specs/account_spec.rb
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
id = 1337
balance = 100.0
account = Bank::Account.new(id, balance)

account.must_respond_to :id
account.id.must_equal id

@@ -18,6 +17,7 @@
end

it "Raises an ArgumentError when created with a negative balance" do
# skip
# Note: we haven't talked about procs yet. You can think
# of them like blocks that sit by themselves.
# This code checks that, when the proc is executed, it
@@ -28,12 +28,14 @@
end

it "Can be created with a balance of 0" do
# skip
# If this raises, the test will fail. No 'must's needed!
Bank::Account.new(1337, 0)
end
end

describe "Account#withdraw" do
# skip
it "Reduces the balance" do
start_balance = 100.0
withdrawal_amount = 25.0
@@ -46,6 +48,7 @@
end

it "Returns the modified balance" do
# skip
start_balance = 100.0
withdrawal_amount = 25.0
account = Bank::Account.new(1337, start_balance)
@@ -57,6 +60,7 @@
end

it "Outputs a warning if the account would go negative" do
# skip
start_balance = 100.0
withdrawal_amount = 200.0
account = Bank::Account.new(1337, start_balance)
@@ -71,6 +75,7 @@
end

it "Doesn't modify the balance if the account would go negative" do
# skip
start_balance = 100.0
withdrawal_amount = 200.0
account = Bank::Account.new(1337, start_balance)
@@ -84,6 +89,7 @@
end

it "Allows the balance to go to 0" do
# skip
account = Bank::Account.new(1337, 100.0)
updated_balance = account.withdraw(account.balance)
updated_balance.must_equal 0