package fmi.sda.homework1;

import java.util.LinkedList;

public class FrontBookkeeper61838 implements IFrontBookkeeper {
	String result="";
	@Override
	public String updateFront(String[] news) {
		Army army=new Army();
		
		for(String currentNews:news){
			String[] newsFromFront=currentNews.split(" ");
			
			if(currentNews.contains("=")){
				String soldiers=currentNews.substring(newsFromFront[0].length()+4);
				String unitName = newsFromFront[0];
				LinkedList<String> soldiersList = new LinkedList<>();
				for(String soldier:soldiers.substring(0, soldiers.length()-1).split(", ")){
					soldiersList.add(soldier);
				}
				army.addUnit(unitName,soldiersList);
				
			}else if(currentNews.contains("attached")){
				if(newsFromFront.length==4){
					army.attachUnit(newsFromFront[0], newsFromFront[3]);
				}else{ //third command
				}
	
			}else if(currentNews.contains("died")){
				String[] killed = newsFromFront[1].replace("..", " ").split(" "); // 
				System.out.println(newsFromFront[3]);
					
				army.killSoldiers(Integer.parseInt(killed[0]), Integer.parseInt(killed[1]),newsFromFront[3]);
			}
			else if(currentNews.contains("show")){
				if(newsFromFront.length==2){
					String unit=newsFromFront[1];
					result+=army.showUnit(unit)+"\n";
				}else if(newsFromFront.length>2){ 
					result+=army.showSoldier(newsFromFront[2])+"\n";
				}
			}	
		}
		return result;
	}
}
@@ -1,32 +1,4 @@
-package fmi.sda.homework1;%0A%0A
 impo
@@ -930,17 +930,28 @@
 %22 %22); //
- 
+%C3%A4%C3%AE%C3%B1%C3%B2%C3%A0 %C3%A3%C3%B0%C3%AE%C3%A7%C3%AD%C3%AE
 %0A%09%09%09%09Sys
@@ -1373,8 +1373,9 @@
 lt;%0A%09%7D%0A%7D
+%0A

Update FrontBookkeeper61838.java