Guest User

Untitled

a guest
Feb 17th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. // Iplementation of Constructor Dependency Injection
  2.  
  3. public class AnimalConstruct {
  4. private String species;
  5. private String ras;
  6.  
  7. // Constructor Dependency Injection
  8. AnimalConstruct(String species, String ras) {
  9. this.species = species;
  10. this.ras = ras;
  11. }
  12. }
  13.  
  14. public class AnimalSetValueConstruct {
  15.  
  16. AnimalConstruct animalConstruct = new AnimalConstruct( "Kucing", "Anggora" );
  17. }
  18.  
  19.  
  20. // Iplementation of Setter Dependency Injection
  21.  
  22. public class AnimalSetter {
  23. private String species;
  24. private String ras;
  25.  
  26. // Setter Dependency Injection
  27. public void setSpecies(String species) {
  28. this.species = species;
  29. }
  30.  
  31. public void setRas(String ras) {
  32. this.ras = ras;
  33. }
  34.  
  35. }
  36.  
  37. public class AnimalSetValueSetter {
  38.  
  39. public void Setter()
  40. {
  41. AnimalSetter animalSetter = new AnimalSetter();
  42. animalSetter.setSpecies("Kucing");
  43. animalSetter.setRas("Anggora");
  44. }
  45. }
Add Comment
Please, Sign In to add comment