[Uw-ruby] week 5 homework
Ryan Davis
ryand-uwruby at zenspider.com
Fri Nov 2 10:27:46 PST 2007
I'll also be posting this to the website as soon as I get real
internet access (I'm at the airport):
##
# Week 5 Homework
##
# Bank
#
# Must be able to:
#
# * Make new accounts.
# * Close accounts.
# * Make deposits for a specific account.
# * Make withdrawls for a specific account.
#
# How you do it is entirely up to you.
##
# Vending Machine
#
# Must be able to:
#
# * Hold multiple products with differing prices.
# * Know when it is out of a specific product.
# * Refill specific products.
# * Sell specific products (and therefor deal with user input and
payments)
##
# Parking Lot
#
# Must be able to:
#
# * Open close gate/bar thingy
# * Take money for parking spot #
# * Know how long the car can be there and mark it for fine if past time
# * whatever... we didn't talk about this, so be creative.
---- test/test_bank.rb
#!/usr/bin/env ruby -w
##
# Student Name: XXX
# Homework Week: 5
#
$: << 'lib' # this is only needed if you don't use autotest
require 'test/unit'
require 'bank.rb'
##
# NOTE: these tests are just hints, go nuts with them and/or the
design...
class TestBank < Test::Unit::TestCase
def setup
@bank = Bank.new
end
def test_create_account
flunk "write me"
end
def test_deposit_to_acct
flunk "write me"
end
def test_deposit_to_acct_unknown_person
flunk "write me"
end
def test_withdraw_known_person
flunk "write me"
end
def test_withdraw_known_person_overdraw
flunk "write me"
end
def test_withdraw_unknown_person
flunk "write me"
end
end
----- test/test_account.rb
#!/usr/bin/env ruby -w
$: << 'lib' # this is only needed if you don't use autotest
require 'test/unit'
require 'account.rb'
class TestAccount < Test::Unit::TestCase
def setup
@account = Account.new "Money Penny"
end
def test_deposit
flunk "write me"
end
def test_withdraw
flunk "write me"
end
# have fun and good luck...
end
More information about the Uw-ruby
mailing list