28 lines
385 B
Ruby
28 lines
385 B
Ruby
class Checkout
|
|
class InvalidItem < StandardError; end
|
|
|
|
AVAILABLE_ITEMS = {
|
|
PI5: 60.00,
|
|
ZERO2W: 15.00,
|
|
PICO2: 4.00
|
|
}
|
|
|
|
def initialize
|
|
@items = []
|
|
end
|
|
|
|
def add(item)
|
|
raise InvalidItem unless valid_item(item)
|
|
@items.push item
|
|
end
|
|
|
|
def items
|
|
@items
|
|
end
|
|
|
|
private
|
|
|
|
def valid_item(item)
|
|
return AVAILABLE_ITEMS.keys.include?(item)
|
|
end
|
|
end |