Lab 02#46
Conversation
| "bread" : 50, | ||
| "butter" : 50 | ||
| }, | ||
| "hobos": 1, |
There was a problem hiding this comment.
По условию В доках обитает hobos > 2 бродяг.
| throw new IllegalArgumentException("Wrong arguments provided."); | ||
| } | ||
| String path = args[0]; | ||
| initializeController(path); |
There was a problem hiding this comment.
Кмк, лучше было бы сделать так controller = getController().
| public static Controller getInstance() { | ||
| return instance; | ||
| } |
There was a problem hiding this comment.
Не очень понятное апи, а если я обращусь к нему до конструктора?
|
|
||
| public class Dock implements Runnable { | ||
| int unloadingSpeed; | ||
| ConcurrentHashMap<String, Integer> storageTaken = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
А зачем ConcurrentHashMap если все равно все выполняется под синхронизацией.
| for (var i : storageTaken.keySet()) { | ||
| System.out.println(i + storageTaken.get(i)); | ||
| } |
| for (var i : storageTaken.keySet()) { | ||
| System.out.println(i + storageTaken.get(i)); | ||
| } |
| } | ||
|
|
||
| public void setCargo(String cargo) { | ||
| synchronized (this) { |
There was a problem hiding this comment.
лучше тогда метод пометить synchronized. Но в текущем коде, все это происходит в однмо потоке, поэтому тут это не нужно как и ниже.
| if (cargo == null) { | ||
| continue; | ||
| } | ||
| synchronized (Controller.getInstance()) { |
There was a problem hiding this comment.
А зачем это тут? Контроллер нигде не изменяется
| ingredientsStolen.put(cargoToSteal, ingredientsStolen.get(cargoToSteal) + 1); | ||
| logger.log(Level.INFO, ingredientsNeeded + " " + ingredientsStolen); |
There was a problem hiding this comment.
Почему? Тут же надо убедиться, что он своровал объект.
|
Основная оценка:
Допы:
В итоге: |
No description provided.