-
Notifications
You must be signed in to change notification settings - Fork 38
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
Дз № 4 + исправления по дз № 3 + spring + ДЗ № 5 #6
base: master
Are you sure you want to change the base?
Conversation
Изначально исправления по предыдущему дз были в прошлом PR (hw-3), перенесла их сюда. |
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.
См комментарии
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class SensorEventAdapter extends SensorEvent { |
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.
Нужно сделать через отдельный класс, который принимает на вход событие библиотечного типа и возвращает событие "нашего" типа.
Наследование здесь не нужно.
|
||
for (SensorEventProcessor eventProcessor : eventProcessors) { | ||
EventHandler handler = new EventProcessorAdapter(eventProcessor); | ||
((ArrayList<EventHandler>) handlers).add(handler); |
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.
зачем cast к ArrayList - в Collection есть метод add
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.
У меня там раньше немного другое было написано, каст идея сгенерировала, потом я поменяла строчку, а каст остался:(
public void start() { | ||
this.eventsManager.registerEventHandler( | ||
stringEvent -> { | ||
toString(stringEvent.getEventType(), stringEvent.getObjectId()); |
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.
Моя ошибка, там в Sample приведена строчка, которую выводить надо, a я написала то, как это в SensorCommand было.
public SensorEventsManagerAdapter(List<SensorEventProcessor> eventProcessors) { | ||
this.eventsManager = new SensorEventsManager(); | ||
|
||
Collection<EventHandler> handlers = new ArrayList<>(); |
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.
Почему вообще не сделать просто:
eventProcessors.each(processor -> registerEventProcessor(processor))
?
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.
Не догадалась:)
public class RemoteControlApp implements RemoteControl { | ||
|
||
private HashMap<String, Command> buttonsVocab; | ||
private RemoteControlRegistry remoteControlRegistry; |
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.
Не нужно, не успела убрать.
No description provided.