import java.util.Map; import resources.StockManagement; public class TestMain { public static void main(String[] args) { StockManagement stockMan = new StockManagement(); stockMan.arrive(10, "A"); System.out.println("Arrive A: 10"); stockMan.arrive(20, "B"); System.out.println("Arrive B: 20"); Map<String, Integer> stock1 = stockMan.getStock(); Map<String, Integer> shortage1 = stockMan.getShortage(); Map.Entry<String, Integer> shipping1 = stockMan.getShipping(); System.out.println("stock:"); System.out.println("A: " + stock1.get("A")); System.out.println("B: " + stock1.get("B")); System.out.println("shotage:"); System.out.println("A: " + shortage1.get("A")); System.out.println("B: " + shortage1.get("B")); System.out.println("shipping:"); if (shipping1 != null) System.out.println(shipping1.getKey() +": " + shipping1.getValue()); stockMan.req(5, "A"); System.out.println("Request A: 5"); Map<String, Integer> stock2 = stockMan.getStock(); Map<String, Integer> shortage2 = stockMan.getShortage(); Map.Entry<String, Integer> shipping2 = stockMan.getShipping(); System.out.println("stock:"); System.out.println("A: " + stock2.get("A")); System.out.println("B: " + stock2.get("B")); System.out.println("shotage:"); System.out.println("A: " + shortage2.get("A")); System.out.println("B: " + shortage2.get("B")); System.out.println("shipping:"); if (shipping2 != null) System.out.println(shipping2.getKey() +": " + shipping2.getValue()); stockMan.req(10, "A"); System.out.println("Request A: 10"); Map<String, Integer> stock3 = stockMan.getStock(); Map<String, Integer> shortage3 = stockMan.getShortage(); Map.Entry<String, Integer> shipping3 = stockMan.getShipping(); System.out.println("stock:"); System.out.println("A: " + stock3.get("A")); System.out.println("B: " + stock3.get("B")); System.out.println("shotage:"); System.out.println("A: " + shortage3.get("A")); System.out.println("B: " + shortage3.get("B")); System.out.println("shipping:"); if (shipping3 != null) System.out.println(shipping3.getKey() +": " + shipping3.getValue()); stockMan.arrive(10, "A"); System.out.println("Arrive A: 10"); Map<String, Integer> stock4 = stockMan.getStock(); Map<String, Integer> shortage4 = stockMan.getShortage(); Map.Entry<String, Integer> shipping4 = stockMan.getShipping(); System.out.println("stock:"); System.out.println("A: " + stock4.get("A")); System.out.println("B: " + stock4.get("B")); System.out.println("shotage:"); System.out.println("A: " + shortage4.get("A")); System.out.println("B: " + shortage4.get("B")); System.out.println("shipping:"); if (shipping4 != null) System.out.println(shipping4.getKey() +": " + shipping4.getValue()); } }