Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Naming-conventions/Ruby/naming-conventions-1.rb
Normal file
5
Task/Naming-conventions/Ruby/naming-conventions-1.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
test_variable = [1, 9, 8, 3]
|
||||
test_variable.sort # => [1, 3, 8, 9]
|
||||
test_variable # => [1, 9, 8, 3]
|
||||
test_variable.sort! # => [1, 3, 8, 9]
|
||||
test_variable # => [1, 3, 8, 9]
|
||||
47
Task/Naming-conventions/Ruby/naming-conventions-2.rb
Normal file
47
Task/Naming-conventions/Ruby/naming-conventions-2.rb
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# Global variable
|
||||
$number_of_continents = 7
|
||||
|
||||
module Banking
|
||||
# Module constants for semantic versioning
|
||||
VERSION = '1.0.0.1'
|
||||
class BankAccount
|
||||
attr_accessor :first_name, :last_name
|
||||
attr_reader :account_number
|
||||
|
||||
@@ATM_FEE = 3.75
|
||||
@@adiministrator_password = 'secret'
|
||||
|
||||
# The class's constructor
|
||||
def initialize(first_name, last_name, account_number)
|
||||
@first_name = first_name
|
||||
@last_name = last_name
|
||||
@account_number = account_number
|
||||
@balance = 0
|
||||
end
|
||||
|
||||
# Explicit setter as extra behavior is required
|
||||
def account_number=(account_number)
|
||||
puts 'Enter administrator override'
|
||||
if gets == @@adiministrator_password
|
||||
@account_number = account_number
|
||||
else
|
||||
puts 'Sorry. Incorrect password. Account number not changed'
|
||||
end
|
||||
end
|
||||
|
||||
# Explicit getter as extra behavior is required
|
||||
def balance
|
||||
"$#{@balance / 100}.#{@balance % 100}"
|
||||
end
|
||||
|
||||
# Check if account has sufficient funds to complete transaction
|
||||
def sufficient_funds? (withdrawal_amount)
|
||||
withdrawal_amount <= @balance
|
||||
end
|
||||
|
||||
# Destructive method
|
||||
def donate_all_money!
|
||||
@balance = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue