It is now time to put our newly-learned skills into practice. Here is a new requirement to build into the Stock
class:
Sometimes, updates might come out of order and we might get an update for a newer timestamp, followed by an update for an older timestamp. This could be due to random network latency, or due to the fact that sometimes we might get updates from different sources and one might be slightly ahead of the other.
The
Stock
class should be able to handle such cases, and theprice
attribute should return the latest price as per the timestamp.The
is_increasing_trend
should also process the latest three prices as per their timestamps.
Try your hand at implementing this requirement. Do not make any changes to the existing interfaces for these methods, but feel free to make any changes to the implementation as you require. Here are some things to think about:
Does our existing design support this new feature? Do we need to make any changes to the current design?
What kind of tests...