master
 1package main
 2
 3import (
 4	"math"
 5)
 6
 7func Perimeter(rectangle Rectangle) float64 {
 8	return 2 * (rectangle.Width + rectangle.Height)
 9}
10
11type Shape interface {
12	Area() float64
13}
14
15type Rectangle struct {
16	Width  float64
17	Height float64
18}
19
20func (r Rectangle) Area() float64 {
21	return r.Width * r.Height
22}
23
24type Circle struct {
25	Radius float64
26}
27
28func (c Circle) Area() float64 {
29	return math.Pi * c.Radius * c.Radius
30}
31
32type Triangle struct {
33	Base   float64
34	Height float64
35}
36
37func (t Triangle) Area() float64 {
38	return (t.Base * t.Height) * 0.5
39}