Varasku

wzorzec Singleton

Nov 14th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. package javaapplicationuml;
  2.  
  3.  
  4. public class OsobaSingleton {
  5. private static OsobaSingleton instance;
  6. private String imie="";
  7. private String nazwisko="";
  8. private String pesel="";
  9.  
  10. public String getImie() {
  11. return imie;
  12. }
  13.  
  14. public void setImie(String imie) {
  15. this.imie = imie;
  16. }
  17.  
  18. public String getNazwisko() {
  19. return nazwisko;
  20. }
  21.  
  22.  
  23. public void setNazwisko(String nazwisko) {
  24. this.nazwisko = nazwisko;
  25. }
  26.  
  27.  
  28. public String getPesel() {
  29. return pesel;
  30. }
  31.  
  32. public void setPesel(String pesel) {
  33. this.pesel = pesel;
  34. }
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. private OsobaSingleton(){}
  46.  
  47.  
  48. public static OsobaSingleton getInstance()
  49. {
  50. if (instance==null)
  51. {
  52. instance = new OsobaSingleton();
  53. instance.imie="imieSingleton";
  54. instance.nazwisko="nazwiskoSingleton";
  55. instance.pesel="peselSingleton";
  56. }
  57. return instance;
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment