Пример #1
0
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
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()
}