Forums Register Login

How to get total

+Pie Number of slices to send: Send
Hello Friends,

Please find my code as follow:


I am just trying to implement decorator pattern, but I am not getting how can I get method.

I would appreciate if any one can help me.

Thanking You,
Kasparov
+Pie Number of slices to send: Send
I'm not sure of your reasons for using the decorator pattern here but if Discount and or Reduction are supposed to be your decorator classes then you need to pass an instance of the object they are supposed to decorate into the constructor and then in the getPrice() method you would call getPrice() on the object which you are decorating. Currently your Discount and Reduction classes recursively call their own getPrice() method with no way of exiting the recursive calls.
What's that smell? Hey, sniff this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 576 times.
Similar Threads
Abstract method query
Abstract inner class in the abstract outer class
Legal Method Declarations II
modifier for enum
static with abstract
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:40:40.