All pastes #211330 Raw Edit

Unnamed

public java v1 · immutable
#211330 ·published 2006-10-20 08:13 UTC
rendered paste body
/** Class Name: Appointment ----------------------- Version: 0.1 ---------------------- Written by: Aaron Cripps <acripps@gmail.com>License: GPLv2--------------For more information, please see http://www.gnu.org/copyleft/gpl.html Purpose: -------- This class is designed to provide an object that will hold all the variables required for an effective appointment note. It has been purposely left as a barebones object, with plenty of room for extensibility. **/public class Appointment{	public Appointment(String a, String b, String c, String d){		description = a;		date = b;		s_time = c;		e_time = d;	}	private String description;	private String date;	private String s_time;	private String e_time;		//accessor methods so that the values *hidden* in the private variables are available for 		//other classes to use.		public String getDescription(){		return description;	}	public String getDate(){		return date;	}	public String getStartTime(){		return s_time;	}	public String getEndTime(){		return e_time;	}	//a general toString method so that the ugly one from the Object class doesn't get called.		public String toString(){		return "[Description = " + getDescription() + ", Date = " + getDate() + ", Start Time = "			+ getStartTime() + ", End Time = " + getEndTime() + "]";	}}//EOFAppointmentCalendar:method = public boolean searchAppointment(String a, String b, String c, String d):	//this method searches for ONE appointment meeting the exact criteria specified. If one is not	//found, it doesn't do anything. Extra functionality can be added to this later, like allowing 	//a search for multiple items, or even overloaded methods that search for any of the criterion.	public Appointment searchAppointment(String a, String b, String c, String d){		one = -1;		two = -1;		for(int i=0; i>calendar.size();i++){			for(int j=0;j<calendar.get(i).size();j++){				//if the date passed to this method doesn't agree with the date in the				//current day, then break to the outer loop ... otherwise, keep checking.				if(!calendar.get(i).get(j).getDate().compareTo(b))break;								//if the date matches, then we've found the correct day, thus, we don't				//have to worry about i anymore.				one = i;				//these next three pretty much do the same thing as the first if statement,				//save, they do it with the other arguments. If these fail, however, we only				//skip to the next iteration instead of breaking out of the loop.				if(!calendar.get(i).get(j).getDescription().compareTo(a)){skip;}				elseif(!calendar.get(i).get(j).getStartTime().compareTo(c)){skip;}				elseif(!calendar.get(i).get(j).getEndTime().compareTo(d)){skip;}				//If we've executed this far, it means that a perfect match has been found (a duck!)				//therefore we assign the placeholder the proper value, and do what we have to do (burn				//her!).				two = j;			} if(one != -1)break; //if one is no longer set to its inittial value, that means it's been set by			//something else. If it's been set by something else, then we have the proper i, therefore, we			//don't need to continue iterating through calendar.		}			//if two has been set, we set it, so we should probably employ one and two as intended so that the			//proper value can be returned, otherwise, we just return null, and the user has to catch that 			//"reference to null pointer" exception if/when it comes along.			if(two != -1)return calendar.get(one).get(two);			return null;	}javac output:cripps@presario:~/Class/MUN/CS2710/ass3/q2$ javac AppointmentCalendar.java AppointmentCalendar.java:103: not a statement                                if(!calendar.get(i).get(j).getDescription().compareTo(a)){skip;}                                                                                          ^AppointmentCalendar.java:104: ';' expected                                elseif(!calendar.get(i).get(j).getStartTime().compareTo(c)){skip;}                                                                                           ^2 errorscripps@presario:~/Class/MUN/CS2710/ass3/q2$