示例#1
0
文件: shape1.go 项目: asdfsx/goprj
func showShapeDetails(shape shapes.Shaper) {
	fmt.Print("fill=", shape.Fill(), " ")               // All shapes have a fill color
	if shape, ok := shape.(shapes.CircularShaper); ok { // shadow variable
		fmt.Print("radius=", shape.Radius(), " ")
		if shape, ok := shape.(shapes.RegularPolygonalShaper); ok { //shadow
			fmt.Print("sides=", shape.Sides(), " ")
		}
	}
	fmt.Println()
}
示例#2
0
文件: shape1.go 项目: asdfsx/goprj
func sanityCheck(name string, shape shapes.Shaper) {
	fmt.Print("name=", name, " ")
	fmt.Print("fill=", shape.Fill(), " ")
	if shape, ok := shape.(shapes.CircularShaper); ok {
		fmt.Print("radius=", shape.Radius(), " ")
		if shape, ok := shape.(shapes.RegularPolygonalShaper); ok {
			fmt.Print("sides=", shape.Sides(), " ")
		}
	}
	fmt.Println()
}