Created
November 24, 2020 19:49
-
-
Save internetova/4cee109fe97e285c6102fc78ef32d32f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Представьте, что разрабатывайте фентезийную игру. | |
В игре есть гоблины и орки. Они спавнятся в пещерах. | |
Создайте классы: | |
Goblin | |
Hobogoblin extends Goblin | |
Orc | |
Lair - пещера гоблинов, которая может вмещать в себя только гоблинов и наследников | |
Создайте экземпляр класса Lair. В качестве типа поставьте гоблина, хогоблина и орка. Результат опишите в комментариях | |
*/ | |
void main() { | |
final lair1 = Lair<Goblin>(); | |
final lair2 = Lair<Hobogoblin>(); | |
// final lair3 = Lair<Orc>(); Ошибка: 'Orc' doesn't extend 'Goblin' | |
} | |
class Goblin {} | |
class Hobogoblin extends Goblin {} | |
class Orc {} | |
class Lair<T extends Goblin> {} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment