6.1.2 用eclipse环境调试一步一步学repast操作
-
Upload
zhang-shuren -
Category
Education
-
view
923 -
download
9
Transcript of 6.1.2 用eclipse环境调试一步一步学repast操作
Building the CarryDrop Building the CarryDrop simulation in Eclipsesimulation in Eclipse
Creating a new project with Creating a new project with existing code from John Murphy’s existing code from John Murphy’s RePast tutorialRePast tutorial
PreparationPreparation
For these slides you will need:For these slides you will need:– The Eclipse IDE installed and running.The Eclipse IDE installed and running.– Access to the source code from John Access to the source code from John
Murphy’s RePast Murphy’s RePast tutorialtutorial, step , step 1414..
Creating a new projectCreating a new project
Start EclipseStart Eclipse Go to File -> ProjectGo to File -> Project In the New Project In the New Project
dialog box select “Java dialog box select “Java Project” and hit the Project” and hit the Next buttonNext button
In the next screen, In the next screen, name the project and name the project and choose a location.choose a location.
Leave the default Leave the default setting for the project setting for the project layout.layout.
Creating a new project Creating a new project cont.cont.
Add RePast to the Add RePast to the build path under build path under the “Libraries” tab.the “Libraries” tab.
Click the “Finish” Click the “Finish” button.button.
Please refer to Installing Repast in the Eclipse IDE under section IV.B of the RePast Study Group homepage for details on adding the RePast jar to a project build path.
Creating a new classCreating a new class
Now that we have the Now that we have the project established we can project established we can add the first new class.add the first new class.
Go to File->New->Class. Go to File->New->Class. A New Class window should A New Class window should
appear.appear. For the Package, enter For the Package, enter
“demo”“demo” For Name, enter For Name, enter
CarryDropModel.CarryDropModel. Leave all other settings at Leave all other settings at
default values.default values. Hit the “Finish” button.Hit the “Finish” button.
The first class: The first class: CarryDropModelCarryDropModel Go to step 14 of Go to step 14 of
Murphy’s tutorial.Murphy’s tutorial. In your browser, select In your browser, select
all the Java code for all the Java code for the CarryDropModel the CarryDropModel class and go to Edit-class and go to Edit->Copy>Copy
In Eclipse, select all In Eclipse, select all the pre-written code in the pre-written code in the new the new CarryDropModelCarryDropModel
The first class: The first class: CarryDropModelCarryDropModel Go to Edit->Paste.Go to Edit->Paste. The code from the tutorial webpage should have now replaced the The code from the tutorial webpage should have now replaced the
pre-written code.pre-written code.
Adding the other classesAdding the other classes
Save the CarryDropModel in Eclipse Save the CarryDropModel in Eclipse and it is doneand it is done
Repeat the previous steps to create Repeat the previous steps to create new classes, copy code from the new classes, copy code from the tutorial, and paste it in Eclipse for both tutorial, and paste it in Eclipse for both CarryDropAgent and CarryDropSpace.CarryDropAgent and CarryDropSpace.
The CarryDrop simulation is now in The CarryDrop simulation is now in Eclipse and ready to be run. Eclipse and ready to be run.
The CaryyDrop simulationThe CaryyDrop simulation
To start the simulation, go to Run->Run…To start the simulation, go to Run->Run… In the Run dialog box CarryDropModel, In the Run dialog box CarryDropModel,
– make sure the Project name is correct make sure the Project name is correct – the Main Class box has demo.CarryDropModelthe Main Class box has demo.CarryDropModel
Hit the “Run” buttonHit the “Run” button