nus-cs2103-AY2223S2 / forum

12 stars 0 forks source link

Display inherited methods in class diagram #422

Closed anchengyang closed 1 year ago

anchengyang commented 1 year ago

Hi all, I would like to check that based on the practice paper part 2, the UiWidget inherits from the ProgressWatcher class. Why does it contain the update() method from the Watcher interface? In tutorial, we were told that we do not need to include methods that we inherited from interfaces or abstract classes. This can be seen from Item implementing Billable.

Here are pictures from the practice paper part 2 answer as well as tutorial week 8. image image

joellow88 commented 1 year ago

I believe as UIWidget is not an abstract class, any abstract methods in its parent classes or implemented interfaces will have to be implemented (else the code won't compile). Since update() is not implemented in ProgressWatcher, it will have to be implemented in UiWidget.

In the tutorial week 8 solution you showed, bill() need not appear in Item if bill() is not implemented in item. This is allowed as Item is still an abstract class. Any (non-abstract) class that inherits from Item will have to implement the bill() method, so the bill() method will appear in those classes instead.

anchengyang commented 1 year ago

@joellow88 ohh thanks so if the question says that the abstract class Item implements the method bill() method, i will need to show bill() in the diagram?

damithc commented 1 year ago

@joellow88 ohh thanks so if the question says that the abstract class Item implements the method bill() method, i will need to show bill() in the diagram?

@anchengyang Yes.

anchengyang commented 1 year ago

@joellow88 @damithc thank you!