Exemple #1
0
 public Activity addActivity(
     String activityName, int activityDuration, String predecessors[], int activityResources[]) {
   Activity newActivity = null;
   if (this.isUnique(activityName)) {
     newActivity =
         new Activity(
             activityName, activityDuration, activityResources, this.getMaxNumOfResources());
     // the predecessors of START are NULL
     if (predecessors != null) {
       if (predecessors.length == 0) {
         Activity current = getActivityByName("START");
         newActivity.addPredecessor(current);
         current.addSuccessor(newActivity);
       } else {
         for (int i = 0; i < predecessors.length; i++) {
           Activity current = getActivityByName(predecessors[i]);
           if (current != null) {
             newActivity.addPredecessor(current);
             current.addSuccessor(newActivity);
           } else {
             view.printDebugln(
                 "Cannot add predecessor relation to non-exisiting node " + predecessors[i]);
           }
         }
       }
     }
     activities.add(newActivity);
   } else {
     // activity name is not unique or activity already exists
     view.printDebugln(
         "Cannot add activity " + activityName + " because the name already exists.");
   }
   return newActivity;
 }
Exemple #2
0
 private void addArc(String from, String to) {
   Activity activityFrom = getActivityByName(from);
   Activity activityTo = getActivityByName(to);
   if (activityFrom != null && activityTo != null) {
     activityFrom.addSuccessor(activityTo);
     activityTo.addPredecessor(activityFrom);
   } else view.printDebugln("Cannot add arc: at least one activity is currently not present.");
 }