TEL:400-8793-956
当前位置:程序、服务器

为什么我的循环不起作用?

提问者: 近期获赞: 浏览人数: 发布时间:2021-02-24 08:45:20

 问:我以为您必须确保电池未充满电,所以请执行!。然后增加mBarsCount

 
公共 类 GoKart  { 
public static final int MAX_ENERGY_BARS = 8 ; 私有字符串mColor ; 私人int mBarsCount ; 公共GoKart (字符串颜色){ mColor = color ; mBarsCount = 0 ; } public String getColor (){ return mColor ; }公共无效收费(){        
 
    mBarsCount  =  MAX_ENERGY_BARS ; 
} public boolean isBatteryEmpty (){ return mBarsCount == 0 ; }公共布尔isFullyCharged (){而(!isFullyCharged ()){ mBarsCount + 1 ; } return mBarsCount == MAX_ENERGY_BARS ; }
  
 
答:您已经在该isFullyCharged方法中添加了代码以向Kart收费。应该在charge。
 
有道理?
 
  公共 无效 收费() {     
while (!isFullyCharged ()){ mBarsCount ++; } } public boolean isFullyCharged (){ return mBarsCount == MAX_ENERGY_BARS ; } }    
上一篇: #fff092b0。此颜色代码有什么问题?
下一篇: 没有这样的文件或目录,请打开“ ./views/header.html”