Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Jade库-容器之间的代理移动_Java_Containers_Agent_Agents Jade_Mobility - Fatal编程技术网

Java Jade库-容器之间的代理移动

Java Jade库-容器之间的代理移动,java,containers,agent,agents-jade,mobility,Java,Containers,Agent,Agents Jade,Mobility,我编写了一段代码,表示使用跨容器旅行的代理。我的代理具有循环行为,它使用一个简单的switch case语句来跨容器移动。它在“主容器”上运行,然后转到“容器-1”,然后转到“容器-2”,然后转到“容器-1”,依此类推! 问题是当它想回来的时候,它没有!关于unknown容器或类似的内容没有错误 /* * To change this template, choose Tools | Templates * and open the template in the editor. */ pack

我编写了一段代码,表示使用跨容器旅行的代理。我的代理具有
循环行为
,它使用一个简单的
switch case
语句来跨容器移动。它在“主容器”上运行,然后转到“容器-1”,然后转到“容器-2”,然后转到“容器-1”,依此类推! 问题是当它想回来的时候,它没有!关于unknown
容器
或类似的内容没有错误

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package MyAgentPool;

import jade.core.Agent;
import jade.core.ContainerID;
import jade.core.behaviours.CyclicBehaviour;

/**
 *
 * @author King Hadi
*/
public class MyAgent00 extends Agent {       
@Override
protected void takeDown() {
    // TODO Auto-generated method stub
    super.takeDown();
    System.out.print("goodbye!");
}

@Override
protected void setup() {
    // TODO Auto-generated method stub
    super.setup();
    System.out.println("Hello I'm " + this.getLocalName());
    this.addBehaviour(new MyBehaviour());
   }
}

class MyBehaviour extends CyclicBehaviour {

private int step = 0;

@Override
public void action() {
    // TODO Auto-generated method stub
    switch (step) {
        case 0: {
            System.out.println("step variable is: "+ step);
            step++;
            ContainerID destination = new ContainerID();
            destination.setName("Container-2");                                
            System.out.println("waiting 2 seconds! before traveling ... ");
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }                

            myAgent.doMove(destination);
            break;
        }
        case 1: {
            System.out.println("step variable is: "+ step);
            step++;
            ContainerID destination1 = new ContainerID();
            destination1.setName("Container-1");                
            System.out.println("waiting 2 seconds! before traveling ... ");
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }                

            myAgent.doMove(destination1);
            break;
        }
        case 2: {
            System.out.println("step variable is: "+ step);
            step--;
            ContainerID destination2 = new ContainerID();
            destination2.setName("Container-2");                                
            System.out.println("waiting 2 seconds! before traveling ...");
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }                                
            myAgent.doMove(destination2);
            break;
        }
        default: {
            System.out.println("step variable is: "+ step);
            step = 0;
            ContainerID destination = new ContainerID();
            destination.setName("Main-Contianer");
            myAgent.doMove(destination);
            System.out.println("waiting 2 seconds! before traveling ...");

            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }                
            break;
        }
    }
}
}
有人知道为什么这个代码不起作用吗?
谢谢!:)

您在默认开关语句中犯了拼写错误:

destination.setName("Main-Contianer");
应该是:

destination.setName("Main-Container");

部署它时会发生什么?请澄清