From 71d8a267b3a0d8bd7b3e005088dd009269738447 Mon Sep 17 00:00:00 2001 From: Uhizaki Date: Wed, 27 Nov 2024 12:38:43 +0300 Subject: [PATCH 01/10] lab7 --- golang/lab7/Cosmetic.go | 28 +++++++++++++++++++++++++++ golang/lab7/Sweets.go | 27 ++++++++++++++++++++++++++ golang/lab7/lab7.go | 43 +++++++++++++++++++++++++++++++++++++++++ golang/lab7/technic.go | 27 ++++++++++++++++++++++++++ golang/main.go | 2 ++ 5 files changed, 127 insertions(+) create mode 100644 golang/lab7/Cosmetic.go create mode 100644 golang/lab7/Sweets.go create mode 100644 golang/lab7/lab7.go create mode 100644 golang/lab7/technic.go diff --git a/golang/lab7/Cosmetic.go b/golang/lab7/Cosmetic.go new file mode 100644 index 00000000..c8f5564e --- /dev/null +++ b/golang/lab7/Cosmetic.go @@ -0,0 +1,28 @@ +package lab7 +import "fmt" + +type Cosmetic struct { + Name string + Brend string + Price float32 +} + +func (c Cosmetic) GetInformation() { + fmt.Println("У нас есть в наличии", c.Name, "из бренда", c.Brend, "и стоит", c.Price) +} + +func (c Cosmetic) GetPrice() float32 { + return c.Price +} + +func (c *Cosmetic) Sale(x float32) { + (*c).Price = (c.Price / 100) * (100 - x) +} + +func (c *Cosmetic) ChangePrice(x float32) { + (*c).Price = x +} + +func (c *Cosmetic) ChangeDescription(x string) { + (*c).Brend = x +} diff --git a/golang/lab7/Sweets.go b/golang/lab7/Sweets.go new file mode 100644 index 00000000..cb9ff6d9 --- /dev/null +++ b/golang/lab7/Sweets.go @@ -0,0 +1,27 @@ +package lab7 +import "fmt" +type Sweets struct { + Name string + Taste string + Price float32 +} + +func (s Sweets) GetInformation() { + fmt.Println("У нас есть в наличии", s.Name, "вкуса", s.Taste, "стоимостью", s.Price) +} + +func (s Sweets) GetPrice() float32 { + return s.Price +} + +func (s *Sweets) Sale(x float32) { + (*s).Price = (s.Price / 100) * (100 - x) +} + +func (s *Sweets) ChangePrice(x float32) { + (*s).Price = x +} + +func (s *Sweets) ChangeDescription(x string) { + (*s).Taste = x +} diff --git a/golang/lab7/lab7.go b/golang/lab7/lab7.go new file mode 100644 index 00000000..80330282 --- /dev/null +++ b/golang/lab7/lab7.go @@ -0,0 +1,43 @@ +package lab7 + +import "fmt" + +type Product interface { + GetInformation() + GetPrice() float32 + Sale(float32) + ChangePrice(float32) + ChangeDescription(string) +} + + +func CalculateBue(list []Product) float32 { + var sum float32 = 0 + for _, price := range list { + sum += price.GetPrice() + } + return sum +} + +func RunLab7Tasks() { + var interface_cosmetic Product = &Cosmetic{"помада", "Gucci", 5000} + var interface_techcic Product = &Technic{"ноутбук", "Apple", 169660} + var interface_sweets Product = &Sweets{"Сникерс", "Солёная карамель", 85} + interface_cosmetic.GetInformation() + interface_techcic.GetInformation() + interface_sweets.GetInformation() + var bue []Product = []Product{interface_cosmetic, interface_techcic, interface_sweets} + sum := CalculateBue(bue) + fmt.Println("Товары стоят",sum) + interface_techcic.ChangePrice(150000) + interface_cosmetic.ChangeDescription("LV") + interface_cosmetic.Sale(5) + interface_sweets.Sale(60) + interface_sweets.ChangeDescription("Белый шоколад") + interface_techcic.GetInformation() + interface_cosmetic.GetInformation() + interface_sweets.GetInformation() + + sum = CalculateBue(bue) + fmt.Println("Товары стоят",sum) +} \ No newline at end of file diff --git a/golang/lab7/technic.go b/golang/lab7/technic.go new file mode 100644 index 00000000..7f6d43cb --- /dev/null +++ b/golang/lab7/technic.go @@ -0,0 +1,27 @@ +package lab7 +import "fmt" +type Technic struct { + Name string + Brend string + Price float32 +} + +func (t Technic) GetInformation() { + fmt.Println("У нас есть в наличии", t.Name, "от компании", t.Brend, "и стоит", t.Price) +} + +func (t Technic) GetPrice() float32 { + return t.Price +} + +func (t *Technic) Sale(x float32) { + (*t).Price = (t.Price / 100) * (100 - x) +} + +func (t *Technic) ChangePrice(x float32) { + (*t).Price = x +} + +func (t *Technic) ChangeDescription(x string) { + (*t).Brend = x +} \ No newline at end of file diff --git a/golang/main.go b/golang/main.go index 71c1bbcd..3494e7d8 100644 --- a/golang/main.go +++ b/golang/main.go @@ -5,6 +5,7 @@ import ( "fmt" "isuct.ru/informatics2022/lab4" "isuct.ru/informatics2022/lab6" + "isuct.ru/informatics2022/lab7" ) @@ -12,4 +13,5 @@ func main() { fmt.Println("Рукина Полина Владимировна") lab4.RunLab4Tasks() lab6.Runlab6() + lab7.RunLab7Tasks() } \ No newline at end of file From d65b63edae4139ec94d09b9e3e87498d1d22368b Mon Sep 17 00:00:00 2001 From: Uhizaki Date: Wed, 27 Nov 2024 12:55:42 +0300 Subject: [PATCH 02/10] Lab7 --- golang/lab7/Informatics_2024 | 1 + 1 file changed, 1 insertion(+) create mode 160000 golang/lab7/Informatics_2024 diff --git a/golang/lab7/Informatics_2024 b/golang/lab7/Informatics_2024 new file mode 160000 index 00000000..ea3aab55 --- /dev/null +++ b/golang/lab7/Informatics_2024 @@ -0,0 +1 @@ +Subproject commit ea3aab550a1bc9d754d59d45399f2cacba72f8a3 From 2a896d4cbfa9ec8f5b14ec1bb060ba6252dbc68b Mon Sep 17 00:00:00 2001 From: rukinapolina Date: Wed, 18 Dec 2024 13:24:32 +0300 Subject: [PATCH 03/10] Update Cosmetic.go --- golang/lab7/Cosmetic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/golang/lab7/Cosmetic.go b/golang/lab7/Cosmetic.go index c8f5564e..c7ebe6bc 100644 --- a/golang/lab7/Cosmetic.go +++ b/golang/lab7/Cosmetic.go @@ -15,7 +15,7 @@ func (c Cosmetic) GetPrice() float32 { return c.Price } -func (c *Cosmetic) Sale(x float32) { +func (c *Cosmetic) ApplyDiscount(x float32) { (*c).Price = (c.Price / 100) * (100 - x) } From 97e13e6a6e833d69aba498999611223736cd15e6 Mon Sep 17 00:00:00 2001 From: rukinapolina Date: Wed, 18 Dec 2024 13:25:42 +0300 Subject: [PATCH 04/10] Update Sweets.go --- golang/lab7/Sweets.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/golang/lab7/Sweets.go b/golang/lab7/Sweets.go index cb9ff6d9..9c8798ab 100644 --- a/golang/lab7/Sweets.go +++ b/golang/lab7/Sweets.go @@ -14,7 +14,7 @@ func (s Sweets) GetPrice() float32 { return s.Price } -func (s *Sweets) Sale(x float32) { +func (s *Sweets) ApplyDiscount(x float32) { (*s).Price = (s.Price / 100) * (100 - x) } From f3854dd01ac7bbb3e1f5fea21f5c7fc53cd84329 Mon Sep 17 00:00:00 2001 From: rukinapolina Date: Wed, 18 Dec 2024 13:26:26 +0300 Subject: [PATCH 05/10] Update lab7.go --- golang/lab7/lab7.go | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/golang/lab7/lab7.go b/golang/lab7/lab7.go index 80330282..0bc9dc90 100644 --- a/golang/lab7/lab7.go +++ b/golang/lab7/lab7.go @@ -2,16 +2,16 @@ package lab7 import "fmt" -type Product interface { +type Products interface { GetInformation() GetPrice() float32 - Sale(float32) + ApplyDiscount(float32) ChangePrice(float32) ChangeDescription(string) } -func CalculateBue(list []Product) float32 { +func CalculateBuy(list []Products) float32 { var sum float32 = 0 for _, price := range list { sum += price.GetPrice() @@ -20,24 +20,24 @@ func CalculateBue(list []Product) float32 { } func RunLab7Tasks() { - var interface_cosmetic Product = &Cosmetic{"помада", "Gucci", 5000} - var interface_techcic Product = &Technic{"ноутбук", "Apple", 169660} - var interface_sweets Product = &Sweets{"Сникерс", "Солёная карамель", 85} - interface_cosmetic.GetInformation() - interface_techcic.GetInformation() - interface_sweets.GetInformation() - var bue []Product = []Product{interface_cosmetic, interface_techcic, interface_sweets} - sum := CalculateBue(bue) + var cosmetic Products = &Cosmetic{"помада", "Gucci", 5000} + var techcic Products = &Technic{"ноутбук", "Apple", 169660} + var sweets Products = &Sweets{"Сникерс", "Солёная карамель", 85} + cosmetic.GetInformation() + techcic.GetInformation() + sweets.GetInformation() + var buy []Products = []Products{cosmetic , techcic, sweets} + sum := CalculateBuy(buy) fmt.Println("Товары стоят",sum) - interface_techcic.ChangePrice(150000) - interface_cosmetic.ChangeDescription("LV") - interface_cosmetic.Sale(5) - interface_sweets.Sale(60) - interface_sweets.ChangeDescription("Белый шоколад") - interface_techcic.GetInformation() - interface_cosmetic.GetInformation() - interface_sweets.GetInformation() + techcic.ChangePrice(150000) + cosmetic.ChangeDescription("LV") + cosmetic.ApplyDiscount(5) + sweets.ApplyDiscount(60) + sweets.ChangeDescription("Белый шоколад") + techcic.GetInformation() + cosmetic.GetInformation() + sweets.GetInformation() - sum = CalculateBue(bue) + sum = CalculateBuy(buy) fmt.Println("Товары стоят",sum) -} \ No newline at end of file +} From 957f3528369a34d884a2ea98e02fad4d4e71859d Mon Sep 17 00:00:00 2001 From: rukinapolina Date: Wed, 18 Dec 2024 13:27:04 +0300 Subject: [PATCH 06/10] Update technic.go --- golang/lab7/technic.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/golang/lab7/technic.go b/golang/lab7/technic.go index 7f6d43cb..67d22d1e 100644 --- a/golang/lab7/technic.go +++ b/golang/lab7/technic.go @@ -14,7 +14,7 @@ func (t Technic) GetPrice() float32 { return t.Price } -func (t *Technic) Sale(x float32) { +func (t *Technic) ApplyDiscount(x float32) { (*t).Price = (t.Price / 100) * (100 - x) } @@ -24,4 +24,4 @@ func (t *Technic) ChangePrice(x float32) { func (t *Technic) ChangeDescription(x string) { (*t).Brend = x -} \ No newline at end of file +} From a51876b7d24f4d8e688b90ea516c47ffa02b2144 Mon Sep 17 00:00:00 2001 From: rukinapolina Date: Wed, 18 Dec 2024 13:28:25 +0300 Subject: [PATCH 07/10] Update main.go --- golang/main.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/golang/main.go b/golang/main.go index 3494e7d8..232912b8 100644 --- a/golang/main.go +++ b/golang/main.go @@ -1,4 +1,3 @@ - package main import ( @@ -14,4 +13,4 @@ func main() { lab4.RunLab4Tasks() lab6.Runlab6() lab7.RunLab7Tasks() -} \ No newline at end of file +} From f2ad707e4c22964fc5221eaff99f9255b9f25f1d Mon Sep 17 00:00:00 2001 From: rukinapolina Date: Fri, 20 Dec 2024 20:10:07 +0300 Subject: [PATCH 08/10] Merge branch 'Rukina_Polina' into lab6 --- golang/lab4/lab4.go | 72 ++++++++++++++--------------------------- golang/lab6/lab6.go | 2 +- golang/lab7/Cosmetic.go | 28 ++++++++++++++++ golang/lab7/Sweets.go | 27 ++++++++++++++++ golang/lab7/lab7.go | 43 ++++++++++++++++++++++++ golang/lab7/technic.go | 27 ++++++++++++++++ golang/main.go | 2 ++ 7 files changed, 153 insertions(+), 48 deletions(-) create mode 100644 golang/lab7/Cosmetic.go create mode 100644 golang/lab7/Sweets.go create mode 100644 golang/lab7/lab7.go create mode 100644 golang/lab7/technic.go diff --git a/golang/lab4/lab4.go b/golang/lab4/lab4.go index 1326cc5a..69edc658 100644 --- a/golang/lab4/lab4.go +++ b/golang/lab4/lab4.go @@ -1,54 +1,32 @@ -package lab4 -import ( +package lab4 + +import ( "math" + "fmt" ) - -func Calc(a float64, x float64) float64 { - return math.Tan(math.Pow(math.Log10(a+x), 3)) / math.Pow(a+x, 2.0/7.0) -} - -func TaskA(a float64, xi float64, xk float64, deltaX float64) []float64 { - values := []float64{} - for x := xi; x <= xk; x += deltaX { - values = append(values, Calc(a, x)) -func CalculateExpression (a float64, x float64) float64 { - return math.Tan(math.Pow(math.Log10(a+x), 3)) / math.Pow(a+x, 2.0/7.0) -} - -func TaskA(a , xi , xk , deltax float64) { - var values []float64 - for x := xi; x <= xk; x += deltaX { - values = append(values, CalculateExpression (a, x)) - } - return values -} - -func TaskB(a float64, x [5]float64) []float64 { - values := []float64{} - for _, value := range x { - values = append(values, Calc(a, value)) - } - return values - var values []float64{} +func CalculateExpression (a float64, x float64) float64 { + return math.Tan(math.Pow(math.Log10(a+x), 3)) / math.Pow(a+x, 2.0/7.0) +} + +func TaskA(a , xi , xk , deltax float64) []float64 { + var values []float64 + for x := xi; x <= xk; x += deltax { + values = append(values, CalculateExpression (a, x)) + } + return values +} + +func TaskB(a float64, x [5]float64) []float64 { + var values []float64 for _, value := range x { - values = append(values, CalculateExpression (a, value)) - } + values = append(values, CalculateExpression (a, value)) + } return values } func RunLab4Tasks() { - const a float64 = 2.0 - valuesA := TaskA(a, 1.08, 1.88, 0.16) - var slice = [5]float64{1.16, 1.35, 1.48, 1.52, 1.96} - valuesB := TaskB(a, slice) - - fmt.Println("Результаты TaskA:") - for _, value := range valuesA { - fmt.Println(value) - } - - fmt.Println("Результаты TaskB:") - for _, value := range valuesB { - fmt.Println(value) - } -} + a := 2.0 + fmt.Println(TaskA(a, 1.08, 1.88, 0.16)) + var s = [5]float64{1.16, 1.35, 1.48, 1.52, 1.96} + fmt.Println(TaskB(a,s)) +} \ No newline at end of file diff --git a/golang/lab6/lab6.go b/golang/lab6/lab6.go index 8a2f8269..ac1ef1f4 100644 --- a/golang/lab6/lab6.go +++ b/golang/lab6/lab6.go @@ -1,4 +1,4 @@ -package main +package lab6 import ( "fmt" diff --git a/golang/lab7/Cosmetic.go b/golang/lab7/Cosmetic.go new file mode 100644 index 00000000..c7ebe6bc --- /dev/null +++ b/golang/lab7/Cosmetic.go @@ -0,0 +1,28 @@ +package lab7 +import "fmt" + +type Cosmetic struct { + Name string + Brend string + Price float32 +} + +func (c Cosmetic) GetInformation() { + fmt.Println("У нас есть в наличии", c.Name, "из бренда", c.Brend, "и стоит", c.Price) +} + +func (c Cosmetic) GetPrice() float32 { + return c.Price +} + +func (c *Cosmetic) ApplyDiscount(x float32) { + (*c).Price = (c.Price / 100) * (100 - x) +} + +func (c *Cosmetic) ChangePrice(x float32) { + (*c).Price = x +} + +func (c *Cosmetic) ChangeDescription(x string) { + (*c).Brend = x +} diff --git a/golang/lab7/Sweets.go b/golang/lab7/Sweets.go new file mode 100644 index 00000000..9c8798ab --- /dev/null +++ b/golang/lab7/Sweets.go @@ -0,0 +1,27 @@ +package lab7 +import "fmt" +type Sweets struct { + Name string + Taste string + Price float32 +} + +func (s Sweets) GetInformation() { + fmt.Println("У нас есть в наличии", s.Name, "вкуса", s.Taste, "стоимостью", s.Price) +} + +func (s Sweets) GetPrice() float32 { + return s.Price +} + +func (s *Sweets) ApplyDiscount(x float32) { + (*s).Price = (s.Price / 100) * (100 - x) +} + +func (s *Sweets) ChangePrice(x float32) { + (*s).Price = x +} + +func (s *Sweets) ChangeDescription(x string) { + (*s).Taste = x +} diff --git a/golang/lab7/lab7.go b/golang/lab7/lab7.go new file mode 100644 index 00000000..0bc9dc90 --- /dev/null +++ b/golang/lab7/lab7.go @@ -0,0 +1,43 @@ +package lab7 + +import "fmt" + +type Products interface { + GetInformation() + GetPrice() float32 + ApplyDiscount(float32) + ChangePrice(float32) + ChangeDescription(string) +} + + +func CalculateBuy(list []Products) float32 { + var sum float32 = 0 + for _, price := range list { + sum += price.GetPrice() + } + return sum +} + +func RunLab7Tasks() { + var cosmetic Products = &Cosmetic{"помада", "Gucci", 5000} + var techcic Products = &Technic{"ноутбук", "Apple", 169660} + var sweets Products = &Sweets{"Сникерс", "Солёная карамель", 85} + cosmetic.GetInformation() + techcic.GetInformation() + sweets.GetInformation() + var buy []Products = []Products{cosmetic , techcic, sweets} + sum := CalculateBuy(buy) + fmt.Println("Товары стоят",sum) + techcic.ChangePrice(150000) + cosmetic.ChangeDescription("LV") + cosmetic.ApplyDiscount(5) + sweets.ApplyDiscount(60) + sweets.ChangeDescription("Белый шоколад") + techcic.GetInformation() + cosmetic.GetInformation() + sweets.GetInformation() + + sum = CalculateBuy(buy) + fmt.Println("Товары стоят",sum) +} diff --git a/golang/lab7/technic.go b/golang/lab7/technic.go new file mode 100644 index 00000000..67d22d1e --- /dev/null +++ b/golang/lab7/technic.go @@ -0,0 +1,27 @@ +package lab7 +import "fmt" +type Technic struct { + Name string + Brend string + Price float32 +} + +func (t Technic) GetInformation() { + fmt.Println("У нас есть в наличии", t.Name, "от компании", t.Brend, "и стоит", t.Price) +} + +func (t Technic) GetPrice() float32 { + return t.Price +} + +func (t *Technic) ApplyDiscount(x float32) { + (*t).Price = (t.Price / 100) * (100 - x) +} + +func (t *Technic) ChangePrice(x float32) { + (*t).Price = x +} + +func (t *Technic) ChangeDescription(x string) { + (*t).Brend = x +} diff --git a/golang/main.go b/golang/main.go index 37eadfe7..232912b8 100644 --- a/golang/main.go +++ b/golang/main.go @@ -4,6 +4,7 @@ import ( "fmt" "isuct.ru/informatics2022/lab4" "isuct.ru/informatics2022/lab6" + "isuct.ru/informatics2022/lab7" ) @@ -11,4 +12,5 @@ func main() { fmt.Println("Рукина Полина Владимировна") lab4.RunLab4Tasks() lab6.Runlab6() + lab7.RunLab7Tasks() } From 33969e456b65b72a940bbb1ded186a970cd1b02a Mon Sep 17 00:00:00 2001 From: rukinapolina Date: Fri, 20 Dec 2024 20:34:18 +0300 Subject: [PATCH 09/10] Revert "Lab7" This reverts commit d65b63edae4139ec94d09b9e3e87498d1d22368b. --- golang/lab7/Informatics_2024 | 1 + 1 file changed, 1 insertion(+) create mode 160000 golang/lab7/Informatics_2024 diff --git a/golang/lab7/Informatics_2024 b/golang/lab7/Informatics_2024 new file mode 160000 index 00000000..ea3aab55 --- /dev/null +++ b/golang/lab7/Informatics_2024 @@ -0,0 +1 @@ +Subproject commit ea3aab550a1bc9d754d59d45399f2cacba72f8a3 From d25c649fc76d85701dfc49d1852d968e715360a5 Mon Sep 17 00:00:00 2001 From: rukinapolina Date: Fri, 20 Dec 2024 23:51:52 +0300 Subject: [PATCH 10/10] deleted --- golang/lab7/Informatics_2024 | 1 - 1 file changed, 1 deletion(-) delete mode 160000 golang/lab7/Informatics_2024 diff --git a/golang/lab7/Informatics_2024 b/golang/lab7/Informatics_2024 deleted file mode 160000 index ea3aab55..00000000 --- a/golang/lab7/Informatics_2024 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ea3aab550a1bc9d754d59d45399f2cacba72f8a3