本程序计算一个组织机构的净收益。假设这个虚构的组织所获得的收入来源于两个项目:fixed billing 和 time and material。该组织的净收益等于这两个项目的收入总和。
GO的代码摘自《GO语言中文网》的GO系列教程。我转化成F#。通过对比,体会这两种语言各自的特点及它们有趣的共性。
GO:
type Income interface {
calculate() int
source() string
}
type FixedBilling struct {
projectName string
biddedAmount int
}
type TimeAndMaterial struct {
projectName string
noOfHours int
hourlyRate int
}
func (fb FixedBilling) calculate() int {
return fb.biddedAmount
}
func (fb FixedBilling) source() string {