diff --git a/lab-02/by/nrydo/docks_and_hobos/ConfigReader.java b/lab-02/by/nrydo/docks_and_hobos/ConfigReader.java new file mode 100644 index 0000000..eb62d8d --- /dev/null +++ b/lab-02/by/nrydo/docks_and_hobos/ConfigReader.java @@ -0,0 +1,114 @@ +package by.nrydo.docks_and_hobos; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; + +import java.io.FileReader; +import java.util.Arrays; + +public class ConfigReader { + private static ConfigReader instance = null; + + private int generatingTime; + private int shipCapacityMin; + private int shipCapacityMax; + private String[] cargoTypes; + private int maxShips; + private int unloadingSpeed; + private int dockCapacity; + private int hobos; + private int[] ingredientsCount; + private int stealingTime; + private int eatingTime; + + private ConfigReader() { + } + + public static ConfigReader getInstance() { + if (instance == null) { + instance = new ConfigReader(); + } + return instance; + } + + public void readConfig(String filePath) { + JSONParser parser = new JSONParser(); + + try (FileReader reader = new FileReader(filePath)) { + Object obj = parser.parse(reader); + JSONObject jsonObject = (JSONObject) obj; + + generatingTime = Math.toIntExact((Long) jsonObject.get("generating_time")); + shipCapacityMin = Math.toIntExact((Long) jsonObject.get("ship_capacity_min")); + shipCapacityMax = Math.toIntExact((Long) jsonObject.get("ship_capacity_max")); + + JSONArray cargoTypesJson = (JSONArray) jsonObject.get("cargo_types"); + cargoTypes = new String[cargoTypesJson.size()]; + for (int i = 0; i < cargoTypesJson.size(); i++) { + cargoTypes[i] = (String) cargoTypesJson.get(i); + } + + maxShips = Math.toIntExact((Long) jsonObject.get("max_ships")); + unloadingSpeed = Math.toIntExact((Long) jsonObject.get("unloading_speed")); + dockCapacity = Math.toIntExact((Long) jsonObject.get("dock_capacity")); + hobos = Math.toIntExact((Long) jsonObject.get("hobos")); + + JSONArray ingredientsCountJson = (JSONArray) jsonObject.get("ingredients_count"); + ingredientsCount = new int[cargoTypesJson.size()]; + for (int i = 0; i < ingredientsCountJson.size(); i++) { + ingredientsCount[i] = ((Long) ingredientsCountJson.get(i)).intValue(); + } + + stealingTime = Math.toIntExact((Long) jsonObject.get("stealing_time")); + eatingTime = Math.toIntExact((Long) jsonObject.get("eating_time")); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + public int getGeneratingTime() { + return generatingTime; + } + + public int getShipCapacityMin() { + return shipCapacityMin; + } + + public int getShipCapacityMax() { + return shipCapacityMax; + } + + public String[] getCargoTypes() { + return cargoTypes; + } + + public int getMaxShips() { + return maxShips; + } + + public int getUnloadingSpeed() { + return unloadingSpeed; + } + + public int getDockCapacity() { + return dockCapacity; + } + + public int getHobos() { + return hobos; + } + + public int[] getIngredientsCount() { + return ingredientsCount; + } + + public int getStealingTime() { + return stealingTime; + } + + public int getEatingTime() { + return eatingTime; + } +} diff --git a/lab-02/by/nrydo/docks_and_hobos/Dock.java b/lab-02/by/nrydo/docks_and_hobos/Dock.java new file mode 100644 index 0000000..a1d32c0 --- /dev/null +++ b/lab-02/by/nrydo/docks_and_hobos/Dock.java @@ -0,0 +1,107 @@ +package by.nrydo.docks_and_hobos; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.Semaphore; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +import java.util.logging.FileHandler; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.logging.SimpleFormatter; + +public class Dock implements Runnable { + private final int unloadingSpeed; + private final int dockCapacity; + private final int[] currentCargoStore; + private final Tunnel tunnel; + private final int maxBatchCount = 1; + private final Semaphore cargoSemaphore; + private final Lock stealingLock; + private int unloadThisSecond; + private int unloadBatchCount; + private final Logger logger; + + public Dock(Tunnel tunnel) { + this.tunnel = tunnel; + unloadingSpeed = ConfigReader.getInstance().getUnloadingSpeed(); + dockCapacity = ConfigReader.getInstance().getDockCapacity(); + currentCargoStore = new int[ConfigReader.getInstance().getCargoTypes().length]; + cargoSemaphore = new Semaphore(0); + stealingLock = new ReentrantLock(); + unloadThisSecond = 0; + unloadBatchCount = 0; + logger = createLogger(); + } + + private Logger createLogger() { + Logger logger = Logger.getLogger(Dock.class.getName()); + try { + FileHandler fileHandler = new FileHandler("log/dock.log"); + fileHandler.setFormatter(new SimpleFormatter()); + logger.addHandler(fileHandler); + } catch (Exception e) { + logger.log(Level.SEVERE, "Failed to create logger", e); + } + return logger; + } + + @Override + public void run() { + while (true) { + Ship ship = tunnel.getShip(); + unloadCargo(ship); + } + } + + public int steal() { + try { + cargoSemaphore.acquire(); + stealingLock.lock(); + List cargos = new ArrayList<>(); + for (int i = 0; i < currentCargoStore.length; i++) { + if (currentCargoStore[i] > 0) { + cargos.add(i); + } + } + int cargo = cargos.get((new Random()).nextInt(cargos.size())); + currentCargoStore[cargo]--; + stealingLock.unlock(); + return cargo; + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + + private void unloadCargo(Ship ship) { + while (ship.getStore() > 0) { + try { + int cargo = currentCargoStore[ship.getCargoType()]; + int batchSize = ship.take(getBatchSize()); + int cargoToUnload = Math.min(batchSize, dockCapacity - cargo); + cargoSemaphore.release(batchSize); + currentCargoStore[ship.getCargoType()] = cargo + cargoToUnload; + logCargoUnloading(cargoToUnload, ConfigReader.getInstance().getCargoTypes()[ship.getCargoType()]); + Thread.sleep(999L / maxBatchCount + 1); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + } + + private int getBatchSize() { + if (unloadBatchCount == 0) { + unloadBatchCount = maxBatchCount; + unloadThisSecond = unloadingSpeed; + } + int result = (unloadThisSecond + unloadBatchCount / 2) / unloadBatchCount; + unloadThisSecond -= result; + unloadBatchCount--; + return result; + } + + private void logCargoUnloading(int cargoToUnload, String cargoType) { + logger.info(String.format("Unloaded cargo: quantity=%d, type=%s", cargoToUnload, cargoType)); + } +} \ No newline at end of file diff --git a/lab-02/by/nrydo/docks_and_hobos/Hobo.java b/lab-02/by/nrydo/docks_and_hobos/Hobo.java new file mode 100644 index 0000000..ef6d6a3 --- /dev/null +++ b/lab-02/by/nrydo/docks_and_hobos/Hobo.java @@ -0,0 +1,105 @@ +package by.nrydo.docks_and_hobos; + +import java.util.Arrays; +import java.util.concurrent.BrokenBarrierException; +import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.Semaphore; +import java.util.concurrent.locks.Lock; +import java.util.logging.FileHandler; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.logging.SimpleFormatter; + +public class Hobo implements Runnable { + private boolean isCook = false; + private Semaphore cookSemaphore; + private Semaphore eatingSemaphore; + private Lock ingredientsLock; + private final CyclicBarrier eatingBarrier; + private final Dock dock; + private final HoboGroup group; + private final Logger logger; + + public Hobo(HoboGroup group, Dock dock, CyclicBarrier eatingBarrier) { + this.dock = dock; + this.group = group; + this.eatingBarrier = eatingBarrier; + this.logger = createLogger(); + } + + private Logger createLogger() { + Logger logger = Logger.getLogger(Hobo.class.getName()); + try { + // Создание обработчика файла логов + FileHandler fileHandler = new FileHandler("log/hobo.log"); + fileHandler.setFormatter(new SimpleFormatter()); + logger.addHandler(fileHandler); + } catch (Exception e) { + logger.log(Level.SEVERE, "Failed to create logger", e); + } + return logger; + } + + public void becomeCook(Semaphore cookSemaphore, Lock ingredientsLock, Semaphore eatingSemaphore) { + isCook = true; + this.cookSemaphore = cookSemaphore; + this.ingredientsLock = ingredientsLock; + this.eatingSemaphore = eatingSemaphore; + } + + @Override + public void run() { + int stealingTime = ConfigReader.getInstance().getStealingTime(); + try { + if (isCook) { + while (true) { + tryCook(); + } + } + while (true) { + Thread.sleep(stealingTime * 1000L); + while (group.isEating().get()) { + eatingBarrier.await(); + Thread.sleep(ConfigReader.getInstance().getEatingTime() * 1000L); + } + stealIngredient(); + } + } catch (InterruptedException | BrokenBarrierException e) { + logger.log(Level.SEVERE, "Thread interrupted", e); + } + } + + private void stealIngredient() { + int ingredient = dock.steal(); + group.putIngredient(ingredient); + logger.info("Stole ingredient: " + ConfigReader.getInstance().getCargoTypes()[ingredient]); + } + + private void tryCook() { + try { + cookSemaphore.acquire(); + ingredientsLock.lock(); + if (group.isEating().get()) { + ingredientsLock.unlock(); + eatingBarrier.await(); + Thread.sleep(ConfigReader.getInstance().getEatingTime() * 1000L); + return; + } + int[] ingredients = group.getIngredients(); + int[] ingredientsCount = ConfigReader.getInstance().getIngredientsCount(); + for (int i = 0; i < ingredients.length; i++) { + if (ingredients[i] < ingredientsCount[i]) { + ingredientsLock.unlock(); + return; + } + } + eatingSemaphore.release(); + group.isEating().set(true); + ingredientsLock.unlock(); + eatingBarrier.await(); + Thread.sleep(ConfigReader.getInstance().getEatingTime() * 1000L); + } catch (InterruptedException | BrokenBarrierException e) { + throw new RuntimeException(e); + } + } +} diff --git a/lab-02/by/nrydo/docks_and_hobos/HoboGroup.java b/lab-02/by/nrydo/docks_and_hobos/HoboGroup.java new file mode 100644 index 0000000..5b89b74 --- /dev/null +++ b/lab-02/by/nrydo/docks_and_hobos/HoboGroup.java @@ -0,0 +1,108 @@ +package by.nrydo.docks_and_hobos; + +import java.util.Random; +import java.util.concurrent.BrokenBarrierException; +import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.Semaphore; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +import java.util.logging.FileHandler; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.logging.SimpleFormatter; + +public class HoboGroup implements Runnable { + private final Thread[] threads; + private final int[] ingredients; + private final Semaphore cookSemaphore; + private final Semaphore eatingSemaphore; + private final Lock ingredientsLock; + private final CyclicBarrier eatingBarrier; + private final AtomicBoolean eating; + private final Logger logger; + + HoboGroup(Dock dock) { + Hobo[] hobos = new Hobo[ConfigReader.getInstance().getHobos()]; + ingredients = new int[ConfigReader.getInstance().getIngredientsCount().length]; + + cookSemaphore = new Semaphore(0); + eatingSemaphore = new Semaphore(0); + ingredientsLock = new ReentrantLock(); + eatingBarrier = new CyclicBarrier(hobos.length + 1, this::eat); + eating = new AtomicBoolean(false); + + threads = new Thread[hobos.length]; + logger = createLogger(); + + for (int i = 0; i < hobos.length; i++) { + hobos[i] = new Hobo(this, dock, eatingBarrier); + threads[i] = new Thread(hobos[i]); + } + + Random random = new Random(); + + int firstCook = random.nextInt(hobos.length); + int secondCook = (firstCook + random.nextInt(hobos.length - 1) + 1) % hobos.length; + + hobos[firstCook].becomeCook(cookSemaphore, ingredientsLock, eatingSemaphore); + hobos[secondCook].becomeCook(cookSemaphore, ingredientsLock, eatingSemaphore); + } + + private Logger createLogger() { + Logger logger = Logger.getLogger(HoboGroup.class.getName()); + try { + FileHandler fileHandler = new FileHandler("log/hobo_group.log"); + fileHandler.setFormatter(new SimpleFormatter()); + logger.addHandler(fileHandler); + } catch (Exception e) { + logger.log(Level.SEVERE, "Failed to create logger", e); + } + return logger; + } + + private void logEating() { + logger.info("Hobos are eating"); + } + + void eat() { + logEating(); + int[] ingredientsCount = ConfigReader.getInstance().getIngredientsCount(); + for (int i = 0; i < ingredients.length; i++) { + ingredients[i] -= ingredientsCount[i]; + } + eating.set(false); + } + + public void putIngredient(int ingredient) { + ingredientsLock.lock(); + ingredients[ingredient]++; + cookSemaphore.release(); + ingredientsLock.unlock(); + } + + public int[] getIngredients() { + return ingredients; + } + + public AtomicBoolean isEating() { + return eating; + } + + @Override + public void run() { + for (Thread thread : threads) { + thread.start(); + } + + try { + while (true) { + eatingSemaphore.acquire(); + cookSemaphore.release(); + eatingBarrier.await(); + } + } catch (InterruptedException | BrokenBarrierException e) { + logger.log(Level.SEVERE, "Thread interrupted", e); + } + } +} \ No newline at end of file diff --git a/lab-02/by/nrydo/docks_and_hobos/Main.java b/lab-02/by/nrydo/docks_and_hobos/Main.java new file mode 100644 index 0000000..bcacc20 --- /dev/null +++ b/lab-02/by/nrydo/docks_and_hobos/Main.java @@ -0,0 +1,34 @@ +package by.nrydo.docks_and_hobos; + +public class Main { + public static void main(String[] args) { + if (args.length < 1) { + throw new IllegalArgumentException(); + } + + String configFilePath = args[0]; + + ConfigReader config = ConfigReader.getInstance(); + config.readConfig(configFilePath); + + Tunnel tunnel = new Tunnel(); + ShipGenerator shipGenerator = new ShipGenerator(tunnel); + Dock dock = new Dock(tunnel); + HoboGroup hobos = new HoboGroup(dock); + + Thread shipGeneratorThread = new Thread(shipGenerator); + Thread dockThread = new Thread(dock); + Thread hobosThread = new Thread(hobos); + + shipGeneratorThread.start(); + dockThread.start(); + hobosThread.start(); + + try { + shipGeneratorThread.join(); + dockThread.join(); + } catch (Exception exception) { + exception.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/lab-02/by/nrydo/docks_and_hobos/Ship.java b/lab-02/by/nrydo/docks_and_hobos/Ship.java new file mode 100644 index 0000000..192ea39 --- /dev/null +++ b/lab-02/by/nrydo/docks_and_hobos/Ship.java @@ -0,0 +1,33 @@ +package by.nrydo.docks_and_hobos; + +public class Ship { + private int store; + private final int cargoType; + + public Ship(int capacity, int cargoType) { + this.store = capacity; + this.cargoType = cargoType; + } + + public int getStore() { + return store; + } + + public int getCargoType() { + return cargoType; + } + + public String getTypeName() { + return ConfigReader.getInstance().getCargoTypes()[cargoType]; + } + + public int take(int x) { + if (store > x) { + store -= x; + return x; + } + int result = store; + store = 0; + return result; + } +} diff --git a/lab-02/by/nrydo/docks_and_hobos/ShipGenerator.java b/lab-02/by/nrydo/docks_and_hobos/ShipGenerator.java new file mode 100644 index 0000000..3a716b1 --- /dev/null +++ b/lab-02/by/nrydo/docks_and_hobos/ShipGenerator.java @@ -0,0 +1,59 @@ +package by.nrydo.docks_and_hobos; + +import java.util.Random; +import java.util.logging.FileHandler; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.logging.SimpleFormatter; + +public class ShipGenerator implements Runnable { + private final Tunnel tunnel; + private final Logger logger; + + public ShipGenerator(Tunnel tunnel) { + this.tunnel = tunnel; + this.logger = createLogger(); + } + + private Logger createLogger() { + Logger logger = Logger.getLogger(ShipGenerator.class.getName()); + try { + FileHandler fileHandler = new FileHandler("log/ship_generator.log"); + fileHandler.setFormatter(new SimpleFormatter()); + logger.addHandler(fileHandler); + } catch (Exception e) { + logger.log(Level.SEVERE, "Failed to create logger", e); + } + return logger; + } + + @Override + public void run() { + ConfigReader config = ConfigReader.getInstance(); + while (true) { + try { + Ship ship = generateShip(); + tunnel.addShip(ship); + logShipGeneration(ship); + Thread.sleep(config.getGeneratingTime() * 1000L); + } catch (InterruptedException e) { + logger.log(Level.SEVERE, "Thread interrupted", e); + } + } + } + + private Ship generateShip() { + Random random = new Random(); + ConfigReader config = ConfigReader.getInstance(); + int minCapacity = config.getShipCapacityMin(); + int maxCapacity = config.getShipCapacityMax(); + int capacity = random.nextInt(maxCapacity - minCapacity + 1) + minCapacity; + int cargoType = random.nextInt(config.getCargoTypes().length); + return new Ship(capacity, cargoType); + } + + private void logShipGeneration(Ship ship) { + String message = String.format("Generated ship: capacity=%d, cargoType=%d", ship.getStore(), ship.getCargoType()); + logger.info(message); + } +} \ No newline at end of file diff --git a/lab-02/by/nrydo/docks_and_hobos/Tunnel.java b/lab-02/by/nrydo/docks_and_hobos/Tunnel.java new file mode 100644 index 0000000..483ac31 --- /dev/null +++ b/lab-02/by/nrydo/docks_and_hobos/Tunnel.java @@ -0,0 +1,65 @@ +package by.nrydo.docks_and_hobos; + +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.Semaphore; +import java.util.logging.FileHandler; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.logging.SimpleFormatter; + +public class Tunnel { + private final Semaphore placeSemaphore; + private final Semaphore shipSemaphore; + private final Queue ships; + private final Logger logger; + + public Tunnel() { + ConfigReader config = ConfigReader.getInstance(); + placeSemaphore = new Semaphore(config.getMaxShips()); + shipSemaphore = new Semaphore(0); + ships = new ConcurrentLinkedQueue<>(); + logger = createLogger(); + } + + private Logger createLogger() { + Logger logger = Logger.getLogger(Tunnel.class.getName()); + try { + FileHandler fileHandler = new FileHandler("log/tunnel.log"); + fileHandler.setFormatter(new SimpleFormatter()); + logger.addHandler(fileHandler); + } catch (Exception e) { + logger.log(Level.SEVERE, "Failed to create logger", e); + } + return logger; + } + + public void addShip(Ship ship) { + if (placeSemaphore.tryAcquire()) { + ships.add(ship); + shipSemaphore.release(); + logShipAdded(ship); + } + } + + public Ship getShip() { + try { + shipSemaphore.acquire(); + Ship ship = ships.poll(); + placeSemaphore.release(); + logShipRemoved(ship); + return ship; + } catch (InterruptedException e) { + logger.log(Level.SEVERE, "Thread interrupted", e); + throw new RuntimeException(e); + } + } + + private void logShipAdded(Ship ship) { + logger.info(String.format("Ship added to the tunnel: capacity=%d, cargoType=%s", ship.getStore(), ship.getTypeName())); + } + + private void logShipRemoved(Ship ship) { + logger.info(String.format("Ship removed from the tunnel: capacity=%d, cargoType=%s", ship.getStore(), ship.getTypeName())); + } +} \ No newline at end of file diff --git a/lab-02/by/nrydo/docks_and_hobos/config.json b/lab-02/by/nrydo/docks_and_hobos/config.json new file mode 100644 index 0000000..5ca0197 --- /dev/null +++ b/lab-02/by/nrydo/docks_and_hobos/config.json @@ -0,0 +1,13 @@ +{ + "generating_time": 5, + "ship_capacity_min": 1, + "ship_capacity_max": 5, + "cargo_types": ["Bread", "Cheese", "Meat"], + "max_ships": 3, + "unloading_speed": 5, + "dock_capacity": 100, + "hobos": 5, + "ingredients_count": [1, 1, 1], + "stealing_time": 3, + "eating_time": 5 +} \ No newline at end of file diff --git a/lab-02/lib/json-simple-1.1.1.jar b/lab-02/lib/json-simple-1.1.1.jar new file mode 100644 index 0000000..66347a6 Binary files /dev/null and b/lab-02/lib/json-simple-1.1.1.jar differ diff --git a/lab-02/log/dock.log b/lab-02/log/dock.log new file mode 100644 index 0000000..ae65130 --- /dev/null +++ b/lab-02/log/dock.log @@ -0,0 +1,10 @@ +дек. 27, 2023 8:08:18 AM by.nrydo.docks_and_hobos.Dock logCargoUnloading +INFO: Unloaded cargo: quantity=5, type=Cheese +дек. 27, 2023 8:08:23 AM by.nrydo.docks_and_hobos.Dock logCargoUnloading +INFO: Unloaded cargo: quantity=2, type=Bread +дек. 27, 2023 8:08:28 AM by.nrydo.docks_and_hobos.Dock logCargoUnloading +INFO: Unloaded cargo: quantity=4, type=Cheese +дек. 27, 2023 8:08:33 AM by.nrydo.docks_and_hobos.Dock logCargoUnloading +INFO: Unloaded cargo: quantity=5, type=Meat +дек. 27, 2023 8:08:38 AM by.nrydo.docks_and_hobos.Dock logCargoUnloading +INFO: Unloaded cargo: quantity=4, type=Meat diff --git a/lab-02/log/hobo.log b/lab-02/log/hobo.log new file mode 100644 index 0000000..93923f4 --- /dev/null +++ b/lab-02/log/hobo.log @@ -0,0 +1,26 @@ +дек. 27, 2023 8:08:21 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:21 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:21 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:24 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Bread +дек. 27, 2023 8:08:24 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Bread +дек. 27, 2023 8:08:24 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:27 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:28 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:28 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:30 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:31 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:33 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Meat +дек. 27, 2023 8:08:33 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Meat diff --git a/lab-02/log/hobo.log.1 b/lab-02/log/hobo.log.1 new file mode 100644 index 0000000..93923f4 --- /dev/null +++ b/lab-02/log/hobo.log.1 @@ -0,0 +1,26 @@ +дек. 27, 2023 8:08:21 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:21 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:21 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:24 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Bread +дек. 27, 2023 8:08:24 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Bread +дек. 27, 2023 8:08:24 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:27 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:28 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:28 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:30 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:31 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:33 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Meat +дек. 27, 2023 8:08:33 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Meat diff --git a/lab-02/log/hobo.log.2 b/lab-02/log/hobo.log.2 new file mode 100644 index 0000000..93923f4 --- /dev/null +++ b/lab-02/log/hobo.log.2 @@ -0,0 +1,26 @@ +дек. 27, 2023 8:08:21 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:21 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:21 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:24 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Bread +дек. 27, 2023 8:08:24 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Bread +дек. 27, 2023 8:08:24 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:27 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:28 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:28 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:30 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:31 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Cheese +дек. 27, 2023 8:08:33 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Meat +дек. 27, 2023 8:08:33 AM by.nrydo.docks_and_hobos.Hobo stealIngredient +INFO: Stole ingredient: Meat diff --git a/lab-02/log/hobo_group.log b/lab-02/log/hobo_group.log new file mode 100644 index 0000000..22ae530 --- /dev/null +++ b/lab-02/log/hobo_group.log @@ -0,0 +1,2 @@ +дек. 27, 2023 8:08:36 AM by.nrydo.docks_and_hobos.HoboGroup logEating +INFO: Hobos are eating diff --git a/lab-02/log/ship_generator.log b/lab-02/log/ship_generator.log new file mode 100644 index 0000000..41e0540 --- /dev/null +++ b/lab-02/log/ship_generator.log @@ -0,0 +1,10 @@ +дек. 27, 2023 8:08:18 AM by.nrydo.docks_and_hobos.ShipGenerator logShipGeneration +INFO: Generated ship: capacity=5, cargoType=1 +дек. 27, 2023 8:08:23 AM by.nrydo.docks_and_hobos.ShipGenerator logShipGeneration +INFO: Generated ship: capacity=2, cargoType=0 +дек. 27, 2023 8:08:28 AM by.nrydo.docks_and_hobos.ShipGenerator logShipGeneration +INFO: Generated ship: capacity=4, cargoType=1 +дек. 27, 2023 8:08:33 AM by.nrydo.docks_and_hobos.ShipGenerator logShipGeneration +INFO: Generated ship: capacity=5, cargoType=2 +дек. 27, 2023 8:08:38 AM by.nrydo.docks_and_hobos.ShipGenerator logShipGeneration +INFO: Generated ship: capacity=0, cargoType=2 diff --git a/lab-02/log/tunnel.log b/lab-02/log/tunnel.log new file mode 100644 index 0000000..5700f0e --- /dev/null +++ b/lab-02/log/tunnel.log @@ -0,0 +1,20 @@ +дек. 27, 2023 8:08:18 AM by.nrydo.docks_and_hobos.Tunnel logShipAdded +INFO: Ship added to the tunnel: capacity=5, cargoType=Cheese +дек. 27, 2023 8:08:18 AM by.nrydo.docks_and_hobos.Tunnel logShipRemoved +INFO: Ship removed from the tunnel: capacity=5, cargoType=Cheese +дек. 27, 2023 8:08:23 AM by.nrydo.docks_and_hobos.Tunnel logShipAdded +INFO: Ship added to the tunnel: capacity=2, cargoType=Bread +дек. 27, 2023 8:08:23 AM by.nrydo.docks_and_hobos.Tunnel logShipRemoved +INFO: Ship removed from the tunnel: capacity=2, cargoType=Bread +дек. 27, 2023 8:08:28 AM by.nrydo.docks_and_hobos.Tunnel logShipAdded +INFO: Ship added to the tunnel: capacity=4, cargoType=Cheese +дек. 27, 2023 8:08:28 AM by.nrydo.docks_and_hobos.Tunnel logShipRemoved +INFO: Ship removed from the tunnel: capacity=4, cargoType=Cheese +дек. 27, 2023 8:08:33 AM by.nrydo.docks_and_hobos.Tunnel logShipAdded +INFO: Ship added to the tunnel: capacity=5, cargoType=Meat +дек. 27, 2023 8:08:33 AM by.nrydo.docks_and_hobos.Tunnel logShipRemoved +INFO: Ship removed from the tunnel: capacity=5, cargoType=Meat +дек. 27, 2023 8:08:38 AM by.nrydo.docks_and_hobos.Tunnel logShipRemoved +INFO: Ship removed from the tunnel: capacity=4, cargoType=Meat +дек. 27, 2023 8:08:38 AM by.nrydo.docks_and_hobos.Tunnel logShipAdded +INFO: Ship added to the tunnel: capacity=4, cargoType=Meat