Advertisement
Guest User

Kittens

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