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