4 import java.io.Serializable;
5 import java.util.ArrayList;
9 * Class representing an application task
10 * @author Sébastien Miquée
13 public class GTask implements Serializable
15 private static final long serialVersionUID = 1L;
20 private ArrayList<GTask> dependencies ;
25 * Default constructor.
31 dependencies = new ArrayList<GTask>() ;
38 * @param _n Task number
40 public GTask( int _n )
44 dependencies = new ArrayList<GTask>() ;
50 * Add a dependency to the task.
51 * @param _t Dependency task
53 public void addDependance( GTask _t )
57 if( ! _t.equals( this ) && ! dependencies.contains( _t ) )
59 dependencies.add( _t ) ;
68 * Return the task's number in a string.
69 * @return A String containing the task's number
71 public String toString()
78 * Add a dependencies list to the task.
79 * @param at The dependencies list
81 public void addDependance( ArrayList<GTask> at )
85 for( int i = 0 ; i < at.size() ; i++ )
87 this.addDependance( at.get( i ) ) ;
94 * Define the task's computing weight.
95 * @param _p The computing weight
97 public void setWeight( int _p )
104 * Return the task's weight.
105 * @return The task's weight
107 public int getWeight()
114 * Return the task dependencies list.
115 * @return The dependencies list
117 public ArrayList<GTask> getDependencies()
119 return dependencies ;
124 * Return the ids of the dependences of the task in a list.
125 * @return The ids list
127 public ArrayList<Integer> getDependenciesIds()
129 ArrayList<Integer> ret = new ArrayList<Integer>() ;
131 for( int i = 0 ; i < dependencies.size() ; i++ )
133 ret.add( new Integer( dependencies.get( i ).getNum() ) ) ;
141 * Return the task's number.
142 * @return The task's number
151 * Return the amount of dependencies of the task.
152 * @return The amount of dependencies
154 public int getNbDep()
161 * Return the task's dependencies list in a text form.
162 * @return The String containing the dependencies list
164 public String printDep()
168 for( int i = 0 ; i < nb_dep ; i++ )
170 s = s + dependencies.get( i ).getNum() ;
171 if( i != nb_dep - 1 )
183 /** La programmation est un art, respectons ceux qui la pratiquent !! **/