문제

If we treat tree as an object then what will be its leaf and branches?
Similarly, if we treat dog as an object then what will be its legs,mouth and eyes?

도움이 되었습니까?

해결책

A tree HAS a set of branches. Each branch HAS a set of leaves.

That is, (pseudocode)

class Tree {
    Branch[] branches;
}

class Branch {
    Leaf[] leaves;
}


class Leaf {

}

Similarly with the dog: a dog HAS a collection of eyes; it also has a collection of legs; and it has a mouth.

class Dog {
    Leg[] legs;
    Mouth mouth;
    Eye[] eyes;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top