/**
 *   Author: Gurkirat Singh
 *	 Date: Nov 27,2018
 *   Course: CST8130
 *   
 *   Purpose: This class extends the Events class.
 *   		 This class holds the information regarding the Work event.
 *    Data Fields:  initial constructor (OurDate, OurTime)- set the value of the Object to the objects in parameter
 *    				initial constructor (int,int,int,int,int,int,String,String)- he constructor set the day, month, year, hour,ehours, minute, description,workplace to the parameter values.
 *    				ehours: int - holds the number of hours of work
 *    				workplace: String - holds the name of the workplace
 *    				workplace: void - prompt the user to enter the workplace.
 *    				hours: void - prompt the user to enter number of hours
 *    				toString: String - return the all information of event created
 *    				getDate: OurDate -  method which return the date.
 * 					getTime: OurTime -  method which returns the time.
 */					

import java.util.InputMismatchException;

public class Work extends Events {
	String workplace;
	int ehours;

	public Work(OurDate date, OurTime time) {
		super();
		super.date = date;
		super.time = time;
	}

	public Work(int day, int month, int year, int hour, int minute, String description, String workplace, int ehours) {

		super(day, month, year, hour, minute);
		super.description=description;

		this.workplace = workplace;
		this.ehours = ehours;
	}

	public void workplace() {

		System.out.println("Enter the place to do work:");
		workplace = scan.next();

	}

	public void hours() {
		boolean valid = false;
		do {
			try {

				System.out.println("Enter the number of hours for the shift:");
				ehours = scan.nextInt();

				if (ehours > 0) {
					valid = true;
				} else
					System.out.println("Please enter valid number of hours:");

			} catch (InputMismatchException inputMismatchException) {
				System.out.println("Please enter valid number of hours:");
				scan.next();

			}

		} while (!valid);

	}

	public String toString() {
		return date.toString() + " " + time.toString() + " " + super.description + " at " + workplace + " for " + ehours
				+ " hours";

	}

	public OurDate getDate() {
		return date;
	}

	public OurTime getTime() {
		return time;
	}

}
