1
0
mirror of https://github.com/MADTeacher/go_basics.git synced 2025-11-23 21:34:47 +02:00

отредактирована 3 глава

This commit is contained in:
Stanislav Chernyshev
2025-06-04 18:38:52 +03:00
parent 70656cfad8
commit f97178b439
64 changed files with 1751 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
package main
import (
"fmt"
"golang/factory/shape"
)
func main() {
rectangle := shape.NewRectangle(10, 6, shape.Point{X: 6, Y: -8}, "Gold")
fmt.Printf("%+v\n", *rectangle)
fmt.Printf("%+v\n", rectangle.GetName())
fmt.Printf("Perimeter = %+v\n", rectangle.GetPerimeter())
fmt.Printf("Area = %+v\n", rectangle.GetArea())
// меняем значения полей
rectangle.SetLength(15)
rectangle.SetWidth(7)
rectangle.SetColor("Green")
fmt.Printf("%+v\n", *rectangle)
fmt.Printf("New perimeter = %+v\n", rectangle.GetPerimeter())
fmt.Printf("New Area = %+v\n", rectangle.GetArea())
}