?
All look good
package pl.codegym.task.task14.task1404;
import java.io.*;
import java.util.ArrayList;
/*
Koty
*/
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String key;
try {
while (!((key = reader.readLine()).isEmpty())) {
Cat cat = CatFactory.getCatByKey(key);
System.out.println(cat.toString());
}
}
catch(Exception e){ }
}
static class CatFactory {
static Cat getCatByKey(String key) {
Cat cat = null;
if ("dziki".equals(key)) {
cat = new FemaleCat("Pazur");
} else if ("mańka".equals(key)) {
cat = new FemaleCat("Mania");
} else if ("kafel".equals(key)) {
cat = new NiceCat("Kafelek");
} else {
cat = new Cat(key);
}
return cat;
}
}
static class Cat extends CatFactory {
private String name;
protected Cat(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public String toString() {
return "Jestem " + getName() + ", podwórkowy kocur";
}
}
static class FemaleCat extends Cat {
FemaleCat(String name) {
super(name);
}
public String toString() {
return "Jestem " + getName() + ", zaraz wydrapię Ci oczy";
}
}
static class NiceCat extends Cat {
NiceCat(String name) {
super(name);
}
public String toString() {
return "Jestem miłą kotką o imieniu " + getName();
}
}
}