Skip to content

Instantly share code, notes, and snippets.

# account.rb
require_relative 'banking.rb'
require_relative 'interact.rb'
class Account
def initialize(balance, amount)
@amount = Banking.new(interact, amount)
@balance = 1000.00
end
# banking.rb
require_relative 'interact.rb'
require_relative 'account.rb'
class Banking
def initialize(interact, amount)
@amount = gets.chomp
@interact = Interact.new(account, trans_type, amount)
# @account = Account.new(amount, balance)
# interact.rb
require_relative 'account.rb'
class Interact
def start_transaction(transaction_type, current_balance)
puts "#{@greeting} Please type 'balance', 'withdraw', or 'deposit' to begin your transaction."
grab_trans_type = gets.chomp
case transaction_type
when 'balance'
puts "Your current account balance is #{Account.balance}, thank you."
class Account
def initialize(balance)
@balance = balance
end
end
# account.rb
class Account
def initialize(balance)
@balance = balance
end
attr_accessor :amount
attr_reader :balance
def withdraw(amount)
# interact.rb
require_relative './account'
class Interact
def initialize(account)
@account = account
end
def start_transaction
puts "#{greeting} Please type 'balance', 'withdraw', or 'deposit' to begin your transaction."
grab_trans_type = gets.chomp
# banking.rb
require_relative './interact'
require_relative './account'
account = Account.new(100)
interact = Interact.new(account)
while true
interact.start_transaction
@sirramongabriel
sirramongabriel / movie_manager_partial1.rb
Last active December 22, 2015 14:48
introduces the movies hash as well as the first set of client options.
movie_list = {}
puts "Hello, welcome to movie manager. Please type one of the following options to get started."
puts "---- Type 'add' to add a movie to your list."
puts "---- Type 'update' to update a movie."
puts "---- Type 'display' to see all your movies."
puts "---- Type 'delete' to delete a movie."
choice = gets.chomp.downcase
@sirramongabriel
sirramongabriel / movie_manager_partial2.rb
Created September 8, 2013 19:27
Spotlight on the first case statement.
case choice
when 'add'
puts "What movie do you want to add?"
title = gets.chomp
if movies[title.to_sym].nil?
puts "What's the rating? (Type a number 0 to 4.)"
rating = gets.chomp
movies[title.to_sym] = rating.to_i
puts "#{title} has been added with a rating of #{rating}."
when 'update'
puts "What movie do you want to update?"
title = gets.chomp
if movies[title.to_sym].nil?
puts "Movie not found!"
else
puts "What's the new rating? (Type a number 0 to 4.)"
rating = gets.chomp
movies[title.to_sym] = rating.to_i
puts "#{title} has been updated with new rating of #{rating}."