The program will begin by reading a tab
-
delimited text file called people.txt, which you
can download
here
.
After skipping the first line of the file that identifies what each column contains, your program will
proceed to read data about each contact a line at a time. From
the data contained on each line, the
program will create a Contact object and add it to the list of contacts. After reading all contacts from the
file, the program will show how many contacts were read. It will then print a menu of options that will
allow
the user to list all people with a particular last name, all people who hail from a particular state
,
and all people who lie within a particular age range. It will also offer the user the option to write all the
contacts to a file.
Here is what you have t
o do:
1.
Declare a class called Person in a file called Person.cs. A person will have properties that store
the first name, last name, and age, constructors, and a ToString() function. Make sure age is
protected against being set to a negative value. (5 point
s)
2.
Declare an interface called Detailed in a file called Detailed.cs. It should declare one function,
GetDetailedDescription, that implementing classes will override to print out a formatted
detailed description of the object. (3 points)
3.
Declare a class ca
lled Contact in a file called Contact.cs.
a.
Declare to it extend Person and implement Detailed (2 points)
b.
The Contact class must have properties for holding the state, email address, and phone
number, each with appropriate data types (3 points)
c.
It must have
two constructors, one default and one non
-
default (2 points)
d.
It must have a ToString() function that offers a one
-
line, tab
-
delimited listing of the data
for each contact. In other words, it shows the data in the same format that each line of
the input fi
le showed. (2 points)
e.
It must have override the GetDetailedDescription function to enable the object to be
printed according to the sample output(2 points)
4.
Declare a class called ContactWriter that can write one
-
line descriptions of Contact objects to
eith
er text files or binary files. (5 points)
5.
In Program.cs,
a.
Include and use a function called PrintWelcome() that prints a welcome banner (1 point)
b.
Ask the user for the name of the input file. (1 point)
c.
Read the contacts from the input file into a List<Contac
t>. If the file cannot be read,
print a warning message and end the program. Otherwise, show how many contacts
were read. (4 points).
d.
Repeatedly print a menu of options that will enable the user to find a contact by last
name, find a contact by state, find
a contact by age range, or print the contacts to a file.
(2 points)
e.
Include and use a function called ListContactsWithLastName that lists the detailed
descriptions of all contacts with a particular last name (3 points)
f.
Include and use a function called Li
stContactsInState that lists the fancy descriptions of
all contacts who live in a particular state (3 points)
g.
Include and use a function called ListContactsInAgeRange that lists the fancy
descriptions of all contacts whose age lies within a particular rang
e (3 points)
h.
Include and use a function called SaveContactsToFile
that writes the one
-
line description
of each contact to a file the user names in either binary or text format depending on
whether the file name the user specifies ends in a .txt or a .bin extension. Make sure
you use ContactWriter to do this. (5 points)
6.
Include helpful comments in your code (1 point)
7.
Submit your entire solution folder (including sln and cs files) as contact_manager_lastname.zip,
where you replace lastname with your last name (1 point)