Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 29 lines (13 sloc) 0.38 kB
534782d @hectorcorrea First commit
authored
1 class TaxCalculator
79827f4 @hectorcorrea switched tabs to spaces
authored
2 tax = 0
534782d @hectorcorrea First commit
authored
3
79827f4 @hectorcorrea switched tabs to spaces
authored
4 constructor: (tax) ->
5 this.tax = tax
534782d @hectorcorrea First commit
authored
6
79827f4 @hectorcorrea switched tabs to spaces
authored
7 taxAmount: (price) -> price * (this.tax/100)
534782d @hectorcorrea First commit
authored
8
79827f4 @hectorcorrea switched tabs to spaces
authored
9 totalPrice: (price) -> price + (price * (this.tax/100))
534782d @hectorcorrea First commit
authored
10
11
57623ac @hectorcorrea minor tweaks
authored
12 calc = new TaxCalculator(20)
534782d @hectorcorrea First commit
authored
13 price = 100
14 tax = calc.taxAmount(price)
15 total = calc.totalPrice(price)
16
17 console.log "price $#{price}"
18 console.log "tax $ #{tax}"
19 console.log "total $#{total}"
d3c1743 @hectorcorrea last tweaks before PSU Web Conference
authored
20
21
22
23
24
25
26
27
28
Something went wrong with that request. Please try again.