1
0
mirror of https://github.com/MADTeacher/go_basics.git synced 2025-11-23 21:34:47 +02:00
Files
go_basics/part_3/3.7/golang/factory/shape/rectangle.go

48 lines
809 B
Go
Raw Normal View History

package shape
type Rectangle struct {
shape // композиция
width uint
length uint
}
func (r *Rectangle) GetWidth() uint {
return r.width
}
func (r *Rectangle) GetLength() uint {
return r.length
}
func (r *Rectangle) SetWidth(width uint) {
r.width = width
}
func (r *Rectangle) SetLength(length uint) {
r.length = length
}
func (r *Rectangle) GetPerimeter() uint {
return (r.length + r.width) * 2
}
func (r *Rectangle) GetArea() float64 {
return float64(r.length * r.width)
}
func (r *Rectangle) GetName() string {
return "Super-puper " + r.shape.GetName()
}
func NewRectangle(width, length uint, center Point, color string) *Rectangle {
return &Rectangle{
shape: shape{
name: "Rectangle",
color: color,
center: center,
},
width: width,
length: length,
}
}