Threesuns

Email the Instructor

Contact

All Semesters

Semesters

All Courses

Courses

2014Spring

01.13.14 - 05.11.14

Scripting (Blended)

CSYS2033

Wednesday
01:00 PM - 02:20 PM

Person Object

Lab03

Objective: To work with creating a custom object and methods.

pastdue

Submit Your Solution

Lab03

Request a Copy of your Solution

Lab03

Requirements

Page is well formed and valid10 pts
Person constructor function created10 pts
Function to accept inputs was created10 pts
Display method was created10 pts
Person objects allow blank names but not blank phone number parts20 pts
Display function shows names formatted correctly20 pts
Display function shows phone numbers correctly20 pts
Total100 pts

Instructions

For this lab you will be writing a script that will allow a user to enter the first name, last name, area code, and phone number of a person which will then be stored in an object and displayed on the page.

To do this you will need to create a constructor function for Person which will contain the attributes mentioned above about that person. A person object created with this constructor function can have a first and last name or either of the names can be left blank. The person can also have a phone number consisting of an area code and number but if either of the two parts of the phone number are missing the incomplete phone number should not be stored in the object.

In addition to the Person constructor function you should also write a stand-alone function (not a method of the object) that prompts the user for the four pieces of information about the person and then allows for those values to be used to make the Person object.

A method should be created for the Person object called display that will show the information stored inside that Person object. The display method should show the last name followed by a comma and then the first name if both names are available. If either name is missing, the one name that is available should be displayed without a comma, and if neither name is available the display method should show "Unknown" in place of the names.

If the entire phone number was entered the display method should show it in (999) 999-9999 format. If the entire phone number wasn't entered then nothing should be shown in its place.