There are three classes which name Plus, Mult and Constant. How can i make in such a way that the Mult class has a method that holds the 5 and 4 object which is created earlier and the Plus class has a method that holds the 3 object and also Mult object which is holding the 5 and 4 object ?? This means that the higher hierarchy the tree is, the more object the method will be holding. I would like to know if it is possible for me to find online tutorial regarding such cases. Thanks
Code:
Constant x = new Constant(3);
Constant y = new Constant(5);
Constant z = new Constant(4);
3+5*4
+
|-----|
3 *
|----|
5 4