Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Fruit
- attr_accessor :color, :type
- attr_reader :total_price
- def initialize(color, type, amount, unit_price)
- @color = color
- @type = type
- @total_price = amount * unit_price
- end
- def to_s
- "Color: #{self.color}; Type: #{self.type}; Total price: #{self.total_price}"
- end
- end
- pear = Fruit.new 'green', :pear, 3, 10
- puts pear
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement