This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Account | |
| def initialize(balance) | |
| @balance = balance | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # account.rb | |
| class Account | |
| def initialize(balance) | |
| @balance = balance | |
| end | |
| attr_accessor :amount | |
| attr_reader :balance | |
| def withdraw(amount) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # banking.rb | |
| require_relative './interact' | |
| require_relative './account' | |
| account = Account.new(100) | |
| interact = Interact.new(account) | |
| while true | |
| interact.start_transaction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}." |