Skip to content
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

lab6 #527

Open
wants to merge 4 commits into
base: Voroshilov_Efim
Choose a base branch
from
Open

lab6 #527

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
66 changes: 66 additions & 0 deletions golang/lab6/lab6.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package lab6

import (
"fmt"
"strconv"
)

const maxPowerUsage = 800

type PC struct {
Brand string
GPU string
CPU string
PowerUsage int
Storage int
}

func (pc *PC) SetBrand(brand string) {
pc.Brand = brand
}

func (pc *PC) SetPowerUsage(powerUsage int) {
if powerUsage > maxPowerUsage {
fmt.Println("Ошибка: превышение максимальной мощности потребления!")
} else {
pc.PowerUsage = powerUsage
}
}

func (pc *PC) SetGPU(gpu string) {
pc.GPU = gpu
}

func (pc *PC) SetCPU(cpu string) {
pc.CPU = cpu
}

func (pc *PC) SetStorage(storage int) {
pc.Storage = storage
}

func (pc *PC) GetInfo() string {
return "Бренд: " + pc.Brand + "\n" +
"Процессор: " + pc.CPU + "\n" +
"Видеокарта: " + pc.GPU + "\n" +
"Жесткий диск: " + strconv.Itoa(pc.Storage) + " Гб\n" +
"Энергопотребление: " + strconv.Itoa(pc.PowerUsage) + " Вт"
}

func RunLab6() {
pc := PC{
Brand: "LG",
CPU: "Intel Xeon 231",
GPU: "Nvidia 1050 GTX",
Storage: 256,
PowerUsage: 300,
}
fmt.Println(pc.GetInfo())

pc.SetBrand("BMW")
pc.SetCPU("Razen Radeon 5632")
pc.SetGPU("Invoker RTX SunsrikeSuper 2090")
pc.SetStorage(512)
pc.SetPowerUsage(2000)
fmt.Println(pc.GetInfo())
}
3 changes: 3 additions & 0 deletions golang/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import (
"fmt"

"isuct.ru/informatics2022/lab4"
"isuct.ru/informatics2022/lab6"

)

func main() {
fmt.Println("Ворошилов Ефим Александрович")
lab4.RunLab4()
lab6.RunLab6()
}
Loading