Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/mrd/models/cagn/Agent.java


1   /*
2    * Copyright (C) 2002-2003, Mark Diggory
3    *
4    * This file is part of the CAGN model project.
5    *
6    * This program is free software; you can redistribute it and/or modify
7    * it under the terms of the GNU General Public License as published by
8    * the Free Software Foundation; either version 2 of the License, or
9    * (at your option) any later version.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.
15   *
16   * You should have received a copy of the GNU General Public License
17   * along with this program; if not, write to the Free Software
18   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. License
19   * information is also available at http://www.gnu.org.
20   *
21   */
22  package org.mrd.models.cagn;
23  
24  import uchicago.src.sim.gui.*;
25  import uchicago.src.sim.engine.Stepable;
26  
27  /**
28   * Used to supply "standard" methods to Agents
29   * that use the Landscape object.
30   * @author Mark Diggory <mdiggory@latte.harvard.edu>
31   */
32  public abstract class Agent implements Stepable, Drawable{
33      
34      /** Constant representing an alive Agent in the model. Is used to identify
35       * live agents on the landscape
36       */
37      public static final int ALIVE = 0;
38      
39      /** Constant representing a dead Agent in the landscape. Is used to reap
40       * dead agents from the landscape
41       */
42      public static final int DEAD = -1;
43      
44      /** Holds value of property x (the agents location). */
45      protected int x;
46      
47      /** Holds value of property y (the agents location). */
48      protected int y;
49      
50      /** Holds value of property stage. */
51      protected int stage = ALIVE;
52      
53      /** Holds value of property landscape. */
54      protected Landscape landscape;
55      
56      /** Abstract step() method must be overridden in Agents that
57       *  extend this class
58       */
59      public abstract void step();
60      
61      /** Abstract draw() method must be overridden in Agents that
62       *  extend this class
63       * @param g graphics object to draw this in.
64       */
65      public abstract void draw(SimGraphics g);
66      
67      /** Setter for property stage.
68       * @param stage New value of property stage.
69       */
70      public void setStage(int stage) {
71          this.stage = stage;
72      }
73      
74      /** Getter for property stage.
75       * @return Value of property stage.
76       */
77      public int getStage() {
78          return stage;
79      }
80      
81      /** Getter for property x.
82       * @return Value of property x.
83       */
84      public int getX() {
85          return this.x;
86      }
87      
88      /** Getter for property y.
89       * @return Value of property y.
90       */
91      public int getY() {
92          return this.y;
93      }
94      
95      /** Setter for property x.
96       * @param x New value of property x.
97       */
98      public void setX(int x) {
99          this.x = x;
100     }
101     
102     /** Setter for property y.
103      * @param y New value of property y.
104      */
105     public void setY(int y) {
106         this.y = y;
107     }
108     
109     /** Getter for property landscape.
110      * @return Value of property landscape.
111      */
112     public Landscape getLandscape() {
113         return this.landscape;
114     }
115     
116     /** Setter for property landscape.
117      * @param landscape New value of property landscape.
118      */
119     public void setLandscape(Landscape landscape) {
120         this.landscape = landscape;
121     }
122 
123 }