import java.util.ArrayList;
import java.util.List;

public class Run {
	
	public static int getNum(List<Cow> cowList,Integer year){
		List<Cow> tempList = new ArrayList<Cow>();
	     for(int i=0,length=cowList.size();i<length;i++){
	    	 Cow cow = cowList.get(i);
	    	 if(cow.getAge()>=5){
	    		 Cow tempcow = new Cow(1);
	    		 tempList.add(tempcow);
	    	 }
	    	 cow.setAge((cow.getAge()+1)); 
	     }
	     year--;
	     cowList.addAll(tempList);
	     System.out.println(year);
	     if(year==0){
	    	 return cowList.size();
	     }
	     return getNum(cowList,year);
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
	   List<Cow> cowList=  new ArrayList<Cow>();
	   cowList.add(new Cow(1));
	   int year = 20;
	   int num =getNum(cowList,year);
	   System.out.println("aaa"+num);
	}
	
}
最近下载更多
AXIN  LV36 2014年2月26日
最代码官方  LV167 2013年3月7日
最近浏览更多
金牌讲师 2022年5月8日
暂无贡献等级
159753yzy 2021年12月13日
暂无贡献等级
2196316269  LV10 2021年2月24日
寒若笑  LV1 2020年9月2日
翳翳桑榆日  LV1 2020年8月13日
清欢hello  LV3 2020年5月28日
宝贝二加一 2020年3月6日
暂无贡献等级
whywhywhy  LV10 2019年8月29日
最代码安逸  LV15 2019年6月27日
laoityic  LV8 2019年5月13日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友