CS206-Email-Handler

Practical Work

By using Microsoft Visual Studio 2015, develop an object-oriented console application that can handle emails. Your program is NOT expected to be able to send emails. It is for providing the environment to build a database of the emails, displaying and handling the database content. While you are responsible for the final design of the console application, your program is expected to realise a class cEmail representing an email that contains the following:

  • Member variables including the fields To_From (that contains a name followed by an email address put inside a pair of square brackets, and a character to indicate whether it is a sent-to-receiver or received-from-sender message), Subject, Cc (that contains a name followed by an email address put inside a pair of square brackets), Message, and Date (e.g. 8 November 2015 can be represented by the integer 151108). Notice that the first 4 member variables are for storing a string, while the member variable Date is of type int.
  • Member functions for reading and writing the member variables in cEmail.

Then, develop the class Em_Han to build up a database that keeps the emails ever sent or received. The database can be realised by an array of a finite size, which is assumed big enough and your program does not need to check this. Member functions that allow the user to build up and display the content of the database should be implemented. Then, within the class, you are required to write public member function(s) to realise one of the following five tasks (of handling the email messages). The task to do should be determined by the remainder obtained from dividing your team number by 5. For example, if your team number is SEVEN, 7%5 = 2, you should do Task 2) of this request.

Task

  1. The function performs the sorting of the received emails based on the name of the sender (within the To_From field) in ascending order, and display a sorted list of sender name, subject and date of sending.
    Hint: To do the sorting, notice that strcmp(“Peter”, “Mary”) will return 1, meaning that “Peter” is larger than “Mary”. Similarly, strcmp(“Mary”, “Peter”) will return -1, strcmp(“Mary”,”Mary”) will return 0. Notice that you can ignore the sent-to-receiver messages.

  2. The function performs the sorting of the sent emails based on the name of the receiver (within the To_From field) in ascending order, and display a sorted list of receiver name, subject and date of receiving. To do the sorting, read the hint in Task 0). Notice that you can ignore the received-from-sender messages.

  3. The function performs the sorting of the emails based on the date in ascending order, and display a sorted list of date, name, and subject together with a string indicating it is a sent or received message.

  4. The function performs the sorting of the emails based on the subject in ascending order, and display the sorted list of subject, name, and date together with a string indicating it is a sent or received message. To do the sorting, read the hint in Task 0).

  5. The function asks the user to input a name, and display a numbered list of subject and date of the email together with a string indicating it is a sent or received email under that name. The user can then enter a number and the corresponding email will be deleted from the database.

Hint: You can add a member variable in the cEmail class that specifies whether it is a valid email. If an email is deleted from the database, that email becomes an invalid email. On displaying the content of the database, only valid emails will be shown.

  • It is required that the class and the implementation of its member functions should be built as a separate static library and linked into the console application.
  • Your program is expected to provide a text-mode user interface so that users can repeatedly handle and display the database of emails until the user chooses to end the application.
  • Should you want to get a credit, you should design the application such that when a user wants to start it, he needs to login the application with a username first, which will be checked with a file that stores username-password pairs. If the username is new, the application will ask for a password from the user and store it into that file. If the username can be found in that file, the application will start only when the password is correct. The application will end if the user fails to provide the correct password in three consecutive trials.

General Description

  1. Each team should comprise up to TWO students (THREE students for HD class).

  2. Unless you get prior approval from your subject lecturer/tutor, you must observe the following:

  3. Do NOT use any technique or C++ constructs not taught in the subject

    • Any library not mentioned in the subject must NOT be used (e.g. the mathematics library to compute x to the power of y.)
    • Each team should upload the zipped file to the Blackboard (under Groups, select File Exchange after clicking your team number).
  4. The documentation for your request is important. The ability of writing good comments in the program will also be an important factor to the final assessment of your request.

  5. It is compulsory to use a word processing tool to write your report. The font size must not be bigger than 12 or smaller than 10. Use 1.5 lines spacing on both sides of a page. Including all figures and tables, if any, the length of the report should not be shorter than 7 pages.