Newer
Older
StockManagement / StockManagement / src / Deriver.java
import java.util.*;

public class Deriver {
	private Map.Entry<String, Integer> available;
	private Map.Entry<String, Integer> request;
	private Stock stock;
	private Map.Entry<String, Map.Entry<Integer, Integer>> value;
	public void updateAvailable(Map.Entry<String, Integer> available, Map<String, Integer> shortage) {
		this.available = available;
		Map.Entry<String, Map.Entry<Integer, Integer>> temp_if2;
		int temp_get4;
		if (shortage.get(available.getKey()) != null) {
			temp_get4 = shortage.get(available.getKey());
		} else {
			temp_get4 = 0;
		}
		if ((available.getValue()>=temp_get4)) {
			int temp_get5;
		if (shortage.get(available.getKey()) != null) {
			temp_get5 = shortage.get(available.getKey());
		} else {
			temp_get5 = 0;
		}
		int temp_get6;
		if (shortage.get(available.getKey()) != null) {
			temp_get6 = shortage.get(available.getKey());
		} else {
			temp_get6 = 0;
		}
			temp_if2 = new AbstractMap.SimpleEntry<>(available.getKey(), new AbstractMap.SimpleEntry<>(temp_get5, (available.getValue()-temp_get6)));
		} else {
			temp_if2 = new AbstractMap.SimpleEntry<>(available.getKey(), new AbstractMap.SimpleEntry<>(0, available.getValue()));
		}
		value = temp_if2;
		this.stock.updateDeriver(value);
	}
	public void updateRequest(Map.Entry<String, Integer> request, Map<String, Integer> stock) {
		this.request = request;
		Map.Entry<String, Map.Entry<Integer, Integer>> temp_if3;
		int temp_get7;
		if (stock.get(request.getKey()) != null) {
			temp_get7 = stock.get(request.getKey());
		} else {
			temp_get7 = 0;
		}
		if ((temp_get7>=request.getValue())) {
			int temp_get8;
		if (stock.get(request.getKey()) != null) {
			temp_get8 = stock.get(request.getKey());
		} else {
			temp_get8 = 0;
		}
			temp_if3 = new AbstractMap.SimpleEntry<>(request.getKey(), new AbstractMap.SimpleEntry<>(request.getValue(), (temp_get8-request.getValue())));
		} else {
			int temp_get9;
		if (stock.get(request.getKey()) != null) {
			temp_get9 = stock.get(request.getKey());
		} else {
			temp_get9 = 0;
		}
			temp_if3 = new AbstractMap.SimpleEntry<>(request.getKey(), new AbstractMap.SimpleEntry<>(0, temp_get9));
		}
		value = temp_if3;
		this.stock.updateDeriver(value);
	}
	public Deriver(Stock stock) {
		this.stock = stock;
	}
	public Map.Entry<String, Map.Entry<Integer, Integer>> getValue() {
		return new AbstractMap.SimpleEntry<>(value);
	}
}