up
This commit is contained in:
1 parent
6f84989154
commit
9b3d8ba015
5 files changed
+34
-12
No files matched your search
@@ -3,6 +3,7 @@ package canteen;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.util.LinkedList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import desmoj.core.dist.ContDistNormal;
|
||||
@@ -13,7 +14,7 @@ import desmoj.core.simulator.ProcessQueue;
|
||||
import desmoj.core.simulator.TimeInstant;
|
||||
import desmoj.core.simulator.TimeSpan;
|
||||
|
||||
public class Canteen extends Model {
|
||||
public class Canteen extends Model implements PropertyChangeListener{
|
||||
|
||||
static int clientLeftOnInitCount = 0;
|
||||
|
||||
@@ -21,7 +22,7 @@ public class Canteen extends Model {
|
||||
private int cookCount;
|
||||
private int tableTwoCount;
|
||||
private int tableFourthCount;
|
||||
private int minMealCount;
|
||||
private int minMealCount=3;
|
||||
private int workingCookCount;
|
||||
private int eatingClientCount;
|
||||
private int avaiableSeats = 20;
|
||||
@@ -55,10 +56,10 @@ public class Canteen extends Model {
|
||||
private Dishes dishes;
|
||||
private Cashier cashier;
|
||||
private DishesStorage storage;
|
||||
|
||||
private LinkedList<Cook> cooks;
|
||||
private boolean automaticMode = true;
|
||||
protected PropertyChangeSupport change = new PropertyChangeSupport(this);
|
||||
|
||||
|
||||
public Canteen(Model model, String name, boolean showInRaport,
|
||||
boolean showInTrace) {
|
||||
super(model, name, showInRaport, showInRaport);
|
||||
@@ -69,7 +70,9 @@ public class Canteen extends Model {
|
||||
public void setParam() {
|
||||
|
||||
}
|
||||
|
||||
public void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||
this.change.addPropertyChangeListener(listener);
|
||||
}
|
||||
@Override
|
||||
public String description() {
|
||||
// TODO Auto-generated method stub
|
||||
@@ -79,9 +82,10 @@ public class Canteen extends Model {
|
||||
@Override
|
||||
public void doInitialSchedules() {
|
||||
System.out.println("InitialSchedules");
|
||||
cooks=new LinkedList<Cook>();
|
||||
clientQueue = new ProcessQueue<Client>(this, "Kolejka klientow", false,
|
||||
false);
|
||||
kitchen = new Kitchen(this, "Kitchen", false);
|
||||
kitchen = new Kitchen(this, "Kitchen", false,10);
|
||||
clientGenerator = new ClientGenerator(this, "client generator", false);
|
||||
dishes = new Dishes(getClientAveragePrice());
|
||||
clientNoPleceQueue = new ProcessQueue<Client>(this, "Kolejka klientow czekajacych na siedzenie", false,
|
||||
@@ -96,7 +100,7 @@ public class Canteen extends Model {
|
||||
groupGenerator = new GroupGenerator(this, "groupGenerator", false);
|
||||
privilegedClientGenerator = new PrivilegedClientGenerator(this,
|
||||
"privilegedClientGenerator", false);
|
||||
|
||||
|
||||
kitchen.activate(new TimeSpan(0));
|
||||
cashier.activate(new TimeSpan(0));
|
||||
clientGenerator.activate(new TimeSpan(0));
|
||||
@@ -347,6 +351,17 @@ public class Canteen extends Model {
|
||||
this.clientAveragePrice = clientAveragePrice;
|
||||
}
|
||||
|
||||
public LinkedList<Cook> getCooks() {
|
||||
change.firePropertyChange("s",1,2);
|
||||
return cooks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
System.out.println(evt.toString());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -85,6 +85,7 @@ public class Cashier extends SimProcess {
|
||||
|
||||
}
|
||||
if (dishList.get(string) <= model.getMinMealCount()) {
|
||||
System.out.println("rob " + string);
|
||||
model.getKitchen().addDishToPrepare(string);
|
||||
if (!model.getKitchen().isCurrent())
|
||||
model.getKitchen().activate();
|
||||
|
||||
@@ -116,13 +116,14 @@ public class Client extends SimProcess {
|
||||
Random rand = new Random();
|
||||
|
||||
LinkedList<String> lD = avaliableDishes.get("dish"); // dish
|
||||
selectedMenu.add(lD.get(rand.nextInt(lD.size())-1));
|
||||
selectedMenu.add(lD.get(rand.nextInt(lD.size())));
|
||||
|
||||
LinkedList<String> lS = avaliableDishes.get("soup");// soup
|
||||
selectedMenu.add(lS.get(rand.nextInt(lS.size())-1));
|
||||
selectedMenu.add(lS.get(rand.nextInt(lS.size())));
|
||||
|
||||
LinkedList<String> lDr = avaliableDishes.get("drink");// drink
|
||||
selectedMenu.add(lDr.get(rand.nextInt(lDr.size())-1));
|
||||
selectedMenu.add(lDr.get(rand.nextInt(lDr.size())));
|
||||
|
||||
}
|
||||
|
||||
public LinkedList<String> getMenu() {
|
||||
|
||||
@@ -20,9 +20,10 @@ public class Cook extends SimProcess {
|
||||
while(true){
|
||||
insertMeToIdleQueue();
|
||||
if(!model.getKitchen().isCurrent())
|
||||
model.getKitchen().activate();
|
||||
model.getKitchen().activateAfter(this);
|
||||
passivate();//zostanie zaktywownay przez kuchnie jezeli beda dostepne dania do przygotowania
|
||||
if(taskToDo!=null){ //jezeli wszystko bedzie ok to ten warunek zawsze bedzi spelniony!
|
||||
System.out.println("robie jedzenie!! " +taskToDo);
|
||||
hold(new TimeSpan(model.getMealPrepareTime(),TimeUnit.SECONDS));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -10,11 +10,15 @@ public class Kitchen extends SimProcess {
|
||||
private LinkedList<String> dishIsPreparing;
|
||||
private Canteen model;
|
||||
|
||||
public Kitchen(Model arg0, String arg1, boolean arg2) {
|
||||
public Kitchen(Model arg0, String arg1, boolean arg2,int cookNuber) {
|
||||
super(arg0, arg1, arg2);
|
||||
model = (Canteen) arg0;
|
||||
dishToPrepare = new LinkedList<String>();
|
||||
dishIsPreparing = new LinkedList<String>();
|
||||
for(int i = 0;i<cookNuber;i++){
|
||||
Cook cook=new Cook(model, "Kucharz", false);
|
||||
model.getCooks().add(cook);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user