-
Notifications
You must be signed in to change notification settings - Fork 112
Labs3-7 #604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
maksim228666
wants to merge
3
commits into
ISUCT:Kiselev_Maksim
Choose a base branch
from
maksim228666:labs3-7
base: Kiselev_Maksim
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Labs3-7 #604
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package Lab6 | ||
|
|
||
| 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) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() | ||
|
|
||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.