From: misterparker@... Date: 2008-07-16T22:35:20+09:00 Subject: Re: check my class On Jul 16, 2:23 am, Frederick Cheung wrote: > > Because your file probably used tabs (the convention usually to use > soft tabs instead, 2 spaces per tab). > In an interactive session with irb tab means auto complete so pasting > a document with tabs in it won't end well. > Don't know if you can set textedit to use spaces instead of tabs. > > Fred > Perfect fix. thanks Here's the my first functioning class. class Item attr_reader :cash, :salesTaxPayable, :salesCount, :sales def initialize(item,price,cost) @item, @price, @cost = [item, price, cost] @sales = @salesCount = @cash = @salesTaxPayable = 0 @tax = 0.06 @unCoveredCost = cost end def sale(discount_price = false, qty = 1) if discount_price == false then @salesTaxPayable += ((@price*qty) * @tax) @sales += (@price - ((@price*qty)*@tax)) @cash += @price*qty @unCoveredCost -= ((@price*qty) - ((@price*qty)*@tax)) else @salesTaxPayable += (@price*@tax) @sales = @sales + ((discount_price*qty) - ((discount_price*qty)*@tax)) @cash = @cash + (discount_price*qty) @remainingCost = @unCoveredCost - ((discount_price*qty) - ((discount_price*qty)*@tax)) end @salesCount += 1 end end (changed all the tabs to spaces) Hurray. And it worked for what i needed. temporary cash register haha Tell me what you think about making a variable for the repeated calculations...Michael said it was better to just do the calcs as they are needed? so i did. i'm trying to learn the "ruby way" of making things simpler and more elegant