| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 654 人关注过本帖
标题:这怎么修改啊?
取消只看楼主 加入收藏
床至只局
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2015-2-1
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:0 
这怎么修改啊?
/*
 * 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);
    }
}
收到的鲜花
  • 林月儿2015-05-03 21:20 送鲜花  49朵   附言:good good study,day day up
搜索更多相关主题的帖子: package lenovo public change eating 
2015-05-02 23:09
快速回复:这怎么修改啊?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018210 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved