我有这段代码:
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();
}
我如何回答这个问题?我不知道除了在构造函数中添加已经完成的东西之外我还能做些什么呢?我已经拥有了我需要的东西吗?
答案 0 :(得分:0)
据我所知,看起来你想要使用
public BigVic() // constructor
{
this.itsNumFilled = 0; // Nothing is filled.
this.itsNumEmpty = 100; // For a default size of 100 executor "slots".
} //======================