Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package com.upgrad.patterns.Service; import com.upgrad.patterns.Interfaces.IndianDiseaseStat; import com.upgrad.patterns.Constants.SourceType; import com.upgrad.patterns.Strategies.DiseaseShStrategy; import com.upgrad.patterns.Strategies.JohnHopkinsStrategy; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class IndiaDiseaseStatFactory { private IndianDiseaseStat diseaseShStrategy; private IndianDiseaseStat johnHopkinsStrategy;

package com.upgrad.patterns.Service;
import com.upgrad.patterns.Interfaces.IndianDiseaseStat;
import com.upgrad.patterns.Constants.SourceType;
import com.upgrad.patterns.Strategies.DiseaseShStrategy;
import com.upgrad.patterns.Strategies.JohnHopkinsStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class IndiaDiseaseStatFactory {
private IndianDiseaseStat diseaseShStrategy;
private IndianDiseaseStat johnHopkinsStrategy;
@Autowired
public IndiaDiseaseStatFactory(DiseaseShStrategy diseaseShStrategy, JohnHopkinsStrategy johnHopkinsStrategy)
{
this.diseaseShStrategy = diseaseShStrategy;
this.johnHopkinsStrategy = johnHopkinsStrategy;
}
//please write the code for this statement
//create a method named GetInstance with return type as IndianDiseaseStat and parameter of type sourceType
//create a conditional statement
//if the sourceType is JohnHopkins
//return johnHopkinsStrategy
//if the sourceType is DiseaseSh
//return diseaseShStrategy
//create a message for invalid disease strategy/sourceType
//throw the message as an Illegal argument exception
/
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Understand the parameters of mortality and morbidity.

Answered: 1 week ago