I have a class Monster { move() attack() } we can create: melee monster : monster overr attack() ranged monster : monster ovverr attack() flying monster : monster overr move() swimming monster : monster overr move() how to create FlyingRangeMonster and MeleeSwimmingMonster without duplicating code? I suppose we should abandon inheritance and use composition. How to realízate it in this case ? Thank you!
3/12/2021 6:49:01 AM
Tatarochka_2 Answers
New Answerbut if we create an interface we will duplicate code (e.g. melee monster and swimmingmeleemonster will have same realization of attack method)
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message