package calendar;
import java.util.Calendar;
/**
* @author Thomas Milner
* @date 24/02/2012
* @file SocialEventjava
*
* @brief
* This is a social event, it extents a regular event
*/
public class SocialEvent extends Event {
private int m_guests;
public static final int NO_FIELDS = 8;
public static final int IDX_GUESTS = 7;
/**
* Returns the guests for the events.
* @return
*/
public int GetGuests() {
return m_guests;
}
/**
* Sets the guests for the event
* @param guests
*/
public boolean SetGuests(int guests) {
m_guests = guests;
return true; //Cause C3 say to.. But it does nothing, and proves
//nothing
}
/**
* Constructor, Builds an event
* @param id the events unique id
* @param title the events title
* @param start_date the events start date
* @param end_date the events end date
* @param description the description of the event
* @param repetition How often the event repeates, as an int
* @param guests the guests that are attending
* @throws Exception
*/
public SocialEvent(int id, String title, Calendar start_date,
Calendar end_date, String description, int repetition,
int guests) throws Exception {
super(id, title, start_date, end_date, description, repetition);
m_guests = guests;
m_type = Event.SOCIAL_EVENT;
}
public SocialEvent() {
super();
}
/**
* converts the event to csv format
*/
@Override
public String ToCSV() {
String csv = super.ToCSV() + ","+m_guests;
return csv;
}
public static void main (String [] args) throws Exception{
Calendar cal1 = Calendar.getInstance();
Calendar cal2 = Calendar.getInstance();
cal2.add(Calendar.HOUR, 2);
SocialEvent e = new SocialEvent();
SocialEvent f = new SocialEvent(Data.AllocateEventId(), "E", cal1,
cal2, "Test",
NOT_REPEATING, 0);
e.SetDescription("Changed 1");
cal2.add(Calendar.HOUR, 4);
e.SetEnd_date(cal2);
e.SetId(999);
e.SetRepetition(2);
e.SetTitle("CHANGE TITLE");
e.SetGuests(2);
System.out.println(f.GetDescription());
System.out.println(f.GetEnd_date());
System.out.println(f.GetId());
System.out.println(f.GetRepetition());
System.out.println(f.GetStart_date());
System.out.println(f.GetTitle());
System.out.println(f.GetGuests());
//incorrect event type
//@SuppressWarnings("unused")
//Event g = new SocialEvent(Data.AllocateEventId(), "E", cal1, cal2,
//"Test",
// 10, 4);
}
}