Skip to content
Open

Lab6 #607

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
31 changes: 31 additions & 0 deletions golang/lab6/Hero.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package lab6

type Hero struct {
name string
class string
lvl float64
}

func (h *Hero) SetName(name string) {
h.name = name
}

func (h *Hero) GetName() string {
return h.name
}

func (h *Hero) SetClass(class string) {
h.class = class
}

func (h *Hero) GetClass() string {
return h.class
}

func (h *Hero) SetLvl(lvl float64) {
h.lvl = lvl
}

func (h *Hero) GetLvl() float64 {
return h.lvl
}
20 changes: 20 additions & 0 deletions golang/lab6/lab6.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package lab6

import "fmt"

func Lab6() {
Hero1 := Hero{
name: "Иван",
class: "Человек",
lvl: 12,
}
fmt.Println("Старое имя:", Hero1.GetName())
Hero1.SetName("Вася")
fmt.Println("Новое имя:", Hero1.GetName())
fmt.Println("Старый класс", Hero1.GetClass())
Hero1.SetClass("Робот")
fmt.Println("Новый класс:", Hero1.GetClass())
fmt.Println("Старый уровент:", Hero1.GetLvl())
Hero1.SetLvl(15)
fmt.Println("Новый уровень:", Hero1.GetLvl())
}
5 changes: 4 additions & 1 deletion golang/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import (
"fmt"

"isuct.ru/informatics2022/lab4"

"isuct.ru/informatics2022/lab6"
)

func main() {
lab4.Lab4()
Copy link
Collaborator

Choose a reason for hiding this comment

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

не нужно убирать прошлые лабы

fmt.Println("Нерабеев Кирилл Сергеевич")
lab4.Lab4()
lab6.Lab6()
}
Loading