-
Notifications
You must be signed in to change notification settings - Fork 0
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
common interfaces #10
Conversation
30c61cc
to
e65d9bd
Compare
back/src/main/kotlin/io/github/badgersOfKotlinForest/kotlinForest/actors/Actor.kt
Outdated
Show resolved
Hide resolved
back/src/main/kotlin/io/github/badgersOfKotlinForest/kotlinForest/actors/MoveableActor.kt
Outdated
Show resolved
Hide resolved
back/src/main/kotlin/io/github/badgersOfKotlinForest/kotlinForest/animals/Food.kt
Outdated
Show resolved
Hide resolved
back/src/main/kotlin/io/github/badgersOfKotlinForest/kotlinForest/map/Map.kt
Outdated
Show resolved
Hide resolved
back/src/main/kotlin/io/github/badgersOfKotlinForest/kotlinForest/map/Map.kt
Outdated
Show resolved
Hide resolved
back/src/main/kotlin/io/github/badgersOfKotlinForest/kotlinForest/map/MapItem.kt
Outdated
Show resolved
Hide resolved
9b975c5
to
560e708
Compare
back/src/main/kotlin/io/github/badgersOfKotlinForest/kotlinForest/map/Map.kt
Outdated
Show resolved
Hide resolved
back/src/main/kotlin/io/github/badgersOfKotlinForest/kotlinForest/map/Map.kt
Outdated
Show resolved
Hide resolved
back/src/main/kotlin/io/github/badgersOfKotlinForest/kotlinForest/tree/Tree.kt
Show resolved
Hide resolved
back/src/main/kotlin/io/github/badgersOfKotlinForest/kotlinForest/animals/Food.kt
Outdated
Show resolved
Hide resolved
back/src/main/kotlin/io/github/badgersOfKotlinForest/kotlinForest/animals/Animal.kt
Outdated
Show resolved
Hide resolved
|
||
// Extends animal because if it is can breed, so it is already an animal | ||
interface Breedable<TSpecies : Animal> : Animal { | ||
fun breedWith(other: TSpecies?): TSpecies |
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.
Почему nullable, я все понять не могу...
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.
Ну червяки какие-нибудь
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.
Пусть тогда будет еще интерфейс, где такой метод без параметров – гермафродит
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.
Стойте, это же наверно не нужный интерфейс вообще? Типа интеракт это делает, пусть животное само решает, что делать с другим животным
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.
Имхо, это бесполезный интерфейс, так как получится, что кто-то из вне его вызывает
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.
Да, это внутреннее поведение...
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.
Ну раз ты хочешь скрещивать кого угодно с кем угодно, то да, не нужный
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.
Тут мне кажется лучше уже описать абстрактный класс, который будет требовать определить базовые для животных(еда, сон, размножение, смерть ...) методы, которые не доступны снаружи(protected
), также который будет реализовывать interactWith
для всех животных. Вроде в природе он одинаковый.
Либо есть еще вариант именно для размножения, сделать какой-нибудь дженерик класс Breeder, и животное внутри его себя будет через композицию хранить и во внутренней логике вызывать.
@@ -0,0 +1,6 @@ | |||
package io.github.badgersOfKotlinForest.kotlinForest.animals | |||
|
|||
enum class EatableType { |
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.
Предлагаю положить в один файл с Eatable
back/src/main/kotlin/io/github/badgersOfKotlinForest/kotlinForest/tree/TreeElement.kt
Show resolved
Hide resolved
3ce509b
to
66f0956
Compare
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.
Вроде норм
66f0956
to
10cea3f
Compare
Если животные абстрактные классы, то наверное здесь всё? |
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.
Ок
Давайте обсуждать. Я решил добавить подвид Actor, MoveableActor, который умеет передвигаться, раз у нас деревья тоже акторы. Ещё я добавил некторые интерфейсы для карты и животных