new tasks
This commit is contained in:
parent
2a4d27cea0
commit
80737d5a6a
1194 changed files with 15353 additions and 1 deletions
26
Task/Classes/Go/classes-2.go
Normal file
26
Task/Classes/Go/classes-2.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import reflect
|
||||
|
||||
type happinessTester interface {
|
||||
happy() bool
|
||||
}
|
||||
|
||||
type bottleOfWine struct {
|
||||
USD float64
|
||||
empty bool
|
||||
}
|
||||
|
||||
func (b *bottleOfWine) happy() bool {
|
||||
return b.USD > 10 && !b.empty
|
||||
}
|
||||
|
||||
func main() {
|
||||
partySupplies := []happinessTester{
|
||||
&picnicBasket{2, true},
|
||||
&bottleOfWine{USD: 6},
|
||||
}
|
||||
for _, ps := range partySupplies {
|
||||
fmt.Printf("%s: happy? %t\n",
|
||||
reflect.Indirect(reflect.ValueOf(ps)).Type().Name(),
|
||||
ps.happy())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue