/*********************************************************************
 * Author: B. Alex Bridges                                           *
 * Login ID: brid0129                                                *
 * Class: CPSC-102, Summer 1998                                      *
 * Project: Programming Assignment 1                                 *
 * Description: This program is a simple database query system for a *
 *              video store.                                         *
 * Contents: Methods for dealing with Videos.                        *
 *********************************************************************/

/* IMPORTS */
import java.io.*;


class Videos
{
	/* CONSTANTS */
	final static boolean b_debug = true;	// CONTROLS EXTRA DEBUG OUTPUT
	final static String str_default = "";	// DEFAULT STRING VALUE
	final static int int_default = -1;		// DEFAULT INTEGER VALUE

	/* GLOBAL VARIABLES */
	private static String str_title;		// MOVIE'S TITLE
	private static int int_year;			// MOVIE'S RELEASE YEAR
	private static int int_runtime;			// MOVIE'S RUNTIME IN MINUTES
	private static String str_available;	// MOVIE'S AVAILABILITY

	public Videos()
	{
		/* INITIALIZE VARIABLES TO DEFAULT VALUES */
		str_title = str_default;
		int_year = int_default;
		int_runtime = int_default;
		str_available = str_default;
	} // constructor Videos

	/*************************************************************************
	 * Method: read_movie                                                    *
	 * Purpose: Reads the movie properties--title, release year, runtime,    *
	 *          and availabilty.                                             *
	 * Input: --PARAMATERS--                                                 *
	 *        => 'br_file_in' = The BufferedReader for the video database.   *
	 * Output: --EXIT VALUE--                                                *
	 *         => FATAL EXCEPTION = -1                                       *
	 *************************************************************************/
	public static void read_movie(BufferedReader br_file_in)
	{
		/* READING OF MOVIE PROPERTIES */
		try
		{
			str_title = br_file_in.readLine();
			int_year = Integer.parseInt( br_file_in.readLine() );
			int_runtime = Integer.parseInt( br_file_in.readLine() );
			str_available = br_file_in.readLine();
		} // try
		/* EXCEPTION HANDLING */
		catch(IOException exception)
		{
			System.out.println(" FATAL EXCEPTION: File input problem.");
			System.exit(-1);
		} // catch
	} // method read_movie

	/*************************************************************************
	 * Method: get_title                                                     *
	 * Purpose: Returns the title of the current movie.                      *
	 * Input: none                                                           *
	 * Output: --RETURN ITEM--                                               *
	 *         => str_title = The title of the current movie.                *
	 *************************************************************************/
	public static String get_title()
	{
		return(str_title);
	} // method get_title

	/*************************************************************************
	 * Method: print_movie                                                   *
	 * Purpose: Prints the movie properties--title, release year, runtime,   *
	 *          and availabilty.                                             *
	 * Input: none                                                           *
	 * Output: none                                                          *	 *************************************************************************/
	public static void print_movie()
	{
		/* PRINTING OF MOVIE PROPERTIES */
		System.out.print("Title: "+str_title+"\n"+
		                 "Released: "+int_year+"\n"+
		                 "Runtime: "+int_runtime+" minutes\n");
		if( str_available.compareTo("false") == 0 )
			System.out.println("Available: No\n");
		else if( str_available.compareTo("true") == 0 )
			System.out.println("Available: Yes\n");
		else
			System.out.println(" ERROR: Availability of '"+str_available+"' is invalid. Must be 'true' or 'false'.\n");
	} // method print_movie
} // class Database
