我有以下代码:
public class BigVic extends Looper
{
private int itsNumFilled; // count this's filled slots
private int itsNumEmpty; // count this's non-filled slots
public BigVic() // constructor
{
// left as an exercise
} //======================
/** Tell how many of the executor's slots are filled. */
public int getNumFilled()
{
return itsNumFilled;
} //======================
/** Tell how many of the executor's slots are empty. */
public int getNumEmpty()
{
return itsNumEmpty;
} //======================
/** Do the original putCD(), but also update the counters. */
public void putCD()
{
if ( ! seesCD() && stackHasCD())
{
itsNumFilled++;
itsNumEmpty--;
super.putCD();
}
} //======================
/** Do the original takeCD(), but also update the counters. */
public void takeCD()
{
if (seesCD())
{
itsNumFilled--;
itsNumEmpty++;
super.takeCD();
}
} //======================
}
我应该这样做:
写出
BigVic
所需的构造函数。
我设法提出了这一点:
public BigVic()
{
super();
this.putCD();
this.takeCD();
}
我该如何回答这个问题?除了添加将使它完成的构造函数中已有的内容外,我不确定还能做什么?我已经拥有了它所需要的吗?
据我所知,您似乎想使用
public BigVic() // constructor
{
this.itsNumFilled = 0; // Nothing is filled.
this.itsNumEmpty = 100; // For a default size of 100 executor "slots".
} //======================
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句