Question: What is the OODP ? class Client { Component comp; } class Component { public void op1 () {...} public void op2() {...} } class
What is the OODP ?
class Client {
Component comp;
}
class Component {
public void op1 () {...}
public void op2() {...}
}
class Leaf extends Component { public void op1 () {...}
public void op2() {...}
}
class Branch extends Component {
Set
public void op1 () {...}
public void op2() {...}
}
Component represents a base class (or possibly an interface) for primitive objects, and Branch represents a Branch class. For example, the Component class might represent a base class for graphic primitives, whereas the Branch class might represent a Drawing class. Leaf class represents a concrete primitive object; for example, a Line class or a Text class. The Operation1() and Operation2() methods represent domain-specific methods implemented by both the Component and Branch classes. The Branch class maintains a collection of components. Typically, Branch methods are implemented by iterating over that collection and invoking the appropriate method for each Component in the collection.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
