0
有一個名爲「約會」的類,其中3個對象需要定義。實現3維稀疏表的構造函數
這是怎麼類最初給出:
/*You must complete this class such that it can be used as nodes in a 3D sparse table.*/
public class Appointment
{
public Appointment()
{
/*You may implement this constructor to suit your needs, or you may add additional constructors.*/
}
public Appointment back;//The next appointment (back) of this appointment on the same date
public Appointment right;//The next appointment (right) of this appointment in the same week.
public Appointment down;//The next appointment (down) of this appointment in the same month.
//Appointment particulars:
private String description;//A description for this appointment.
private int duration;//The number of hours that the appointment will last.
}
還有其他功能,這並不重要。
所以我的想法是創建一個新的方法來初始化每個對象(不確定是不是我的權利!)
public Appointment()
{
right.appointmentRight();
}
public void appointmentRight()
{
for(int i=0; i<12; i++)
{
right = new Appointment(); //trying to initialize them for 12 months
}
}
誰能給我解釋一下,如果我在正確的軌道很,或者我必須做一些完全不同的事情 謝謝