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("Богатов Антон Николаевич")
```
46 changes: 46 additions & 0 deletions golang/lab4/Laba4.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package LABA4

import (
"fmt"
"math"
)

func CalculateY(a, b, x float64) float64 {
numerator := math.Cbrt(a*x + b)
denominator := math.Pow(math.Log10(x), 2)
return numerator / denominator
}

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

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

func Lab4() {
a := 1.35
b := 0.98

fmt.Println("Задача A")
xStartA := 1.14
xEndA := 4.24
dxA := 0.62
resultA := TaskA(a, b, xStartA, xEndA, dxA)

fmt.Println("\nЗадача B")
xValuesB := []float64{0.35, 1.28, 3.51, 5.21, 4.16}
resultB := TaskB(a, b, xValuesB)

fmt.Println(resultA)
fmt.Println(resultB)
}
37 changes: 37 additions & 0 deletions golang/lab6/Laba6.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package LABA6

import "fmt"

type Fox struct {
Name string
Age int
Color string
}

func NewFox(name string, age int, color string) *Fox {
return &Fox{
Name: name,
Age: age,
Color: color,
}
}

func (f *Fox) GetView() string {
return " /\\ /\\\n" +
" ( o o )\n" +
" \\ ^ / \n" +
" | | \n" +
" / \\ \n" +
" / \\ \n" +
" / | | \\ \n" +
"( | | )"
}
func (f *Fox) Describe() string {
return fmt.Sprintf("Имя лисы: %s, возраст: %d года, цвет: %s.", f.Name, f.Age, f.Color)
}

func Lab6() {
fox := NewFox("Феликс", 3, "рыжий")
fmt.Println(fox.Describe())
fmt.Println(fox.GetView())
}
28 changes: 28 additions & 0 deletions golang/lab7/Dress.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package LABA7

type Dress struct {
Name string
Price float64
Brand string
Color string
}

func (d *Dress) GetName() string {
return d.Name
}

func (d *Dress) GetPrice() float64 {
return d.Price
}

func (d *Dress) SetPrice(price float64) {
d.Price = price
}

func (d *Dress) ApplyDiscount(discount float64) {
d.Price = d.Price * (1 - discount/100)
}

func (d *Dress) ChangeColor(newColor string) {
d.Color = newColor
}
34 changes: 34 additions & 0 deletions golang/lab7/Laba6.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package LABA7

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 Lab7() {
dress := &Dress{"платье вечернее", 8000.00, "Zara", "красный"}
wardrobe := &Wardrobe{"шкаф для одежды", 15000.00, "IKEA", "белый"}
products := []Product{dress, wardrobe}
fmt.Println("общая стоимость", Calculate(products))
dress.ApplyDiscount(10)
wardrobe.ApplyDiscount(5)
fmt.Println("общая стоимость товаров после применения скидок", Calculate(products))
fmt.Println("цвет платья:", dress.Color)
fmt.Println("цвет шкафа:", wardrobe.Color)
dress.ChangeColor("черный")
wardrobe.ChangeColor("коричневый")
fmt.Println("цвет платья изменен на:", dress.Color)
fmt.Println("цвет шкафа изменен на:", wardrobe.Color)
}
28 changes: 28 additions & 0 deletions golang/lab7/Wardrobe.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package LABA7

type Wardrobe struct {
Name string
Price float64
Brand string
Color string
}

func (w *Wardrobe) GetName() string {
return w.Name
}

func (w *Wardrobe) GetPrice() float64 {
return w.Price
}

func (w *Wardrobe) SetPrice(price float64) {
w.Price = price
}

func (w *Wardrobe) ApplyDiscount(discount float64) {
w.Price = w.Price * (1 - discount/100)
}

func (w *Wardrobe) ChangeColor(newColor string) {
w.Color = newColor
}
13 changes: 11 additions & 2 deletions golang/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
package main

import "fmt"
import (
"fmt"

LABA4 "isuct.ru/informatics2022/lab4"
LABA6 "isuct.ru/informatics2022/lab6"
LABA7 "isuct.ru/informatics2022/lab7"
)

func main() {
fmt.Println("Hello world")
fmt.Println("Богатов Антон Николаевич")
LABA4.Lab4()
LABA6.Lab6()
LABA7.Lab7()
}
Loading