Skip to content

Commit

Permalink
lab struct
Browse files Browse the repository at this point in the history
  • Loading branch information
BranchyDaddy committed Jan 17, 2024
1 parent 83f1a2a commit f535326
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 13 deletions.
23 changes: 23 additions & 0 deletions golang/character/character.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package character

import "fmt"

type Character struct {
Name string
Intellect int
Psyche int
Physique int
Motorics int
}

func (c *Character) SetName(name string) {
c.Name = name
}

func (c *Character) GetOverallPoints() int {
return c.Intellect + c.Psyche + c.Physique + c.Motorics
}

func (c *Character) PrintDetails() {
fmt.Printf("Name: %s\nIntellect: %d\nPsyche: %d\nPhysique: %d\nMotorics: %d\n", c.Name, c.Intellect, c.Psyche, c.Physique, c.Motorics)
}
38 changes: 25 additions & 13 deletions golang/main.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
package main
import (
"fmt"
"isuct.ru/informatics2022/internal"
)
func main() {
fmt.Println("Кувшинов Владислав")
fmt.Println(internal.CalculateFunctionInRanges(0.26, 0.66, 0.08))
fmt.Println(internal.CalculateFunctionWithXValues([]float64{0.1, 0.35, 0.4, 0.55, 0.6}))
}
package main

import (
"fmt"

"isuct.ru/informatics2022/character"
"isuct.ru/informatics2022/internal"
)

func main() {
fmt.Println("Кувшинов Владислав")
fmt.Println(internal.CalculateFunctionInRanges(0.26, 0.66, 0.08))
fmt.Println(internal.CalculateFunctionWithXValues([]float64{0.1, 0.35, 0.4, 0.55, 0.6}))

player := character.Character{Name: "Гарри Дюбуа", Intellect: 8, Psyche: 7, Physique: 6, Motorics: 5}

player.PrintDetails()

// Изменение имени персонажа
player.SetName("Диджей Миша")
fmt.Println("Имя персонажа после изменения:", player.Name)

// Вывод общей силы персонажа
power := player.GetOverallPoints()
fmt.Println("Общая сила персонажа:", power)
}

0 comments on commit f535326

Please sign in to comment.