So I have been tasked with creating a program that is essentially a planner for a person. It has to have the abilities to add events of 3 types(Party, Dance Class,Club Meeting). It then has to be able to display everything enter, and be able to display the things that occur on the same date, date from the user. Finally it has to check if you have 2 events that occur on the same day, and then check the time against it. So for right now I have a decent amount of base code but I'm having trouble with the adding events part, and my gut tells me that I need to switch my array from the driver program to my SocialEvent Class. So my question is how would I go about adding objects to an array that come from 3 subclasses, and then be able to access that information in the superclass so that it can be checked. Heres what I have so far.

import java.util.Scanner;



public class TestSocialEvent {
	/**
	 * @author Alexander Chamerlaion
	 * @Version 1.0
	 * @Date 10/12/11
	 * This program creates and tests Social Events
	 */

	static String title, attire, dayweek,input,time;
	static int day,month,year;
	public static void main(String[] args) {

		Scanner k = new Scanner(System.in);

		System.out.println("Social Planner");

		SocialEvent ev = new SocialEvent(attire, dayweek, title, day, month, year,time);

		while(true){
			System.out.println("Please enter the type of party you are attending \n(Party, Club Meeting, Dance Class, Display,Quit)");
			String input = k.nextLine();
			input.toLowerCase();
			if(input.equals("party")){
				System.out.println("Choosen a Party");
				Party party = new Party(title, attire, time, year,day,month,dayweek);
				System.out.println("Please enter a description of your event: ");
				title=k.nextLine();
				System.out.println("Please Enter an attire: ");
				attire = k.nextLine();
				System.out.println("Please Enter an time: ");
				time=k.nextLine();
				System.out.println("Please enter the date input the day first: ");
				day=k.nextInt();
				System.out.println("Month: ");
				month=k.nextInt();
				System.out.println("Year: ");
				year=k.nextInt();
				System.out.println("Please enter the day it occurs on(Monday,Tuesday,etc): ");
				dayweek=k.nextLine();
				party.setPartyTime(time);
				party.setPartyTitle(title);
				party.setPartyAttire(attire);
				party.setPartyMonth(month);
				party.setPartyYear(year);
				party.setPartyDay(day);
				ev.addParty(attire, dayweek, title, day, month, year,time);

			}
			else if(input.equals("club meeting")){
				System.out.println("Choosen a Club Meeting");

				System.out.println("Please enter a description of your event: ");
				title=k.nextLine();
				System.out.println("Please Enter an attire: ");
				attire = k.nextLine();
				System.out.println("Please Enter an time (hhmm): ");
				time=k.nextLine();
				System.out.println("Please enter the date input the day first: ");
				day=k.nextInt();
				System.out.println("Month: ");
				month=k.nextInt();
				System.out.println("Year: ");
				year=k.nextInt();
				System.out.println("Please enter the day it occurs on(Monday,Tuesday,etc): ");
				dayweek=k.nextLine();
				ClubMeeting club = new ClubMeeting(title, attire, time, year,day,month,dayweek);
				club.setClubTitle(title);
				club.setClubAttire(attire);
				club.setClubTime(time);
				club.setClubDay(day);
				club.setClubMonth(month);
				club.setClubYear(year);
				club.setClubDayweek(dayweek);
				ev.addClubMeeting(attire, dayweek, title, day, month, year,time);

			}
			else if (input.equals("dance class")){
				System.out.println("Choosen a Dance Class");
				System.out.println("Please enter a description of your event: ");
				title=k.nextLine();
				System.out.println("Please Enter an attire: ");
				attire = k.nextLine();
				System.out.println("Please Enter an time: ");
				time=k.nextLine();
				System.out.println("Please enter the date input the day first: ");
				day=k.nextInt();
				System.out.println("Month: ");
				month=k.nextInt();
				System.out.println("Year: ");
				year=k.nextInt();
				System.out.println("Please enter the day it occurs on: ");
				dayweek=k.next();
				DanceClass dance = new DanceClass(attire, title, time, day, month, year, dayweek);
				dance.setDanceTitle(title);
				dance.setDanceAttire(attire);
				dance.setDanceTime(time);
				dance.setDanceDay(day);
				dance.setDanceMonth(month);
				dance.setDanceYear(year);
				dance.setDanceDayweek(dayweek);
				ev.addDanceClass(attire, dayweek, title, day, month, year,time);
				ev.display();
			}
			else if(input.equals("display")){


				System.out.println("Choosen to Display Social Planner");
				ev.display();
			}
			else if(input.equals("quit"));
			break;
		}	




	}
}
public class SocialEvent {
	private String title;
	private String attire;
	private String time;
	private int day;
	private int month;
	private int year;
	private String dayweek;
	private int count=0;
	private SocialEvent[] events = new SocialEvent[100];
	
	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;
	}
	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++;
		}
	}
	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++;
		}
	}
	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++;
		}
	}
	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){
		if(partyTime.length()>2||partyTime.length()<3){
			this.partyTime=partyTime.substring(0,1)+":"+partyTime.substring(1,2);
		}
		else if(partyTime.length()>3){
			this.partyTime=partyTime.substring(1,2)+":"+partyTime.substring(2,3);
		}
		else{
			System.out.println("Invalid Time ");
		}

	}

	public String getPartyAttire() {
		return partyAttire;
	}

	public void setPartyAttire(String partyAttire) {
		this.partyAttire = partyAttire;
	}

	public String getPartyTitle() {
		return partyTitle;
	}

	public void setPartyTitle(String partyTitle) {
		this.partyTitle = partyTitle;
	}

	public String getPartyDayweek() {
		return partyDayweek;
	}

	public void setPartyDayweek(String partyDayweek) {
		this.partyDayweek = partyDayweek;
	}

	public int getPartyDay() {
		return partyDay;
	}

	public void setPartyDay(int partyDay) {
		if(partyDay>31){
			System.out.println("You've Entered An Invalid Day ");
		}
		else{
			this.partyDay=partyDay;
		}
	}

	public int getPartyMonth() {
		return partyMonth;
	}

	public void setPartyMonth(int partyMonth) {
		if(partyMonth>12){
			System.out.println("You've Entered An Invalid Day ");
		}
		else{
			this.partyMonth=partyMonth;
		}
	}

	public int getPartyYear() {
		return partyYear;
	}

	public void setPartyYear(int partyYear) {
		this.partyYear = partyYear;
	}
	public String toString(){
		return "Title: "+partyTitle+"\nAttire: "+partyAttire+"\nDate: "+partyMonth+"/"+partyDay+"/"+partyYear+"\nDay of the Week: "+
				partyDayweek+"\nTime: "+partyTime;
	}

}
public class DanceClass extends SocialEvent {

