Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public String craftPresent(String presentName) {
- String message = "";
- int count = 0;
- Present present = this.presents.findByName(presentName);
- if (present != null) {
- List<Dwarf> dwarfList = this.dwarfs.getModels().stream()
- .filter(f -> f.getEnergy() > 50)
- .collect(Collectors.toList());
- if (dwarfList.isEmpty()) {
- throw new IllegalArgumentException(ExceptionMessages.NO_DWARF_READY);
- }
- for (Dwarf dwarf : dwarfList) {
- Workshop workshop = new WorkshopImpl();
- workshop.craft(present, dwarf);
- long count1 = dwarf.getInstruments().stream()
- .filter(Instrument::isBroken).count();
- if (present.isDone()) {
- message = String.format("Present %s is done. %d instrument/s have been broken while working on it!", presentName, count1);
- countCrafted++;
- } else {
- message = String.format("Present %s is not done. %d instrument/s have been broken while working on it!", presentName, count1);
- }
- }
- }
- return message;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement