Skip to content
Open
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Вот сюда нужно будет в первой работе с гитом добавит свое ФИО

## ФИО
## Киселев Максим Алексеевич

## Работа с репозиторием

Expand All @@ -26,5 +26,5 @@
```

```python
print("Hello world")
print("Киселев Максим")
```
42 changes: 42 additions & 0 deletions golang/LAB_4/LAB_4.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package Lab4

import (
"fmt"
"math"
)

func Calculate(a, b, x float64) float64 {
numerator := (a * math.Sqrt(x)) - (b * (math.Log(x) / math.Log(5)))
denominator := math.Log10(math.Abs(x - 1))
return numerator / denominator
}

func TaskA(a, b, xStart, xEnd, xStep float64) []float64 {
var YValues []float64
for x := xStart; x <= xEnd; x += xStep {
YValues = append(YValues, Calculate(a, b, x))
}
return YValues
}

func TaskB(a, b float64, xValues []float64) []float64 {
var YValues []float64
for _, x := range xValues {
YValues = append(YValues, Calculate(a, b, x))
}
return YValues
}

func RunLab4() {
a := 4.1
b := 2.7
xStart := 1.2
xEnd := 5.2
xStep := 0.8
var xValues []float64 = []float64{1.84, 2.71, 3.81, 4.56, 5.62}
var resultA []float64 = TaskA(a, b, xStart, xEnd, xStep)
var resultB []float64 = TaskB(a, b, xValues)

fmt.Println("задача A", resultA)
fmt.Println("задача B", resultB)
}
45 changes: 45 additions & 0 deletions golang/Lab_6/Lab_6.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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.

  1. Работник (Employee - дата примема на работу) вот ваш вариант, не благодарите


import (
"fmt"
"strconv"
)

type Character struct {
Name string
Class string
Level int
}

func (c *Character) SetName(name string) {
c.Name = name
}
func (c *Character) SetClass(class string) {
c.Class = class
}
func (c *Character) SetLevel(level int) {
if level > 0 {
c.Level = level
} else {
fmt.Println("ошибка: уровень > 0")
}
}
func (character Character) GetInfo() string {
return "имя: " + character.Name + "\nкласс: " + character.Class + "\nуровень: " + strconv.Itoa(character.Level)
}
func NewCharacter(name string, class string, level int) Character {
return Character{
Name: name,
Class: class,
Level: level,
}
}
func RunLab6() {
character := NewCharacter("Рикимару Сафронович", "воин", 10)
fmt.Println(character.GetInfo())
character.SetName("Инвокер Павлович")
character.SetClass("Маг")
character.SetLevel(15)
fmt.Println(character.GetInfo())
character.SetLevel(-5)
}
28 changes: 28 additions & 0 deletions golang/Lab_7/Bicycle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package Lab7

type Bicycle struct {
Name string
Brand string
Price float64
BikeType string
}

func (b *Bicycle) GetName() string {
return b.Name
}

func (b *Bicycle) GetPrice() float64 {
return b.Price
}

func (b *Bicycle) SetPrice(price float64) {
b.Price = price
}

func (b *Bicycle) ApplyDiscount(discount float64) {
b.Price -= b.Price * discount / 100
}

func (b *Bicycle) ChangeBikeType(newBikeType string) {
b.BikeType = newBikeType
}
47 changes: 47 additions & 0 deletions golang/Lab_7/LAB_7.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package Lab7

import "fmt"

type Product interface {
GetName() string
GetPrice() float64
SetPrice(price float64)
ApplyDiscount(discount float64)
}

func Calculate(products []Product) float64 {
total := 0.0
for _, product := range products {
total += product.GetPrice()
}
return total
}

func RunLab7() {
shirt := &Shirt{
Name: "Классическая рубашка", Price: 3000.00, Brand: "GUCCI", Color: "Белый", Material: "Хлопок", Size: "M",
}
bicycle := &Bicycle{
Name: "Горный велосипед", Brand: "DOTA2", Price: 50000.00, BikeType: "Горный",
}

products := []Product{bicycle, shirt}
fmt.Println("Общая стоимость ", Calculate(products))
bicycle.ApplyDiscount(10)
shirt.ApplyDiscount(20)

fmt.Println("Общая стоимость товаров после применения скидок ", Calculate(products))

fmt.Println("Тип велосипеда ", bicycle.BikeType)
fmt.Println("Размер рубашки ", shirt.Size)

bicycle.ChangeBikeType("Дорожный")
shirt.ChangeColor("Синий")
shirt.ChangeMaterial("Лен")
shirt.ChangeSize("L")

fmt.Println("Тип велосипеда изменен на ", bicycle.BikeType)
fmt.Println("Цвет рубашки изменен на ", shirt.Color)
fmt.Println("Материал рубашки изменен на ", shirt.Material)
fmt.Println("Размер рубашки изменен на ", shirt.Size)
}
41 changes: 41 additions & 0 deletions golang/Lab_7/Shirt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package Lab7

type Shirt struct {
Name string
Price float64
Brand string
Color string
Material string
Size string
}

func (sh *Shirt) GetName() string {
return sh.Name
}

func (sh *Shirt) GetPrice() float64 {
return sh.Price
}

func (sh *Shirt) GetBrand() string {
return sh.Brand
}

func (sh *Shirt) SetPrice(price float64) {
sh.Price = price
}

func (sh *Shirt) ApplyDiscount(discount float64) {
sh.Price -= sh.Price * discount / 100
}

func (sh *Shirt) ChangeColor(newColor string) {
sh.Color = newColor
}
func (sh *Shirt) ChangeMaterial(newMaterial string) {
sh.Material = newMaterial
}

func (sh *Shirt) ChangeSize(newSize string) {
sh.Size = newSize
}
14 changes: 12 additions & 2 deletions golang/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
package main

import "fmt"
import (
"fmt"

Lab4 "isuct.ru/informatics2022/LAB_4"
Lab6 "isuct.ru/informatics2022/LAB_6"
Lab7 "isuct.ru/informatics2022/LAB_7"
)

func main() {
fmt.Println("Hello world")
fmt.Println("Максим Киселев")
Lab4.RunLab4()
Lab6.RunLab6()
Lab7.RunLab7()

}