  Final Project : Object Oriented Nascar


Purpose: Create an application that lets a user find and display information about Nascar drivers. To accomplish this project you will need to create a class, use arrays or hashes, file I/O and regular expressions.

How to submit: You should submit the two required files by pasting one file after another in the assignment submission textbox window. The separation of files should be easy for me to identify since every file should have the four required comment headers (name, submission date, file description, file name/lab #) and both "use strict;" and "use warnings;" in every file.
You will need to download the following file for your project:

Download winstoncup_2002_drivers.txt

Description:
This file contains all the Nascar driver information you will need.

The file is a colon (:) delimited text database.

The field format of the file is structured like this:
"Car Number":"Driver Name":"Sponsor":"Owner":"Crew Chief":"Car Make":"Mini Biography":"Team Name"

To accomplish this project you must create a class and a Perl application to access the methods and data you create in your class.

Remember, for a package to become an object instance you must have a constructor method that returns a blessed anonymous hash. Refer to your reading (page 383 in your book) for information about the bless function.

Specifications for Class:

Name: Nascar.pm

Description:
A package for displaying and searching a Nascar driver's information.

Attributes:
 ->Title - String title of our data (eg. Winston Cup 2002 Drivers). The constructor method would be a good place to initialize/create this attribute. An attribute is simply a key/value pair in the anonymous hash that makes up your object.

Methods:
 ->get_last_name
Purpose: 	This method takes the full name of a driver as an input parameter and converts it to lower case and return's the driver's last name.
Input Parameters: 	Scalar string containing a full name.
Return Value: 	Lower cased string scalar containing driver's last name.

 ->load_data_file
Purpose: 	Opens data file and stores driver's data in either a hash, array, or object attribute. If the data is stored in a hash or array it should be in a module level variable inside "Nascar.pm" so that it is visible to all the methods in the class. This method should only be called once for the lifetime of the object.
Input Parameters: 	String scalar containing the file name.
Notes: 	You should use the file testing techniques that you learned in lab # 5 to find if the input file exists and if it is readable. If not, you should print an appropriate error message to the user and exit gracefully.

 ->print_driver_details
Purpose: 	Prints all the details known about the driver to the screen.
Input Parameters: 	String scalar containing the driver's full name.
Notes: 	At the end of this method you should call the ->print_related_driver method, passing in the same input parameter that you received.
Sample Output: 	

-----------------------------------
|          Kenny Wallace          |
-----------------------------------
Car #      : 23
Team       : Bill Davis Racing
Crew Chief : Philippe Lopez
Owner      : Gail Davis
Sponsor    : Hills Bros Coffee
Car Make   : Dodge

Mini Bio
--------
Kenny Wallace's resolve was sorely tested in 2001, but in
the end he was rewarded with a solid Winston Cup Series ride
with Dale Earnhardt Inc.


 ->print_related_driver
Purpose: 	Prints the names of other drivers that might be related to the driver who was given as an input parameter.
Input Parameters: 	String scalar containing the driver's full name.
Notes: 	A relationship exists if the last name of the driver is the same as another driver. You should retrieve the last name of the driver using the ->get_last_name method.
Sample Output: 	

Possibly Related Drivers:
-------------------------
Driver: Mike Wallace
Driver: Rusty Wallace


 ->print_driver_picker
Purpose: 	Prints a list of all the driver names. When the user makes a selection then driver's details are shown by calling the ->print_driver_details method. The user can also use the letter "m" (should be case insensitive) as a command to exit out of the method.
Notes: 	If a user enters an invalid command such as "adf" or a driver number out of the range at the driver listing prompt then you should inform the user that they entered an invalid command and keep prompting the user for a valid choice until a valid choice is given.
Sample Output: 	

     Driver Name
     -----------
01.) Bill Elliott
02.) Bobby Hamilton
03.) Bobby Labonte
04.) Bret Bodine
05.) Casey Atwood
06.) Dale Earnhardt, Jr.
07.) Dale Jarrett
08.) Dave Blaney
09.) Elliott Sadler
10.) Jamie McMurray
11.) Jeff Burton
12.) Jeff Gordon
13.) Jeff Green
14.) Jeremy Mayfield
15.) Jerry Nadeau
16.) Jimmie Johnson
17.) Jimmy Spencer
18.) Joe Nemechek
19.) John Andretti
20.) Johnny Benson
21.) Ken Schrader
22.) Kenny Wallace
23.) Kevin Harvick
24.) Kurt Busch
25.) Kyle Petty
26.) Mark Martin
27.) Matt Kenseth
28.) Michael Waltrip
29.) Mike Skinner
30.) Mike Wallace
31.) Ricky Craven
32.) Ricky Rudd
33.) Robby Gordon
34.) Rusty Wallace
35.) Ryan Newman
36.) Shawna Robinson
37.) Sterling Marlin
38.) Steve Park
39.) Terry Labonte
40.) Todd Bodine
41.) Tony Stewart
42.) Ward Burton

Valid Commands:
---------------
Number from the list to see driver details.
"m" and "enter" to go back to the main menu.
:


 ->search_by_keyword
Purpose: 	Tries to match input keyword against all the drivers names using a regular expression (should be case insensitive). If one match is found then the method ->print_driver_details is called to print the driver's details. If more than one match is found, print a list that lets the user choose which driver for which he wants details. The user can also use the letter "m" (should be case insensitive) as a command to exit out of the method.
Input Parameters: 	String scalar containing the keyword.
Return Value: 	Scalar containing the amount of matches found by the input keyword.
Notes: 	If a user enters an invalid command such as "adf" or a driver number out of the range at the driver listing prompt then you should inform the user that they entered an invalid command and keep prompting the user for a valid choice until a valid choice is given.
Sample Output: 	

Main Menu: dale

     Driver Name
     -----------
01.) Dale Earnhardt, Jr.
02.) Dale Jarrett

Valid Commands:
---------------
Number from the list to see driver details.
"m" and "enter" to go back to the main menu.
input: 



Specifications for Perl Application:

Name: finalproject.pl

Description:
Uses methods in the Nascar (Nascar.pm) class for queries and print outs of Nascar driver information.

Create a menu system similar to the one you made in lab #3. The application should allow for the following commands from the standard input:

    * "list" - This should call the ->print_driver_picker method of the Nascar class.

    * A keyword that is passed to the ->search_by_keyword method of the Nascar class. Be sure to check the return value of the method and if there are no (0) matches, you should inform the user and suggest that he try another search keyword.


    * "exit" - Exits the application.



Notes: All the commands should be case insensitive. Extra Credit: Create POD class documentation files for the packages you create. Refer to page 422 in your book for instructions on how to do this.
