public class Appointment {
private String clientName;
private String startTime;
private String endTime;
private String date;
private Appointment next;
private String appType; public Appointment(){
clientName = null;
date = null;
startTime = null;
endTime = null;
appType = null;//single app or reapeat app
}
public Appointment(String name,String d, String s, String e, String t){
clientName = name;
date = d;
startTime = s;
endTime = e;
appType = t;
} Appointment app = new Appointment();
假设我做个了个add的方法来加会议,新的会议会加到 next那 。 就形成linkedlist。 有什么办法能实现存单个会议和一组会议(几个会议成为一组)?
private String clientName;
private String startTime;
private String endTime;
private String date;
private Appointment next;
private String appType; public Appointment(){
clientName = null;
date = null;
startTime = null;
endTime = null;
appType = null;//single app or reapeat app
}
public Appointment(String name,String d, String s, String e, String t){
clientName = name;
date = d;
startTime = s;
endTime = e;
appType = t;
} Appointment app = new Appointment();
假设我做个了个add的方法来加会议,新的会议会加到 next那 。 就形成linkedlist。 有什么办法能实现存单个会议和一组会议(几个会议成为一组)?
可以用List存放。
看不懂楼主什么需求
你的意思是在我的appointment class 里加个list?
一个集合类维护一个ArrayList<Appointment>
然后可以向其中添加删除等操作
按你所说的弄个类AppointmentCollection 那这两个类 好像就不能相通了
然后这个对象下面维护一个ArrayList保存所有A申请的会议
这个类里面有add(Appointment) delete(Appointment).......之类的可以向ArrayList里面添加删除
你最后获取为A产生的AppointmentCollection的对象,取ArrayList就是A申请的所有的会议
也不是要分类 可能我不太理解你的意思 我可能也没说好(请原谅) 我的意思是会议由两种(先别看 那个next) 1是 单独的,比如我要只要预约 星期1 就有一个上面的Appointment 对象 2是连续的预约,比如 我要定星期123 就有3个appointment对象了(是同一时间,同一个人) 想把1和2存起来 但是1是为一组single appointment,2是有一组 repeat appointment。 好像我想 抽出2来 删除星期3的 2现在就存了两个对象 我想让1和2 是相通的(好像arraylist那样,index 0、1、2、3这样存single的存0 repeat的存1 ) 那我就可以来分析 他们的预约的时间段(比如 1是1点到2点 2是 星期123 的2点到3点)是没有重叠的,如果有就报错这样。有什么办法可以这样 ?
然后你想删除,比如你想删除repeat里面的第一个next
appointment = apps[1];
appointment_next_to_delete = appointment.next.next;
appointment.next = appointment_next_to_delete;