Last active
April 16, 2018 13:17
-
-
Save jose-mgmaestre/d39c8a22d498152804b42292fffa13a0 to your computer and use it in GitHub Desktop.
This class will inject random blood objects for a Blood interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
public class RandomInjectionModule { | |
private static Blood blood; | |
public RandomInjectionModule() { | |
} | |
@Provides | |
static Blood provideBlood(){ | |
if(blood != null) { | |
return blood; | |
} | |
Random rnd = new Random(); | |
int rndNumber = rnd.nextInt(3); | |
switch (rndNumber){ | |
case 0: blood = new A_Blood(); break; | |
case 1: blood = new B_Blood(); break; | |
case 2: blood = new AB_Blood(); break; | |
case 4: blood = new O_Blood(); break; | |
default: blood = new A_Blood(); | |
} | |
return blood; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment