编辑代码

class Ticket
    def initialize(venue, date, price)
        @venue = venue
        @date = date
        @price = price
    end

    def price
        @price
    end
    def set_price(amount)
        @price = amount
    end
    def price=(amount)
        @price = amount
    end
end

th = Ticket.new("Town Hall", "11/12/13", 63.00)
puts th.price
th.set_price(123.00)
puts "$#{"%.2f" % th.price}"
th.price=(23)
puts "$"+sprintf("%.3f", th.price)