这怎么修改啊?
/** To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package c8;
import java.util.Scanner;
/**
*
* @author lenovo
*/
class Dog{
public void eat(){
System.out.println("Dog eating");
}
public void eats(){
System.out.println("Dogs eating");
}
}
class Cat{
public void eat(){
System.out.println("Cat eating");
}
public void eats(){
System.out.println("Cats eating");
}
}
class Feeder{
public void Feed(String animal="Dog"){
int i;
if(animal.equals("Dog")){
i=1;
}else if(animal.equals("Dogs")){
i=2;
}else if(animal.equals("Cat")){
i=3;
}else if(animal.equals("Cats")){
i=4;
}
switch(i){
case 1:
Dog dog=new Dog();
dog.eat();
break;
case 2:
Dog dogs=new Dog();
dogs.eats();
break;
case 3:
Cat cat=new Cat();
cat.eat();
break;
case 4:
Cat cats=new Cat();
cats.eats();
break;
default:
System.out.println("please input Dog(s) or Cat(s):");
Feeder feed=new Feeder();
feed.Feed();
}
}
}
public class Feeding {
public static void main(String[] args){
Feeder feed=new Feeder();
Scanner can=new Scanner();
String an=can.next();
feed.Feed(an);
}
}