我已經得到了大部分程序,除了一些不是的,我是新來的Java,所以它不是很明顯,我打算做什麼。獲取方法在一個簡單的Java程序中工作
這裏是方法:
public String getInventoryCode()
{
return inventoryCode;
}
public int getQuantityInStock()
{
return quantityInStock;
}
public int getDailyDemand()
{
return dailyDemand;
}
public int getReOrder()
{
return reOrder;
}
public int getLeadTime()
{
return leadTime;
}
public int newDeliveryIn(int newDeli)
{
quantityInStock += reOrder;
return newDeli;
}
下面是主要代碼:
StockItem item_1 = new StockItem("A654Y", 1000, 50, 500, 13);
int quantityIn = item_1.getQuantityInStock();
for (int n = 1; n <=50 ; n++)
{
quantityIn -= item_1.getDailyDemand();
System.out.print(n + "\t");
System.out.println(quantityIn);
if (n % item_1.getLeadTime() == 1){
System.out.println("Batch Ordered");
}
else if (n % item_1.getLeadTime() == 0){
quantityIn += item_1.getReOrder();
System.out.println("Batch Received");
}
}
這是其計算天數達50一個簡單的庫存控制程序,每天減少的庫存量(數量InStock)乘以X數量(dailyDemand),然後當它達到某一天(例如每隔10天(還沒有爲此做出一個方法,因爲不知道如何去做)它會訂購更多的股票(reOrder )將在一定天數後交付並添加到當前股票中訂單後(leadTime)。我想我幾乎在那裏,只是我無法解決的最後一點。
這是輸出我的那一刻得到:
1 950
Batch Ordered
2 900
3 850
4 800
5 750
6 700
7 650
8 600
9 550
10 500
11 450
12 400
13 350
Batch Received
14 800
Batch Ordered
15 750
16 700
17 650
18 600
19 550
20 500
21 450
22 400
23 350
24 300
25 250
26 200
Batch Received
27 650
Batch Ordered
...
我還要「批量訂購,已批量收到」去旁邊的有關日期(第3列),而不是之下,但可以如何解決問題。
任何幫助將是偉大的!謝謝。
很好,謝謝。你有什麼想法解決我在問題中提到的問題嗎?總而言之,我想將其設置爲在X天進行訂單,然後X天后訂單將交付並添加到quantityIn。非常感謝 – Liam 2014-12-01 22:54:06
@James Sure,如何「確定它在X天訂購」確定?當物品數量低於一個數字?每10天? – 2014-12-01 23:03:00
真棒謝謝,我刪除了我的最後一條評論,試圖標記你但沒有工作。再次感謝:) – Liam 2014-12-01 23:12:43