mirror of
https://github.com/MADTeacher/go_basics.git
synced 2025-11-23 21:34:47 +02:00
отредактирована 3 глава
This commit is contained in:
36
part_3/3.4/golang/factory/shape/shape.go
Normal file
36
part_3/3.4/golang/factory/shape/shape.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package shape
|
||||
|
||||
type Point struct {
|
||||
X int
|
||||
Y int
|
||||
}
|
||||
|
||||
type Shape struct {
|
||||
Name string
|
||||
Center Point
|
||||
color string
|
||||
}
|
||||
|
||||
func (s *Shape) SetColor(color string) {
|
||||
s.color = color
|
||||
}
|
||||
|
||||
func (s *Shape) GetColor() string {
|
||||
return s.color
|
||||
}
|
||||
|
||||
func NewShape(name, color string, x, y int) Shape {
|
||||
return Shape{
|
||||
Name: name,
|
||||
color: color,
|
||||
Center: Point{X: x, Y: y},
|
||||
}
|
||||
}
|
||||
|
||||
func NewShapeWithPoint(name, color string, center Point) *Shape {
|
||||
return &Shape{
|
||||
Name: name,
|
||||
color: color,
|
||||
Center: center,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user