-
Notifications
You must be signed in to change notification settings - Fork 112
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
base: Voroshilov_Efim
Are you sure you want to change the base?
lab6/lab7 #527
Conversation
Что-то я не понял, написали что переделали четвертую, а тут 6 и 7 |
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) + " Вт" | ||
} |
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.
В отдельный файл, все в одном месте хранить - дурной тон
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 | ||
} |
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.
Интерфейс тоже в отдельный файл
ApplyDiscount(discount float64) | ||
} | ||
|
||
func Calculate(products []Product) float64 { |
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.
Calculate что?
No description provided.