Answer the question
In order to leave comments, you need to log in
Am I using the abstract Animal class correctly?
abstract Animal {
abstract say()
abstract eat()
}
Dog implements Animal {...}
Cat implements Animal {...}
Cow implements Animal {... and getMilk}
All three classes are similar but the last one adds a method to get milk, Is there a design error, is it possible to say that the cow also implements the Animal class?
Answer the question
In order to leave comments, you need to log in
And here, I figured it out. It was necessary to add one more ampersand.
foreach ($by_month as $y => &$months) {
foreach ($months as $m => &$ers) {
krsort($ers);
}
}
The question itself provokes: Yes! Wrong! )
But seriously.
Do not build a system from the abstract to the concrete. So good in the tutorial. in reality, this generates many unnecessary layers and classes. Do it from the concrete to the abstract. Those. there are two classes that you apply. they have in common. Take out the general in an abstract class. Those. proceed from the bottom to the abstract.
Second moment. Associated with polymorphism. It's coming up with an interface and then implementing it. But this is a different song.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question