github.com/EngineerKamesh/gofullstack@v0.0.0-20180609171605-d41341d7d4ee/volume1/section3/simpleshape/triangle.go (about)

     1  package simpleshape
     2  
     3  type Triangle struct {
     4  	base   float64
     5  	height float64
     6  }
     7  
     8  func NewTriangle(b float64, h float64) *Triangle {
     9  	return &Triangle{base: b, height: h}
    10  }
    11  
    12  func (t *Triangle) Area() float64 {
    13  	return (t.base * t.height) / 2
    14  }