This commit is contained in:
a.pivkin
2025-07-16 08:15:26 +03:00
parent cebbf27b3a
commit 0635aaa5ae
53 changed files with 76 additions and 4 deletions
+9
View File
@@ -0,0 +1,9 @@
package main
func add(a,b int) int {
return a + b
}
func Sub(a,b int) int {
return a - b
}
+3
View File
@@ -0,0 +1,3 @@
module Lec20
go 1.24.4
+14
View File
@@ -0,0 +1,14 @@
package main
import (
"Lec20/rectangle"
"fmt"
)
func main() {
// res := add(2,5)
// fmt.Println("Addition equals to ",res)
r := rectangle.New(10, 20, "green")
fmt.Println("Perimeter: ", r.Perimeter())
}
+14
View File
@@ -0,0 +1,14 @@
package rectangle
type Rect struct {
A,B int
color string
}
func New(newA int, newB int, newColor string) *Rect {
return &Rect{newA,newB,newColor}
}
func (r *Rect) Perimeter() int {
return 2 * (r.A + r.B)
}