With the code what relationships are used? I think its composition and dependency, but if a class uses composition does that also mean they use aggregation and association?
public class Sentence {
private final ArrayList<Word> words=new ArrayList<>();
public void add(Word word){
words.add(word);
}
public void wordCount(){
System.out.println("Number of words: "+words.size());
}
}
Also what would this relationship be?
public class Worker {
private int numJobs;
public void Usemachine(Machine machine){
System.out.println("Using machine: "+machine);
numJobs++;
}
public void jobCount(){
System.out.println("Number of jobs: "+numJobs);
}
}