2022-04-05
1267 words
6 minutes
OOP CS Decomposition & Generalization Association Loosely coupled relationship between two objects. Below are the code representation.
UML represents this with solid line.
public class Student{ public void play(Sport sport){ ... } } public class Wine{ public void pair( food){ ... } } Aggregation More like has a relationship where a whole has parts that belong to it. The code example is below.
Uml represents with empty diamond. Diamond is on the class that has other class.
public class Airliner{ private ArrayList<CrewMember> crew; public Airliner(){ crew = new ArrayList<CrewMember>(); } public void add(CrewMember crewMember) { ... } } public class PetStore{ private ArrayList<Pet> pets; public PetStore(){ pets = new ArrayList<Pet>(); } public void add(Pet pet){ .