calculator.go   A
last analyzed

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
cc 4
eloc 10
dl 0
loc 18
ccs 4
cts 4
cp 1
crap 4
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A money.*calculator.add 0 2 1
A money.*calculator.multiply 0 2 1
A money.*calculator.allocate 0 2 1
A money.*calculator.subtract 0 2 1
1
package money
2
3
type calculator struct{}
4
5
func (c *calculator) add(a, b *Amount) *Amount {
6 1
	return &Amount{a.Value() + b.Value()}
7
}
8
9
func (c *calculator) subtract(a, b *Amount) *Amount {
10 1
	return &Amount{a.Value() - b.Value()}
11
}
12
13
func (c *calculator) multiply(a *Amount, m int64) *Amount {
14 1
	return &Amount{a.Value() * m}
15
}
16
17
func (c *calculator) allocate(a *Amount, ratio, total int) *Amount {
18 1
	return &Amount{a.Value() * int64(ratio) / int64(total)}
19
}
20