This repository has been archived on 2021-09-07. You can view files and clone it, but cannot push or open issues or pull requests.

35 lines
474 B
Go
Raw Normal View History

2018-01-01 17:05:45 +03:00
package composition
import (
"fmt"
)
type Car struct {
WheelCount uint8
Speed int
DoorCount uint8
Brand string
}
func (c *Car) Drive() {
fmt.Println("Goes with speed: %d", c.Speed)
}
type FlyingCar struct {
Car
WingLength float32
FlySpeed int
}
func (c *FlyingCar) Fly() {
fmt.Println("Flies with speed: %d", c.FlySpeed)
}
type SwimmingCar struct {
Car
SwimSpeed int
}
func (c *SwimmingCar) Swimm() {
fmt.Println("Swimm with speed: %d", c.SwimSpeed)
}