com.example.model
Class Sched

java.lang.Object
  extended by com.example.model.Sched

public class Sched
extends java.lang.Object

Schedule class including the functions to parse, combine, invert, and change to a string.


Field Summary
 java.lang.String[] availableString
           
 
Constructor Summary
Sched()
          Constructor, initializes some variables
 
Method Summary
 void addSchedule(java.lang.String username, java.lang.String monday, java.lang.String tuesday, java.lang.String wednesday, java.lang.String thursday, java.lang.String friday)
          Takes a username and schedules for Monday through Friday and enters them into the database.
 void close()
           
 void combineScheds()
          Combines independent schedules (including the "restriction" schedule) into one "super-schedule" with all of the times factored in and no over-lapping time slots
 void convertToString()
          Converts the "super-schedule" object to a single String (availableString) in standard-time human-readable format
 boolean createAccount(java.lang.String username, java.lang.String password, java.lang.String email)
          Adds a user to the database.
 void displaySchedules(int flag)
          Prints out all inputted schedules for debugging purposes flag = 0 for String output, flag = 1 for Vector output flag = 2 for superSched output, flag = 3 for inverted schedule output, flag = 4 for final string output
 java.lang.String[] getFreeTimes()
          Compares and combines the different schedules and returns the result, taking time restrictions into consideration
 void invertSched()
          Invert the "super-schedule" to produce a schedule listing all of the available free times
 boolean login(java.lang.String username, java.lang.String password)
          Takes a username and password and returns true if there is anentry in the database with a matching username and password, and false if there isn't.
 java.lang.String[] lookupSchedule(java.lang.String username)
          Takes a username and returns an array of Strings containing the user's schedules for Monday through Friday.
 void parseScheds()
          Parses a schedule into a form that can be used for easy comparisons (integers in military times within schedule objects) and also ensures that the format entered is valid
 void putRestrictions(java.lang.String r)
          Factors in overall scheduling restrictions
 void putSched(int user, int day, java.lang.String sched)
          Puts each schedule into the scheds array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

availableString

public java.lang.String[] availableString
Constructor Detail

Sched

public Sched()
Constructor, initializes some variables

Method Detail

putSched

public void putSched(int user,
                     int day,
                     java.lang.String sched)
Puts each schedule into the scheds array

Parameters:
user - is an int to tell which user is being added to
day - is an int to tell which day is being added to
sched - is an unformatted String with times that are unavailable

putRestrictions

public void putRestrictions(java.lang.String r)
Factors in overall scheduling restrictions

Parameters:
r - is an unformatted String with the range the output shoudl be in

displaySchedules

public void displaySchedules(int flag)
Prints out all inputted schedules for debugging purposes flag = 0 for String output, flag = 1 for Vector output flag = 2 for superSched output, flag = 3 for inverted schedule output, flag = 4 for final string output

Parameters:
flag - is an int which tells what Schedule to output

getFreeTimes

public java.lang.String[] getFreeTimes()
Compares and combines the different schedules and returns the result, taking time restrictions into consideration


parseScheds

public void parseScheds()
Parses a schedule into a form that can be used for easy comparisons (integers in military times within schedule objects) and also ensures that the format entered is valid


combineScheds

public void combineScheds()
Combines independent schedules (including the "restriction" schedule) into one "super-schedule" with all of the times factored in and no over-lapping time slots


invertSched

public void invertSched()
Invert the "super-schedule" to produce a schedule listing all of the available free times


convertToString

public void convertToString()
Converts the "super-schedule" object to a single String (availableString) in standard-time human-readable format


login

public boolean login(java.lang.String username,
                     java.lang.String password)
              throws java.lang.Exception
Takes a username and password and returns true if there is anentry in the database with a matching username and password, and false if there isn't.

Parameters:
username - is a string that contains the username to login
password - is a string that contains the password to login
Returns:
is a boolean value which is true if the user logs in successfully and falso otherwise
Throws:
java.lang.Exception

createAccount

public boolean createAccount(java.lang.String username,
                             java.lang.String password,
                             java.lang.String email)
                      throws java.lang.Exception
Adds a user to the database. Returns true is the user was added and false if the specified username is already in the database.

Parameters:
username - is a string that contains a username
password - is a string that contains a password
email - is a string which contains an email address
Returns:
boolean value which is true if account is created succesfully and false otherwise
Throws:
java.lang.Exception

lookupSchedule

public java.lang.String[] lookupSchedule(java.lang.String username)
                                  throws java.lang.Exception
Takes a username and returns an array of Strings containing the user's schedules for Monday through Friday. The array contains null values if the username isn't found in the database.

Parameters:
username - is a username which is being looked up
Returns:
is an array of strings which hold the unavailable times for each day
Throws:
java.lang.Exception

addSchedule

public void addSchedule(java.lang.String username,
                        java.lang.String monday,
                        java.lang.String tuesday,
                        java.lang.String wednesday,
                        java.lang.String thursday,
                        java.lang.String friday)
                 throws java.lang.Exception
Takes a username and schedules for Monday through Friday and enters them into the database.

Parameters:
username - is a string which has the username which is being added to
monday - is a string of unavailable times for monday
tuesday - is a string of unavailable times for tuesday
wednesday - is a string of unavailable times for wednesday
thursday - is a string of unavailable times for thursday
friday - is a string of unavailable times for friday
Throws:
java.lang.Exception

close

public void close()