-
Notifications
You must be signed in to change notification settings - Fork 99
Homework #4 #67
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
base: master
Are you sure you want to change the base?
Homework #4 #67
Conversation
| /** | ||
| * Горловина к топливному баку | ||
| */ | ||
| data class TankMouth(val type:Type, val tank:Tank, val car:Car){ |
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.
@mahonin-ms, давайте отвлечемся от программирования, вспомним реальные конструкции, и какая между ними связь...
В реальной жизни: бак установлен в автомобиль, он связан горловиной с внешним миром.
В вашем варианте: горловина, в которую установлены бак и машина
| * @return сколько в баке после заправки | ||
| */ | ||
| fun addFuel(level: Int): Boolean { | ||
| if(car is Taz){ |
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.
@mahonin-ms
... если установленная машина - это таз - то ой.
Получилось не очень натурально
| } | ||
| } | ||
|
|
||
| class FuelSystem { |
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.
@mahonin-ms идея объединить бак и горловину единой внешней сущностью - это хорошее решение! Но ссылка к машине, опять же, кажется лишней. В реальной жизни топливную систему в сборе ставят в машину. Горловина торчит наружу - это и есть интерфейс для заправки
| fun refuelCar(car: Car, litres: Int) { | ||
| println("Заправка авто: ${car.toString()} на ${litres.toString()} литров") | ||
| currentCar = car | ||
| if( currentCar is Taz){ |
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.
@mahonin-ms, получился костыль в заправке. Почему бы не сделать взрыв непосредственно в ТАЗу? Зачем другим компонентам знать "детали его внутренней реализации"?
No description provided.