化之前的代码:
WareHouse wh0 = new WareHouse("Task", Task0);
WareHouse wh1 = new WareHouse("Task", Task1);
WareHouse wh2 = new WareHouse("Task", Task2);
WareHouse wh3 = new WareHouse("Task", Task3);
WareHouse wh4 = new WareHouse("Task", Task4);
//后面要使用wh0,wh1,wh2,wh3,wh4
优化之后的代码:
WareHouse wh0 = setWareHouse(Task0);
WareHouse wh1 = setWareHouse(Task1);
WareHouse wh2 = setWareHouse(Task0);
WareHouse wh3 = setWareHouse(Task1);
WareHouse wh4 = setWareHouse(Task0);
public WareHouse setWareHouse(String Task){
WareHouse wh = new WareHouse("Task", Task);
return wh;
}
WareHouse wh0 = new WareHouse("Task", Task0);
WareHouse wh1 = new WareHouse("Task", Task1);
WareHouse wh2 = new WareHouse("Task", Task2);
WareHouse wh3 = new WareHouse("Task", Task3);
WareHouse wh4 = new WareHouse("Task", Task4);
//后面要使用wh0,wh1,wh2,wh3,wh4
优化之后的代码:
WareHouse wh0 = setWareHouse(Task0);
WareHouse wh1 = setWareHouse(Task1);
WareHouse wh2 = setWareHouse(Task0);
WareHouse wh3 = setWareHouse(Task1);
WareHouse wh4 = setWareHouse(Task0);
public WareHouse setWareHouse(String Task){
WareHouse wh = new WareHouse("Task", Task);
return wh;
}