Java Reference
In-Depth Information
11. Contact newOwner, double newMaterialsCost, double newProductionCost){
12. name = newName;
13. description = newDescription;
14. owner = newOwner;
15. materialsCost = newMaterialsCost;
16. productionCost = newProductionCost;
17. }
18.
19. public String getName(){ return name; }
20. public String getDescription(){ return description; }
21. public Contact getOwner(){ return owner; }
22. public double getMaterialsCost(){ return materialsCost; }
23. public double getProductionCost(){ return productionCost; }
24.
25. public void setMaterialsCost(double newCost){ materialsCost = newCost; }
26. public void setProductionCost(double newCost){ productionCost = newCost; }
27. public void setName(String newName){ name = newName; }
28. public void setDescription(String newDescription){ description = newDescription; }
29. public void setOwner(Contact newOwner){ owner = newOwner; }
30.
31. public void accept(ProjectVisitor v){
32. v.visitDeliverable(this);
33. }
34.
35. public ArrayList getProjectItems(){
36. return null;
37. }
38. }
Example 2.47 DependentTask.java
1. import java.util.ArrayList;
2. public class DependentTask extends Task{
3. private ArrayList dependentTasks = new ArrayList();
4. private double dependencyWeightingFactor;
5.
6. public DependentTask(){ }
7. public DependentTask(String newName, Contact newOwner,
8. double newTimeRequired, double newWeightingFactor){
9. super(newName, newOwner, newTimeRequired);
10. dependencyWeightingFactor = newWeightingFactor;
11. }
12.
13. public ArrayList getDependentTasks(){ return dependentTasks; }
14. public double getDependencyWeightingFactor(){ return dependencyWeightingFactor; }
15.
16. public void setDependencyWeightingFactor(double
newFactor){ dependencyWeightingFactor = newFactor; }
17.
18. public void addDependentTask(Task element){
19. if (!dependentTasks.contains(element)){
20. dependentTasks.add(element);
21. }
22. }
23.
24. public void removeDependentTask(Task element){
25. dependentTasks.remove(element);
26. }
27.
28. public void accept(ProjectVisitor v){
29. v.visitDependentTask(this);
30. }
31. }
Example 2.48 Project.java
1. import java.util.ArrayList;
2. public class Project implements ProjectItem{
3. private String name;
4. private String description;
5. private ArrayList projectItems = new ArrayList();
6.
7. public Project(){ }
8. public Project(String newName, String newDescription){
9. name = newName;
10. description = newDescription;
11. }
12.
13. public String getName(){ return name; }
Search WWH ::




Custom Search