-
Notifications
You must be signed in to change notification settings - Fork 112
Laba7 #635
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
MaksimLahtin
wants to merge
19
commits into
ISUCT:Lahtin_maksim
Choose a base branch
from
MaksimLahtin:laba7
base: Lahtin_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
Laba7 #635
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a724a01
Added initial lab
MaksimLahtin 6440011
Added initial lab
MaksimLahtin 15dcd4e
Added initial lab
MaksimLahtin c12c2cd
Added initial lab
MaksimLahtin 20fc641
Added initial lab
MaksimLahtin bbca83e
Added initial lab
MaksimLahtin 328546c
Added initial lab
MaksimLahtin 407a665
Added initial lab
MaksimLahtin 576d790
Added initial lab
MaksimLahtin 7b69f2e
Added initial lab
MaksimLahtin cacfd80
Added initial lab
MaksimLahtin 19a9d06
Added initial lab
MaksimLahtin 547a0d1
Added initial lab
MaksimLahtin eaeae8e
Merge branch 'Lahtin_maksim' into laba7
MaksimLahtin 8b1145e
Update main.go
MaksimLahtin ae47bb6
Update main.go
MaksimLahtin 7a040a8
Update main.go
MaksimLahtin 3fce078
Update main.go
MaksimLahtin db0e355
Update main.go
MaksimLahtin 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package lab7 | ||
|
|
||
| type Car struct { | ||
| name string | ||
| price float64 | ||
| model string | ||
| color string | ||
|
|
||
| } | ||
|
|
||
| func (c *Car) GetName() string { | ||
| return c.name | ||
| } | ||
|
|
||
| func (c *Car) GetPrice() float64 { | ||
| return c.price | ||
| } | ||
|
|
||
| func (c *Car) SetPrice(price float64) { | ||
| c.price = price | ||
| } | ||
|
|
||
| func (c *Car) ApplyDiscount(discount float64) { | ||
| c.price -= c.price * discount / 100 | ||
| } |
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,24 @@ | ||
| package lab7 | ||
|
|
||
| type Fruit struct { | ||
| Name string | ||
| Price float64 | ||
| Freshness string | ||
| Color string | ||
| } | ||
|
|
||
| func (f *Fruit) GetName() string { | ||
| return f.Name | ||
| } | ||
|
|
||
| func (f Fruit) GetPrice() float64 { | ||
| return f.Price | ||
| } | ||
|
|
||
| func (f *Fruit) SetPrice(price float64) { | ||
| f.Price = price | ||
| } | ||
|
|
||
| func (f *Fruit) ApplyDiscount(discount float64) { | ||
| f.Price -= f.Price * discount / 100 | ||
| } |
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,24 @@ | ||
| package lab7 | ||
|
|
||
| type Mobile struct { | ||
| Name string | ||
| Price float64 | ||
| Brand string | ||
| Color string | ||
| } | ||
|
|
||
| func (m *Mobile) GetName() string { | ||
| return m.Name | ||
| } | ||
|
|
||
| func (m *Mobile) GetPrice() float64 { | ||
| return m.Price | ||
| } | ||
|
|
||
| func (m *Mobile) SetPrice(price float64) { | ||
| m.Price = price | ||
| } | ||
|
|
||
| func (m *Mobile) ApplyDiscount(discount float64) { | ||
| m.Price -= m.Price * discount / 100 | ||
| } |
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,8 @@ | ||
| package lab7 | ||
|
|
||
| type Product interface { | ||
| GetName() string | ||
| GetPrice() float64 | ||
| SetPrice(price float64) | ||
| ApplyDiscount(discount float64) | ||
| } |
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,24 @@ | ||
| package lab7 | ||
|
|
||
| import "fmt" | ||
|
|
||
| func GetTotalPrice(products []Product) float64 { | ||
| var TotalPrice float64 = 0 | ||
| for _, product := range products { | ||
| TotalPrice += product.GetPrice() | ||
| } | ||
| return TotalPrice | ||
| } | ||
|
|
||
| func Lab7() { | ||
| Mobile := &Mobile{"Айфон 11 pro max", 50000, "Iphone", "gold"} | ||
| Fruit := &Fruit{"Манго", 250, "свежее", "yellow"} | ||
| Car := &Car{"Reno Logan", 500000, "Reno", "black"} | ||
| products := []Product{Mobile, Fruit, Car} | ||
| fmt.Println("Стоимость без скидок:", GetTotalPrice(products)) | ||
|
|
||
| Mobile.ApplyDiscount(25) | ||
| Fruit.ApplyDiscount(40) | ||
| Car.ApplyDiscount(10) | ||
| fmt.Println("Стоимость после учёта скидки:", GetTotalPrice(products)) | ||
| } |
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,12 +1,13 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "isuct.ru/informatics2022/lab6" | ||
| "isuct.ru/informatics2022/lab4" | ||
|
|
||
| "fmt" | ||
|
|
||
| "isuct.ru/informatics2022/lab7" | ||
| ) | ||
| func main() { | ||
| fmt.Println("Лахтин Максим Сергеевич") | ||
| lab4.RunLab4() | ||
| lab6.RunLab6() | ||
| } | ||
| fmt.Println("Лаборатнорная 7:") | ||
| lab7.Lab7() | ||
| } | ||
|
|
||
Oops, something went wrong.
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.
прошлые лабы не нужно удалять