	private String danceAttire,danceTitle,danceDayweek,danceTime;
	private int danceDay,danceMonth,danceYear;
	
	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;
		
		
	}

	public String getDanceAttire() {
		return danceAttire;
	}

	public void setDanceAttire(String danceAttire) {
		this.danceAttire = danceAttire;
	}

	public String getDanceTitle() {
		return danceTitle;
	}

	public void setDanceTitle(String danceTitle) {
		this.danceTitle = danceTitle;
	}

	public String getDanceDayweek() {
		return danceDayweek;
	}

	public void setDanceDayweek(String danceDayweek) {
		this.danceDayweek = danceDayweek;
	}

	public String getDanceTime() {
		return danceTime;
	}

	public void setDanceTime(String danceTime) {
		if(danceTime.length()>2||danceTime.length()<3){
			this.danceTime=danceTime.substring(0,1)+":"+danceTime.substring(1,2);
		}
		else if(danceTime.length()>3){
			this.danceTime=danceTime.substring(1,2)+":"+danceTime.substring(2,3);
		}
		else{
			System.out.println("Invalid Time ");
		}

	}
	

	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;
		}
	}

	public int getDanceMonth() {
		return danceMonth;
	}

	public void setDanceMonth(int danceMonth) {
		if(danceMonth>12){
			System.out.println("You've Entered An Invalid Month ");
		}
		else{
			this.danceDay=danceDay;
		}
	}
	public int getDanceYear() {
		return danceYear;
	}

	public void setDanceYear(int danceYear) {
		this.danceYear = danceYear;
	}
	public String toString(){
		return "Title: "+danceTitle+"\nAttire: "+danceAttire+"\nDate: "+danceMonth+"/"+danceDay+"/"+danceYear+"\nDay of the Week: "+
				danceDayweek+"\nTime: "+danceTime;
}
}
public class ClubMeeting extends SocialEvent {

