Skip to content

Wave 2 Primary Requirements #50

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

Merged
merged 1 commit into from
Oct 8, 2015
Merged
Changes from all commits
Commits
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
80 changes: 59 additions & 21 deletions bankaccounttest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,84 @@

module Bank
class Account
attr_accessor :account_id, :account_balance, :amount
attr_accessor :id, :balance, :amount

def initialize(account_id, account_balance = 0)
@account_id = account_id
@account_balance = account_balance.to_i
@amount = amount.to_i
if @account_balance < 0
# :file
@@number_of_accounts = 0

def initialize()
account_array = CSV.read("./support/accounts.csv")
@id = account_array[@@number_of_accounts][0]
@balance = account_array[@@number_of_accounts][1]
@opendate = account_array[@@number_of_accounts][2]
# @opendate = opendate
# @account_id = account_id
@balance = @balance.to_i
# @amount = amount.to_i
if @balance < 0
raise ArgumentError.new("Cannot create a new account with a negative balance")

else
puts "You deposited #{@amount} dollars."
puts "Your new balance is #{@account_balance} dollars."
puts "You deposited #{@balance} dollars."
puts "Your new balance is #{@balance} dollars."
end
end
@@number_of_accounts += 1
end #end statement for initialize method begining on line 10

def withdraw
puts "Type the amount you would like to withdraw:"
@amount = gets.chomp.to_i
if @account_balance - @amount < 0
if @balance - @amount < 0
puts ("Cannot withdraw an amount that will make the balance negative.")
puts "Your current balance is #{@account_balance}."
puts "Your current balance is #{@balance}."
else
@account_balance -= @amount
puts "Your new balance is: #{@account_balance} dollars."
end
end
@balance -= @amount
puts "Your new balance is: #{@balance} dollars."
end#end statment for the if/else beginning on line 32
end#end for withdraw method beginning on line 29

def deposit
puts "Type the amount you would like to deposit:"
@amount = gets.chomp.to_i
@account_balance += @amount
puts "Your new balance is #{@account_balance} dollars."
end
@balance += @amount
puts "Your new balance is #{@balance} dollars."
end#end statement for deposit method beginning on line 41

def balance
puts account_balance
puts @balance
end #end for balance method begining on line 48

def self.all
@@number_of_accounts = 0
all_accounts_array = []
account_array = CSV.read("./support/accounts.csv")
while @@number_of_accounts < account_array.length do
account_name = "Account" + @@number_of_accounts.to_s
account_name = Account.new()
all_accounts_array.push(account_name)
end
return all_accounts_array
end#end statement for self.all method beginning on line 52

def self.find(id)
account_array = self.all
# print account_array
return account_array.find {|i| i.id == id.to_s}
end

end
end
end#end for the account class on line 4

end #end for the bank module begining on line 3

# def self.find(id)
# @file.find do

# end
# end
# end
#
# end
# end
#extra code


Expand Down