Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CatFactory {
- HashMap<String ,String> kittens = new HashMap<String , String>(5);
- public void createKittens() {
- kittens.put("Black","Alisa");
- kittens.put("Gray","Viktor");
- kittens.put("Gray","Dima");
- kittens.put("Black","Akula");
- kittens.put("Gray","Sveta");
- }
- public void getKittensColor() {
- for (String c : kittens.keySet()) {
- System.out.println(c);
- }
- }
- public static void main(String[] args) {
- CatFactory cf = new CatFactory();
- cf.createKittens();
- cf.getKittensColor();
- }
- }
- class Kitten {
- private String name;
- private Color color;
- public Kitten(String name , Color color) {
- this.name = name;
- this.color = color;
- }
- public Color getColor() {
- return color;
- }
- public String getName() {
- return name;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement