Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement a superclass called SocialEvent and subclasses Party, DanceClass, and

ID: 3630924 • Letter: I

Question

Implement a superclass called SocialEvent and subclasses Party, DanceClass, and ClubMeeting. A SocialEvent has a description (for example, “Attend Ann's wedding”), a form of attire ("Casual", "Formal", "Dressy"), a date, a day of the week, and a time. A ClubMeeting is a SocialEvent that occurs monthly, i.e., on the same day every month. A DanceClass is a SocialEvent that occurs weekly, i.e., on the same day every week. A Party is a SocialEvent that occurs once, i.e., on a particular date. Write a method occursOn(int year, int month, String dayOfWeek, int day) that checks whether a SocialEvent occurs on that date. For example, for a monthly SocialEvent, you must check whether the day of the month matches. For a weekly SocialEvent, check whether the day of the week matches.

Then, in a TestSocialEvent class, fill an array of SocialEvent objects with a mixture of different kinds of SocialEvents. First, display all of the user’s SocialEvents by invoking a displaySocialEvent() method that is included in each class. Second, ask a user to enter a date, including the day of the week, and print out all SocialEvents that occur on that date.

Improve your SocialEvent program by giving the user the option to add a new SocialEvent. The user must specify the type of the event, the description, the attire, the day of the week if appropriate, and the date and time.

Improve the program further by letting the user save the social event data to a file and reload the data from a file. The saving part is straightforward: make a method saveAppointmentData. In it, save the type, description, attire, date, day, and time to a file. The loading part is not so easy. First determine the type of the appointment to be loaded, create an object of that type, and then call a loadAppointmentData method to load the data. This last method will be different in each class.

Explanation / Answer

public class SocialEvent

{

//Data members of class

private String title; //title of event

private String attire;

private String time; //time of event

//stores date in three variables

private int day;

private int month;

private int year;

//day name

private String dayweek;

private int count=0;

//array of objects

private SocialEvent[] events = new SocialEvent[100];

//constructor initializes data members of class

public SocialEvent(String attire,String dayweek, String title,int day,int month,int year, String time)

{

this.attire = attire;

this.dayweek = dayweek;

this.title = title;

this.day = day;

this.month = month;

this.year = year;

this.time = time;

}

//adds pary

public void addParty(String attire,String dayweek, String title,int day,int month,int year, String time)

{

if (count < events.length)

{

events[count] = new Party(attire, dayweek, title, day, month, year, time);

count++;

}

}

//adds dance class

public void addDanceClass(String attire,String dayweek, String title,int day,int month,int year, String time)

{

if (count < events.length)

{

events[count] = new DanceClass(attire, dayweek, title, day, month, year, time);

count++;

}

}

//Adds club meetings

public void addClubMeeting(String attire,String dayweek, String title,int day,int month,int year, String time)

{

if (count < events.length)

{

events[count] = new ClubMeeting(attire, dayweek, title, day, month, year, time);

count++;

}

}

//displays all events of class

public void display()

{

for(int i = 0; i<count; i++)

{

System.out.println(events[i].toString());

}

}

}

public class Party extends SocialEvent

{

private String partyAttire,partyTitle,partyDayweek,partyTime;

private int partyDay,partyMonth,partyYear;

public Party(String attire,String dayweek, String title,int day,int month,int year, String time)

{

super(attire, dayweek, title, day, month, year,time);

this.partyAttire=attire;

this.partyDayweek=dayweek;

this.partyTime=time;

this.partyTitle=title;

this.partyDay=day;

this.partyMonth=month;

this.partyYear=year;

}

public void setPartyTime(String partyTime)

{

this.partyTime=partyTime;

}

//setter and gettter functions for PartyAttire member

public String getPartyAttire()

{

return partyAttire;

}

public void setPartyAttire(String partyAttire)

{

this.partyAttire = partyAttire;

}

//setter and gettter functions for PartyTitle

public String getPartyTitle()

{

return partyTitle;

}

public void setPartyTitle(String partyTitle)

{

this.partyTitle = partyTitle;

}

//setter and gettter functions for PartyDayweek

public String getPartyDayweek()

{

return partyDayweek;

}

public void setPartyDayweek(String partyDayweek)

{

this.partyDayweek = partyDayweek;

}

//setter and gettter functions for PartyMonth

public int getPartyDay()

{

return partyDay;

}

public void setPartyDay(int partyDay)

{

this.partyDay=partyDay;

}

//setter and gettter functions for PartyMonth

public int getPartyMonth()

{

return partyMonth;

}

public void setPartyMonth(int partyMonth)

{

this.partyMonth=partyMonth;

}

//setter and gettter functions for PartyYear

public int getPartyYear()

{

return partyYear;

}

public void setPartyYear(int partyYear)

{

this.partyYear = partyYear;

}

//to string method to display data

public String toString(int i)

{

return "Party "+" Title: "+partyTitle+" Attire: "+partyAttire+" Date: "

+partyMonth+"/"+partyDay+"/"+partyYear+" Day of the Week: "+

partyDayweek+" Time: "+partyTime;

}

public class DanceClass extends SocialEvent

{

//declaring data members of class

private String danceAttire,danceTitle,danceDayweek,danceTime;

private int danceDay,danceMonth,danceYear;

//constructor initializes data menmbers of class

public DanceClass(String attire,String dayweek, String title,int day,int month,int year, String time)

{

super(attire, dayweek, title,day,month,year, time);

this.danceAttire=attire;

this.danceTitle=title;

this.danceDayweek=dayweek;

this.danceTime=time;

this.danceDay=day;

this.danceMonth=month;

this.danceYear=year;

}

//setter and gettter functions for DanceAttire

public String getDanceAttire()

{

return danceAttire;

}

public void setDanceAttire(String danceAttire)

{

this.danceAttire = danceAttire;

}

//setter and gettter functions for DanceTitle

public String getDanceTitle()

{

return danceTitle;

}

public void setDanceTitle(String danceTitle)

{

this.danceTitle = danceTitle;

}

//setter and gettter functions for Dayweek

public String getDanceDayweek()

{

return danceDayweek;

}

public void setDanceDayweek(String danceDayweek)

{

this.danceDayweek = danceDayweek;

}

//setter and gettter functions for DanceTime

public String getDanceTime()

{

return danceTime;

}

public void setDanceTime(String danceTime)

{

this.danceTime=danceTime;

}

//setter and gettter functions for DanceDay

public int getDanceDay()

{

return danceDay;

}

public void setDanceDay(int danceDay)

{

if(danceDay>31)

{

System.out.println("You've Entered An Invalid Day ");

}

else

{

this.danceDay=danceDay;

}

}

//setter and gettter functions for DanceMonth

public int getDanceMonth()

{

return danceMonth;

}

public void setDanceMonth(int danceMonth)

{

this.danceDay=danceDay;

}

//setter and gettter functions for DanceYear

public int getDanceYear()

{

return danceYear;

}

public void setDanceYear(int danceYear)

{

this.danceYear = danceYear;

}

public String toString(int i)

{

//to string method to display data

return "Dance Class"+ " Title: "+danceTitle+" Attire: "+danceAttire+" Date: "

+danceMonth+"/"+danceDay+"/"+danceYear+" Day of the Week: "+

danceDayweek+" Time: "+danceTime;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote