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/lab7 #527

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

lab6/lab7 #527

wants to merge 7 commits into from

Conversation

Krezo1206
Copy link

No description provided.

@Krezo1206 Krezo1206 changed the title lab6 lab6/lab7 Dec 18, 2024
@FeLL1kS
Copy link
Collaborator

FeLL1kS commented Dec 25, 2024

Что-то я не понял, написали что переделали четвертую, а тут 6 и 7

Comment on lines +10 to +48
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) + " Вт"
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В отдельный файл, все в одном месте хранить - дурной тон

Comment on lines +7 to +19
type Product interface {
GetName() string
GetPrice() float64
ApplyDiscount(discount float64)
}

func Calculate(products []Product) float64 {
total := 0.0
for _, product := range products {
total += product.GetPrice()
}
return total
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Интерфейс тоже в отдельный файл

ApplyDiscount(discount float64)
}

func Calculate(products []Product) float64 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calculate что?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants