Doubt in module 6

i am stuck at, portfoliomanagerimpl class, as before module6 i was doing everything in this class like calculateannualisedreturn,getstockquotes, and builduri as my default provider was tiingo, but in module 6 there is alphavantage also, so 2 methods(getstockquotes and builduri) should be handled by the 2 implementation of stockquoteservice i.e. tiingoservice and alphavantageservice,
so there should be no need of these 2 methods in impl class but since every module checks for preios module tests as well, i need to keep my previous codes as well because previous testcases do not provide any stockquoteservice as parameter,
here i am stuck, how to handle both cases together, that it passes module 6 and before cases as well.i tried doing stockquoteservice = new tiingoservice by default,but apparently i can’t access tiingo service constructor through impl class since its protected, any hints please? or am i thinking in wrong direction?

You dont have to change anything from previous part of the code, they were working fine and they will work fine, you just have to add the new functionality, understand the factory pattern based on which the classes are created for tiingo and alpha.
you can always create a new constructor for the class which will take arguments as defined by you, there is no need to delete or modify previous constructor.

thanks for replying kunal , that’s why i am not changing anything from previous codes as it will fail otherwise, i am just saying, for module 6 individually there is no need of getstockquotes and builduri in impl class as these methods are handled by tiingocandle and alphavantageservice right?
so , how not to use these methods in impl class during assessment for module 6,as i can’t right 2 same methods for two scenarios right? please point me right direction,I think i am a bit lost

Now from the names of these two methods we can notice few things:
builduri what is this function doing ? Providing url for the api as string, am i right? In that case where should be that function used, maybe somewhere in a file where we are converting url for tiingo or alphavantage as string. So can you determine which file among the files you have to edit is making use of this function. You can use your builduri method there.
Secondly for the getStockQuote function if you will see its different from the previous in the sense now its not only responsible for getting stocks for tiingo api but as well as alphavantage api, try to figure out how you can solve this.

so, can i do like check if stockquote !=null i will find list by object.getstockQuotes() and if ==null then proceed to already written code?

Hey @anmol1point0 i didn’t get you what are you trying to say exactly in which part or file or function you are having confusion as @Kunal explained things are quite clear.

You can have one single getStockQuote function but you can call a specific constructor in the getStockQuote which is whether the previous one or new one, it is for you to figure out when you would call which constructor :slight_smile: