Skip to content
Open

Lab 6 #569

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions golang/lab6/lab6.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package lab6
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не ваш вариант, переделать


import "fmt"

type Rabbit struct {
Name string
Age int
Color string
}

func NewRabbit(name string, age int, color string) *Rabbit {
rabbit := new(Rabbit)
rabbit.Name = name
rabbit.Age = age
rabbit.Color = color
return rabbit
}

func (r Rabbit) GetName() string {
return r.Name
}

func (r *Rabbit) SetAge(age int) {
r.Age = age
}

func (r Rabbit) GetAge() int {
return r.Age
}

func Lab6() {
rabbit := NewRabbit("Шнафи", 3, "Чёрный")
fmt.Println(rabbit.GetAge())
fmt.Println(rabbit.GetName())
rabbit.SetAge(4)
fmt.Println(rabbit.GetAge())
}
2 changes: 2 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/lab4"
"isuct.ru/informatics2022/lab6"
)

func main() {
fmt.Println("Емельчиков Егор Павлович")
lab4.Lab4()
lab6.Lab6()
}
Loading