Getting this when running program
customerbill.rb:28:语法错误,意外的tIVAR,预计输入结束。我试图计算一个红宝石餐厅检查。Ruby语法错误,意外的tIVAR,预计输入结束
class CustomerBill
class Bill < CustomerBill
def initalize (burgers, drinks, subtotal)
@burgers = 6.95 * 5
@drinks = 1.75 * 4
@meal = @burgers + @drinks
@totalBill = @meal + @taxAmount + @tipAmount
end
末
class CustomerTax < CustomerBill
def initalize (tax, taxAmount, totalWithTax)
@tax = 0.0825
@taxAmount = @meal * @tax
@totalWithTax = @meal + @tax
end
末
class CustomerTip
def initalize (tipRate, tipAmount)
@tipRate = 0.15
@tipAmount = @totalWithTax * @tipRate
end
末
puts "Total meal charge #{@meal}"
puts "Tax amount #{@taxAmount}"
puts "Tip amount #{@tipAmount}"
puts "Total bill #{@totalBill}"
这将是超级,如果你可以重新格式化,以便适当的东西被标记为代码。 :)另外,如果这是实际的代码,那里有非常多的结束。 :) – 2015-02-07 19:36:31
真的不清楚你想要做什么。您在结束语中肯定会遇到一些问题,但不止于此。例如,您是否真的希望在CustomerBill内部定义账单类? – nPn 2015-02-07 19:37:44
@DavidHoelzer从格式化很难判断,但实际上并没有足够的_ends_。 – 2015-02-07 20:57:09