Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the following code snippet, which (I think) is valid in a C++/Java-esque language: string toString(PlantBasedFood f) { switch(f.type) { case Apple: return ((Apple) f).
Consider the following code snippet, which (I think) is valid in a C++/Java-esque language: string toString(PlantBasedFood f) { switch(f.type) { case Apple: return ((Apple) f). AppleString(); case Banana: return ((Banana) f).BananaString(); case Carrot: return ((Carrot) f).CarrotString(); case Potato: return ((Potato) f).PotatoString(); } You can imagine that the code base is full of switch statements like this. 1. What is the impact of this style on the test-ability of the code base? For example, how many distinct inputs are needed to achieve full line coverage of this method? Full branch coverage? (2 points) 2. Describe how you could use polymorphism to reduce the number of inputs needed to achieve full line coverage of this method. (4 points) 3. Would this change be an improvement? Why or why not? (2 points)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started