bank_account_attr 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/bank_account_attr.rb +74 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 01b3695375e101ff40c4b300376344a6afe0578c
|
4
|
+
data.tar.gz: 31f39e35dfac4a9922b355c3a66ad4f8b7dd7925
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cf86faf328bc1ee1f7fb6a0f695535523722ac05906c810352a52809bd5afa173a7c90eb050b2fb8a1da8276b651fdc27c2b03533ddf7566f54aa4e716f802d3
|
7
|
+
data.tar.gz: ff48553b490a80a8d8b1345bac1d1f211a10b645d3438d136aaff58c491fa447c3de30273fd37f5e5dd4fdfac6a6585540fdc26cd6713fcf4da3445d5a6a6d75
|
@@ -0,0 +1,74 @@
|
|
1
|
+
!#usr/bin/ruby
|
2
|
+
|
3
|
+
class BankAccount
|
4
|
+
|
5
|
+
attr_accessor :balance, :loan_amt, :name
|
6
|
+
def initialize(balance=10000, loan_amt=0, name="Priyanka")
|
7
|
+
@balance = balance
|
8
|
+
@loan_amt = loan_amt
|
9
|
+
@name = name
|
10
|
+
end
|
11
|
+
def deposite
|
12
|
+
puts "#{name},your previous balance is: #{@balance}"
|
13
|
+
print "Enter the amount you want to deposite: "
|
14
|
+
dip = gets.chomp.to_i
|
15
|
+
@balance = @balance + dip
|
16
|
+
puts "Your current balance is: #{@balance}"
|
17
|
+
end
|
18
|
+
def withdraw
|
19
|
+
puts "#{name},your previous balance is: #{@balance}"
|
20
|
+
print "Enter the amount you want to withdraw: "
|
21
|
+
wid = gets.chomp.to_i
|
22
|
+
@balance = @balance - wid
|
23
|
+
puts "Your current balance is: #{@balance}"
|
24
|
+
end
|
25
|
+
def current_bal
|
26
|
+
puts "#{name},your current balance is: #{@balance}"
|
27
|
+
end
|
28
|
+
def loan
|
29
|
+
puts "#{name},your current balance is: #{@balance}"
|
30
|
+
print "Enter the amount you want for loan: "
|
31
|
+
lon = gets.chomp.to_i
|
32
|
+
@loan_amt = @loan_amt + lon
|
33
|
+
puts "You get the loan of: #{@loan_amt}"
|
34
|
+
end
|
35
|
+
def loan_paid
|
36
|
+
puts "#{name},your current loan amount is: #{@loan_amt}"
|
37
|
+
print "Enter the amount you want to pay for loan: "
|
38
|
+
lon = gets.chomp.to_i
|
39
|
+
@loan_amt = @loan_amt - lon
|
40
|
+
puts "Your current balance with loan amount is: #{@loan_amt+@balance} "
|
41
|
+
end
|
42
|
+
def self.transfer(acc1,acc2)
|
43
|
+
print "Enter the account holder name you want transfer: "
|
44
|
+
@name = gets.chomp.to_s
|
45
|
+
print "Enter the amount for: "
|
46
|
+
amount = gets.chomp.to_i
|
47
|
+
if amount > acc1.balance
|
48
|
+
puts "Transaction failed.You have no enough money for the transaction."
|
49
|
+
else
|
50
|
+
acc1.balance = acc1.balance - amount
|
51
|
+
acc2.balance = acc2.balance + amount
|
52
|
+
puts "Your current balance after transfer is #{acc1.balance}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
account = BankAccount.new
|
57
|
+
account2 = BankAccount.new(2000,0,"aaa")
|
58
|
+
puts "Enter the number of option you want to operate:\n1.deposite\n2.withdraw\n3.balance inquery\n4.apply loan\n5.payment for existing loan\n6.transfer\n"
|
59
|
+
option = gets.chomp.to_i
|
60
|
+
|
61
|
+
case option
|
62
|
+
when 1
|
63
|
+
account.deposite
|
64
|
+
when 2
|
65
|
+
account.withdraw
|
66
|
+
when 3
|
67
|
+
account.current_bal
|
68
|
+
when 4
|
69
|
+
account.loan
|
70
|
+
when 5
|
71
|
+
account.loan_paid
|
72
|
+
when 6
|
73
|
+
BankAccount.transfer(account,account2)
|
74
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bank_account_attr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Priyanka
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: manage a bank account
|
14
|
+
email: priyankajena@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/bank_account_attr.rb
|
20
|
+
homepage: http://rubygems.org/gems/bank_account_attr
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.4.6
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: bank account
|
44
|
+
test_files: []
|