我已经成功输出了语句,为什么还是错误
package zh.codegym.task.task14.task1404;
/*
猫
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.io.FileInputStream;
import java.io. BufferedInputStream;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while(true){
String strings = reader.readLine();
if(strings == null){
break;
}
System.out.println( CatFactory.getCatByKey(strings));
}
}
static class CatFactory {
static Cat getCatByKey(String key) {
Cat cat = new Cat(key);
if ("凶爪".equals(key)) {
cat = new MeanCat("利爪");
} else if ("米斯".equals(key)) {
cat = new NiceCat("米西");
} else if ("斯马奇".equals(key)) {
cat = new NiceCat("斯马戈");
} else {
cat = new Cat(key);
}
return cat;
}
}
static class Cat {
private String name;
protected Cat(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
@Override
public String toString() {
return "我是" + getName() + ",一只小巷猫";
}
}
static class MeanCat extends Cat {
MeanCat(String name) {
super(name);
}
@Override
public String toString() {
return "我是" + getName() + ",我要挖掉你的眼睛";
}
}
static class NiceCat extends Cat {
NiceCat(String name) {
super(name);
}
@Override
public String toString() {
return "我是一只可爱的小猫,我叫" + getName();
}
}
}