我正在使用Anylogic的Process Modeling Library Build 一个模型 . 我有一个名为“Customer”的代理类,它有一个名为“VIP”的布尔变量 . 我有两个源创建Customer类型的实例 . 我想访问创建的每个实例的变量“VIP”,因此我可以在第一个源中将其设置为true,并在第二个源中将其设置为“false” . 当我对它们进行排序时,如何在“source”或“selectOutput”中访问每个实例的类字段“VIP”?
谢谢
您可以通过 Source 块的操作执行此操作,例如,在其On On Exit操作中: agent.VIP = true;
Source
agent.VIP = true;
agent 是局部变量,指向此时正离开 Source 块的代理程序 . 您可以在Bank Office tutorial中学习局部变量 .
agent
使用数据名称创建类的新实例,例如:
Customer john = new Customer(); Customer jane = new Customer();
在您的客户类中,我建议对vip使用getter和setter方法,例如:
public static void getVIP() { return VIP; } public static void setVIP(boolean choice) { VIP = choice; }
然后只需为您的实际对象实例名称执行此操作
john.setVIP(true); jane.setVIP(false);
2 回答
您可以通过
Source
块的操作执行此操作,例如,在其On On Exit操作中:agent.VIP = true;
agent
是局部变量,指向此时正离开Source
块的代理程序 . 您可以在Bank Office tutorial中学习局部变量 .使用数据名称创建类的新实例,例如:
在您的客户类中,我建议对vip使用getter和setter方法,例如:
然后只需为您的实际对象实例名称执行此操作