	private String clubAttire,clubTitle,clubDayweek,clubTime;
	private int clubDay,clubMonth,clubYear;

	public ClubMeeting(String attire,String dayweek, String title,int day,int month,int year, String time) {
		super(attire,dayweek,title,day,month,year,time);
		this.clubAttire=attire;
		this.clubTitle=title;
		this.clubDay=day;
		this.clubMonth=month;
		this.clubYear=year;
		this.clubTime=time;
		this.clubDayweek=dayweek;

	}

	public String getClubAttire() {
		return clubAttire;
	}

	public void setClubAttire(String clubAttire) {
		this.clubAttire = clubAttire;
	}

	public String getClubTitle() {
		return clubTitle;
	}

	public void setClubTitle(String clubTitle) {
		this.clubTitle = clubTitle;
	}

	public String getClubDayweek() {
		return clubDayweek;
	}

	public void setClubDayweek(String clubDayweek) {
		this.clubDayweek = clubDayweek;
	}

	public String getClubTime() {
		return clubTime;
	}

	public void setClubTime(String clubTime) {
		if(clubTime.length()>2||clubTime.length()<3){
			this.clubTime=clubTime.substring(0,1)+":"+clubTime.substring(1,2);
		}
		else if(clubTime.length()>3){
			this.clubTime=clubTime.substring(1,2)+":"+clubTime.substring(2,3);
		}
		else{
			System.out.println("Invalid Time ");
		}

	}

	public void setClubDay(int clubDay) {
		if(clubDay>31){
			System.out.println("You've Entered An Invalid Day ");
		}
		else{
			this.clubDay=clubDay;
		}
	}

	public int getClubDay() {
		return clubDay;
	}

	public int getClubMonth() {
		return clubMonth;
	}

	public void setClubMonth(int clubMonth) {
		if(clubMonth>12){
			System.out.println("You've Entered An Invalid Month ");
		}
		else{
			this.clubMonth=clubMonth;
		}
	}

	public int getClubYear() {
		return clubYear;
	}

	public void setClubYear(int clubYear) {
		this.clubYear = clubYear;
	}
	public String toString(){
		return "Title: "+clubTitle+"\nAttire: "+clubAttire+"\nDate: "+clubMonth+"/"+clubDay+"/"+clubYear+"\nDay of the Week: "+
				clubDayweek+"\nTime: "+clubTime;
}
}

no, your array most definitely is supposed to be in your test-class.
otherwise, for each event you're creating, you're creating a new Array of n elements.
you've had your classes extend SocialEvent, which is a very good way to start.
now, create the SocialEvent[] array ..
in your testclass.

each time you add a new Party => array[index] = (SocialEvent)new Party();
you can add compares about the date, hour, ...

you could use a nested if-structure to get your application working the way you want.

Ok great starting point, but could you do some psedo code, I'm not quite grasping it

I know that I have to do
static SocialEvent[]event;
but then how would I go about adding? And would I need separate arrays for Partys club meeting and Dance Class

well ... no
they all would pass the instanceof test for SocialEvent, since they all extend the SocialEvent class, so, they can all be stored in an array of type SocialEvent.

you could do different things: if you work with an array, do realize you won't be able to fit in more elements than the number you specify upon creation of the array.

if you want to use a list of variable size, you may want to use an ArrayList, which takes only elements of the type SocialEvent

using an arrayList would also make it possible for you to add an element to the list, without knowing anything about how many elements have been added allready.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.