dodanie klas Table oraz male zmiany w Canteen
This commit is contained in:
1 parent
c2aeaab573
commit
85c177647b
6 files changed
+103
-56
No files matched your search
+40
-45
@@ -23,13 +23,9 @@ public class Canteen extends Model implements Runnable
|
||||
|
||||
private AnimPanel animPanel;
|
||||
|
||||
private int cashierCount;
|
||||
private int cookCount;
|
||||
private int tableTwoCount;
|
||||
private int tableFourthCount;
|
||||
private int cashierCount=0;
|
||||
private int cookCount=0;
|
||||
private int minMealCount = 3;
|
||||
private int workingCookCount;
|
||||
private int eatingClientCount;
|
||||
private int avaiableSeats = 20;
|
||||
|
||||
private ContDistUniform clientServiceTime;
|
||||
@@ -59,9 +55,9 @@ public class Canteen extends Model implements Runnable
|
||||
private GroupGenerator groupGenerator;
|
||||
private PrivilegedClientGenerator privilegedClientGenerator;
|
||||
private Dishes dishes;
|
||||
private Cashier cashier;
|
||||
private DishesStorage storage;
|
||||
private LinkedList<Cook> cooks;
|
||||
private LinkedList<Cashier> cashiers;
|
||||
private boolean automaticMode = true;
|
||||
|
||||
protected PropertyChangeSupport change = new PropertyChangeSupport(this);
|
||||
@@ -72,6 +68,8 @@ public class Canteen extends Model implements Runnable
|
||||
change.addPropertyChangeListener(animPanel);
|
||||
change.addPropertyChangeListener("cookCount", animPanel);
|
||||
change.addPropertyChangeListener("tableTwoCount", animPanel);
|
||||
cooks = new LinkedList<Cook>();
|
||||
cashiers = new LinkedList<Cashier>();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@@ -92,32 +90,41 @@ public class Canteen extends Model implements Runnable
|
||||
@Override
|
||||
public void doInitialSchedules() {
|
||||
System.out.println("InitialSchedules");
|
||||
cooks = new LinkedList<Cook>();
|
||||
this.addCashier();
|
||||
this.addCashier();
|
||||
this.addCook();
|
||||
this.addCook();
|
||||
this.addCook();
|
||||
this.addCook();
|
||||
cookIdleQueue = new ProcessQueue<Cook>(this,
|
||||
"Kolejka nudzacych sie kucharzy", false, false);
|
||||
clientQueue = new ProcessQueue<Client>(this, "Kolejka klientow", false,
|
||||
false);
|
||||
kitchen = new Kitchen(this, "Kitchen", false, 3);
|
||||
clientGenerator = new ClientGenerator(this, "client generator", false);
|
||||
dishes = new Dishes(getClientAveragePrice());
|
||||
clientNoPleceQueue = new ProcessQueue<Client>(this,
|
||||
"Kolejka klientow czekajacych na siedzenie", false, false);
|
||||
cashierIdleQueue = new ProcessQueue<Cashier>(this,
|
||||
"Kolejka wolnych kasjerow", false, false);
|
||||
|
||||
cashier = new Cashier(this, "cashier", false);
|
||||
|
||||
storage = new DishesStorage(dishes.averagePrice, 5, this);
|
||||
|
||||
clientGenerator = new ClientGenerator(this, "client generator", false);
|
||||
groupGenerator = new GroupGenerator(this, "groupGenerator", false);
|
||||
privilegedClientGenerator = new PrivilegedClientGenerator(this,
|
||||
"privilegedClientGenerator", false);
|
||||
|
||||
dishes = new Dishes(getClientAveragePrice());
|
||||
kitchen = new Kitchen(this, "Kitchen", false);
|
||||
storage = new DishesStorage(dishes.averagePrice, 5, this);
|
||||
|
||||
kitchen.activate(new TimeSpan(0));
|
||||
cashier.activate(new TimeSpan(0));
|
||||
clientGenerator.activate(new TimeSpan(0));
|
||||
groupGenerator.activate(new TimeSpan(0));
|
||||
privilegedClientGenerator.activate(new TimeSpan(0));
|
||||
|
||||
|
||||
for (Cook cook : cooks) {
|
||||
cook.activate(new TimeSpan(0));
|
||||
}
|
||||
for (Cashier cashier : cashiers) {
|
||||
cashier.activate(new TimeSpan(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -165,7 +172,7 @@ public class Canteen extends Model implements Runnable
|
||||
exp = new Experiment("Symulacja stolowki");
|
||||
connectToExperiment(exp);
|
||||
exp.stop(new TimeInstant(3600*8, TimeUnit.SECONDS));
|
||||
//setDelay(1);
|
||||
setDelay(1);
|
||||
|
||||
exp.start();
|
||||
|
||||
@@ -203,27 +210,6 @@ public class Canteen extends Model implements Runnable
|
||||
this.cookCount = cookCount;
|
||||
}
|
||||
|
||||
public int getTableTwoCount() {
|
||||
return tableTwoCount;
|
||||
}
|
||||
|
||||
public void setTableTwoCount(int tableTwoCount) {
|
||||
change.firePropertyChange("tableTwoCount", this.tableTwoCount,
|
||||
tableTwoCount);
|
||||
this.tableTwoCount = tableTwoCount;
|
||||
|
||||
}
|
||||
|
||||
public int getTableFourthCount() {
|
||||
return tableFourthCount;
|
||||
}
|
||||
|
||||
public void setTableFourthCount(int tableFourthCount) {
|
||||
change.firePropertyChange("tableFourthCount", this.tableFourthCount,
|
||||
tableFourthCount);
|
||||
this.tableFourthCount = tableFourthCount;
|
||||
}
|
||||
|
||||
public int getMinMealCount() {
|
||||
return minMealCount;
|
||||
}
|
||||
@@ -309,8 +295,6 @@ public class Canteen extends Model implements Runnable
|
||||
}
|
||||
|
||||
public void setAvaiableSeats(int avaiableSeats) {
|
||||
change.firePropertyChange("tableTwoCount", this.tableTwoCount,
|
||||
tableTwoCount);
|
||||
this.avaiableSeats = avaiableSeats;
|
||||
}
|
||||
|
||||
@@ -334,9 +318,6 @@ public class Canteen extends Model implements Runnable
|
||||
return storage;
|
||||
}
|
||||
|
||||
public Cashier getCashier() {
|
||||
return cashier;
|
||||
}
|
||||
|
||||
public Kitchen getKitchen() {
|
||||
return kitchen;
|
||||
@@ -371,7 +352,21 @@ public class Canteen extends Model implements Runnable
|
||||
public LinkedList<Cook> getCooks() {
|
||||
return cooks;
|
||||
}
|
||||
|
||||
public void addCashier(){
|
||||
Cashier cashier = new Cashier(this,"Cashier",false);
|
||||
cashierCount++;
|
||||
cashiers.add(cashier);
|
||||
|
||||
}
|
||||
public void addCook(){
|
||||
Cook cook = new Cook(this,"Cashier",false);
|
||||
cookCount++;
|
||||
cooks.add(cook);
|
||||
|
||||
}
|
||||
public LinkedList<Cashier> getCashiers() {
|
||||
return cashiers;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -10,16 +10,12 @@ public class Kitchen extends SimProcess {
|
||||
private LinkedList<String> dishIsPreparing;
|
||||
private Canteen model;
|
||||
|
||||
public Kitchen(Model arg0, String arg1, boolean arg2,int cookNuber) {
|
||||
public Kitchen(Model arg0, String arg1, boolean arg2) {
|
||||
super(arg0, arg1, arg2);
|
||||
model = (Canteen) arg0;
|
||||
dishToPrepare = new LinkedList<String>();
|
||||
dishIsPreparing = new LinkedList<String>();
|
||||
for(int i = 0;i<cookNuber+1;i++){
|
||||
Cook cook=new Cook(model, "Kucharz", false);
|
||||
model.getCooks().add(cook);
|
||||
model.cookIdleQueue.insert(cook);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package canteen;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import desmoj.core.simulator.Entity;
|
||||
import desmoj.core.simulator.Model;
|
||||
|
||||
|
||||
public class Table extends Entity{
|
||||
|
||||
protected ArrayList<Client> clientsAtTheTable;
|
||||
int hasSeats;
|
||||
public Table(Model arg0, String arg1, boolean arg2) {
|
||||
super(arg0, arg1, arg2);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
public void addClient(Client client){
|
||||
clientsAtTheTable.add(client);
|
||||
|
||||
}
|
||||
|
||||
public void removeClient(Client client){
|
||||
clientsAtTheTable.remove(client);
|
||||
}
|
||||
|
||||
public int getClientCount(){
|
||||
return clientsAtTheTable.size();
|
||||
}
|
||||
public int getEmpySeatCount(){
|
||||
return hasSeats-clientsAtTheTable.size();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package canteen;
|
||||
|
||||
import desmoj.core.simulator.Model;
|
||||
|
||||
public class Table2Seats extends Table{
|
||||
|
||||
public Table2Seats(Model arg0, String arg1, boolean arg2) {
|
||||
super(arg0, arg1, arg2);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package canteen;
|
||||
|
||||
import desmoj.core.simulator.Model;
|
||||
|
||||
public class Table4Seat extends Table {
|
||||
|
||||
public Table4Seat(Model arg0, String arg1, boolean arg2) {
|
||||
super(arg0, arg1, arg2);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,9 +12,6 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
|
||||
import canteen.Canteen;
|
||||
import desmoj.core.dist.ContDistNormal;
|
||||
|
||||
public class StartPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -262,8 +259,8 @@ public class StartPanel extends JPanel
|
||||
|
||||
frame.getCanteen().setCashierCount((int)cashierSpinner.getValue());
|
||||
frame.getCanteen().setCookCount((int)cookSpinner.getValue());
|
||||
frame.getCanteen().setTableTwoCount((int)table2Spinner.getValue());
|
||||
frame.getCanteen().setTableFourthCount((int)table4Spinner.getValue());
|
||||
// frame.getCanteen().setTableTwoCount((int)table2Spinner.getValue());
|
||||
// frame.getCanteen().setTableFourthCount((int)table4Spinner.getValue());
|
||||
frame.getCanteen().setMinMealCount((int)minValueIngredientSpinner.getValue());
|
||||
//frame.getCanteen().setClientArrivialTime(Double.parseDouble(Integer.toString((int)minTimeClientSpinner.getValue())), Double.parseDouble(Integer.toString((int)maxTimeClientSpinner.getValue())));
|
||||
|
||||
|
||||
Reference in new issue
Block a user