Skip to content

Commit 9e5dd24

Browse files
committed
Merge pull request #50 from lacuchilla/arh/master
Wave 2 Primary Requirements
2 parents 6f74fff + adfe9a6 commit 9e5dd24

File tree

1 file changed

+59
-21
lines changed

1 file changed

+59
-21
lines changed

bankaccounttest.rb

+59-21
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,84 @@
22

33
module Bank
44
class Account
5-
attr_accessor :account_id, :account_balance, :amount
5+
attr_accessor :id, :balance, :amount
66

7-
def initialize(account_id, account_balance = 0)
8-
@account_id = account_id
9-
@account_balance = account_balance.to_i
10-
@amount = amount.to_i
11-
if @account_balance < 0
7+
# :file
8+
@@number_of_accounts = 0
9+
10+
def initialize()
11+
account_array = CSV.read("./support/accounts.csv")
12+
@id = account_array[@@number_of_accounts][0]
13+
@balance = account_array[@@number_of_accounts][1]
14+
@opendate = account_array[@@number_of_accounts][2]
15+
# @opendate = opendate
16+
# @account_id = account_id
17+
@balance = @balance.to_i
18+
# @amount = amount.to_i
19+
if @balance < 0
1220
raise ArgumentError.new("Cannot create a new account with a negative balance")
1321

1422
else
15-
puts "You deposited #{@amount} dollars."
16-
puts "Your new balance is #{@account_balance} dollars."
23+
puts "You deposited #{@balance} dollars."
24+
puts "Your new balance is #{@balance} dollars."
1725
end
18-
end
26+
@@number_of_accounts += 1
27+
end #end statement for initialize method begining on line 10
1928

2029
def withdraw
2130
puts "Type the amount you would like to withdraw:"
2231
@amount = gets.chomp.to_i
23-
if @account_balance - @amount < 0
32+
if @balance - @amount < 0
2433
puts ("Cannot withdraw an amount that will make the balance negative.")
25-
puts "Your current balance is #{@account_balance}."
34+
puts "Your current balance is #{@balance}."
2635
else
27-
@account_balance -= @amount
28-
puts "Your new balance is: #{@account_balance} dollars."
29-
end
30-
end
36+
@balance -= @amount
37+
puts "Your new balance is: #{@balance} dollars."
38+
end#end statment for the if/else beginning on line 32
39+
end#end for withdraw method beginning on line 29
3140

3241
def deposit
3342
puts "Type the amount you would like to deposit:"
3443
@amount = gets.chomp.to_i
35-
@account_balance += @amount
36-
puts "Your new balance is #{@account_balance} dollars."
37-
end
44+
@balance += @amount
45+
puts "Your new balance is #{@balance} dollars."
46+
end#end statement for deposit method beginning on line 41
3847

3948
def balance
40-
puts account_balance
49+
puts @balance
50+
end #end for balance method begining on line 48
51+
52+
def self.all
53+
@@number_of_accounts = 0
54+
all_accounts_array = []
55+
account_array = CSV.read("./support/accounts.csv")
56+
while @@number_of_accounts < account_array.length do
57+
account_name = "Account" + @@number_of_accounts.to_s
58+
account_name = Account.new()
59+
all_accounts_array.push(account_name)
60+
end
61+
return all_accounts_array
62+
end#end statement for self.all method beginning on line 52
63+
64+
def self.find(id)
65+
account_array = self.all
66+
# print account_array
67+
return account_array.find {|i| i.id == id.to_s}
4168
end
4269

43-
end
44-
end
70+
end#end for the account class on line 4
71+
72+
end #end for the bank module begining on line 3
73+
74+
# def self.find(id)
75+
# @file.find do
76+
77+
# end
78+
# end
79+
# end
80+
#
81+
# end
82+
# end
4583
#extra code
4684

4785

0 commit comments

Comments
 (0)