Skip to content

Commit

Permalink
lab5
Browse files Browse the repository at this point in the history
  • Loading branch information
kokter committed Dec 24, 2023
1 parent 9026efd commit 2f4d62d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
29 changes: 29 additions & 0 deletions golang/internal/lab5/lab5.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package lab5

import "fmt"

type cat struct {
age uint64
breed string
name string
}

func CreateStruct(age uint64, breed, name string) cat {
return cat{age, breed, name}
}

func SetAge(new_age uint64, c *cat) uint64 {
c.age = new_age
return c.age
}
func SetBreed(new_breed string, c *cat) string {
c.breed = new_breed
return c.breed
}
func SetName(new_name string, c *cat) string {
c.name = new_name
return c.name
}
func PrintInfCat(c *cat) {
fmt.Println("Cat's name is", c.name, "\nCat's breed is", c.breed, "\nCat's age is", c.age, "\n")

Check failure on line 28 in golang/internal/lab5/lab5.go

View workflow job for this annotation

GitHub Actions / lint

printf: `fmt.Println` arg list ends with redundant newline (govet)
}
10 changes: 10 additions & 0 deletions golang/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"fmt"

"isuct.ru/informatics2022/internal/lab4"
"isuct.ru/informatics2022/internal/lab5"
)

func main() {
fmt.Println("lab 4")
a := 2.25
Xs := 1.2
Xe := 2.7
Expand All @@ -22,4 +24,12 @@ func main() {
for i := range y {
fmt.Println("При x=", x[i], "y=", y[i])
}
// lab 5
fmt.Println("lab 5")
cat := lab5.CreateStruct(5, "Siamese", "Alice")
lab5.PrintInfCat(&cat)
lab5.SetAge(7, &cat)
lab5.SetBreed("British", &cat)
lab5.SetName("Oleg", &cat)
lab5.PrintInfCat(&cat)
}

0 comments on commit 2f4d62d

Please sign in to comment.