Advertisement
Guest User

TrainingSession

a guest
May 22nd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. public class CatFactory {
  2. HashMap<String ,String> kittens = new HashMap<String , String>(5);
  3.  
  4. public void createKittens() {
  5. kittens.put("Black","Alisa");
  6. kittens.put("Gray","Viktor");
  7. kittens.put("Gray","Dima");
  8. kittens.put("Black","Akula");
  9. kittens.put("Gray","Sveta");
  10. }
  11.  
  12. public void getKittensColor() {
  13. for (String c : kittens.keySet()) {
  14. System.out.println(c);
  15. }
  16. }
  17.  
  18. public static void main(String[] args) {
  19. CatFactory cf = new CatFactory();
  20. cf.createKittens();
  21. cf.getKittensColor();
  22. }
  23. }
  24.  
  25. class Kitten {
  26. private String name;
  27. private Color color;
  28.  
  29. public Kitten(String name , Color color) {
  30. this.name = name;
  31. this.color = color;
  32. }
  33.  
  34. public Color getColor() {
  35. return color;
  36. }
  37.  
  38. public String getName() {
  39. return name;
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement