1 building the carrydrop simulation in jbuilderx by deddy koesrindartoto 08/16/2004

11
1 Building the CarryDrop Simulation in JBuilderX By Deddy Koesrindartoto 08/16/2004

Upload: peter-summers

Post on 01-Jan-2016

215 views

Category:

Documents


1 download

TRANSCRIPT

1

Building the CarryDrop Simulation in JBuilderX

By

Deddy Koesrindartoto

08/16/2004

2

Introduction

This tutorial will explain, step by step, how to create a new project using existing RePast/Java code for a RePast Tutorial by John Murphy.

To be consistent with Murphy’s Tutorial, the project name will be Demo.jpx, and it will contain three Java class :

CarryDropModel.java; CarryDropSpace.java; CarryDropAgent.java.

To follow this tutorial you will need:• JBuilder X installed and running• RePast library installed• Access to the source code of John Murphy’s RePast Tutorial at :

http://www.u.arizona.edu/~jtmurphy/H2R/HowTo01.htm

3

Creating a Demo Project

• Start JBuilder X• Go to File -> New Project

• In the Project Wizard dialog box (Fig 2.A) fill in the project name.

• Use Demo as project name. In JBuilder, this project name will also be used as the package name.

• Leave the default settings for the rest of the fields.

Fig 1

4Creating a project Demo…continued:

Fig 2.A Fig 2.B

In Fig 2.A click the Next button (1) to configure the library/libraries that will be used in Demo project. Dialog box (Fig 2.B) will appear. Press the Required Libraries (2),and press Add button to proceed (3). Leave the default settings for the rest of thefields.

(1)

(2)

(3)

5

Setting up required libraries:

Fig 3.A Fig 3.B

Navigate through the list of libraries shown in Fig 3.A. Select RePast-2.2 library (1) and press the OK button (2). The new dialog box (Fig. 3.B) will acknowledge that the RePast-2.2 library has been added (3) to the Demo project. Leave the default settings for the rest of the fields, and click the Finish button(4).

(1)

(2)(3)

(4)

6Setting up required libraries … Continued:

Fig 4

At this point, the process of creating the Demo project is finished.Demo.jpx is now listed at the JBuilder project pane (1).

However, the project is still empty. There are no classes associated with this project. The next steps will explain how to add classes to this project.

(1)

7

Adding a Java class to the Demo project:

• The next steps will show how to add CarryDropModel.java classes to the Demo project.

• Go to File->New Class…

• A Class Wizard dialog box should appear.

Fig 5

8Adding a Java class to the Demo project... continued:

Fig 6.A

• As shown in Fig 6.A, type CarryDropModel (1) as the Class name, and leave all other settings at default values. Note that, if nothing is checked in the Options choices (2), it will generate an empty class which contains only the class name and the respective package used in this class. Hit the “OK” button (3)

• Fig 6.B shows how the CarryDropModel class now appears in the structure pane (4). Meanwhile, the CarryDropModel source code appears in content pane (5).

Fig 6.B

(1)

(2)

(4)

(5)

(3)

9Copying Murphy’s source code for CarryDropModel.java from his website:

Open your browser, and go to: http://www.u.arizona.edu/~jtmurphy/H2R/HowTo03.htm . Select and copy the whole source code for the CarryDropModel to the clipboard.

10Copying Murphy’s source code for CarryDropModel.java…continued:

(1)

(2)

Go to JBuilder content pane of CarryDropModel.java.Press Edit -> Select All (1)and then Edit -> Paste (2) . It will automatically paste the code you copied earlier from the website for CarryDropModel.java into the content pane.

11

Adding other classes to the Demo project…continued:

Repeat the same process for adding code forthe CarryDropSpace and CarryDropAgent Java classes from Murphy’s website.

When all three classes are added, they will be listed by name in project pane (1) and their code will be shown in content pane (2).

Follow the Murphy Tutorial and modify these three .java classes as needed.

(1)

(2)