shape

package
v0.0.0-...-3662e1e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2020 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintShapeDetails

func PrintShapeDetails(shapes ...Shape)

A function that accepts the Shape interface as a variadic parameter The function will iterate over the Shape type and will execute each of its Name() and Area() methods

Types

type Rectangle

type Rectangle struct {
	Length float64
	Width  float64
}

func (Rectangle) Area

func (r Rectangle) Area() float64

Create the Area() and Name() methods for the rectangle struct type

func (Rectangle) Name

func (r Rectangle) Name() string

type Shape

type Shape interface {
	Area() float64
	Name() string
}

A Shape{} interface with two method sets called Area() float64 and Name() string

type Square

type Square struct {
	Side float64
}

func (Square) Area

func (s Square) Area() float64

Create the Area() and Name() methods for the square struct type

func (Square) Name

func (s Square) Name() string

type Triangle

type Triangle struct {
	Base   float64
	Height float64
}

Create struct types Each of the structs will satisfy the Shape{} interface

func (Triangle) Area

func (t Triangle) Area() float64

Create the Area() and Name() methods for the triangle structure type

func (Triangle) Name

func (t Triangle) Name() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL