C++代写:CS246 Email System

代写一个电子邮件系统,要求用类树的数据结构,并且实现查询功能。

Requirement

As part of an email system, you’ve been asked to implement a tree-like data structure to represent email groups. In its simplest form, the tree consists of a single node and a single email address. It could also consist of nested groups. For example, the Women In CS (WiCS) mailing list could have a group for the faculty representatives, one for the staff representatives, and then a group for the students, where the students are subdivided by plan, and then by year so that the entire group or particular subsets can be targeted in mass mailings.

Some implementation notes follow:

  • The declaration of the Group type can be found in the provided Group.h file. For your submission you must add all requisite declarations to Group.h and all routine and member definitions to Group.cc.

  • In order to complete the Group implementation, you will also need to implement the nested inner classes: GroupNode 2 and EmailNode 3 classes. For your submission you must add all requisite declarations to Group.h and all routine and member definitions to Group.cc. Note: Group has been declared as a friend of both GroupNode and EmailNode so that its code can access their private information if necessary.

  • A Group may have 0 or more email addresses, and 0 or more subgroups.

  • Searching for an email address first starts in the list of email addresses for the root Group node. The search stops as soon as the first occurrence is found. If the address cannot be found there, then each subgroup in turn is searched. Since each subgroup is a Group, the search action follows the previously specified order.

  • A Group can only be deleted if it is a subgroup of the Group node currently being indexed; otherwise, the command fails by doing nothing. For example, if the group g(0) is the pointer to the WiCS group as in the diagram, then the WiCS group will not b removed from g(0) .

  • Note that the information in each list is stored in the standard string lexicographic 4 order using the standard string comparison operators. Thus, the output will be in lexicographic order.

  • It is strongly suggested that you first implement and test your linked list code before you work on the rest to ensure that it is correct.

  • The provided test harness, a3q3.cc, can be compiled with your solution to test (and then debug) your code. The test harness is not robust and you are not to devise tests for it, just for the Group class. Do not change this file. The test harness allows you to have up to 10 groups defined at one time, identified as g0 to g9. If a group has not been initialized, it consists of a nullptr. Most of the test harness commands cannot be performed upon an uninitialized group. Additionally, the user prompts are printed to standard error so that they will not interfere with the output produced, and thus make it easier to write your test files.

  • Your Makefile must create an executable named emailgroups. Note that the executable name is case-sensitive.

Test

The test harness commands consist of:

Command Description
b g(i) name Initializes group g i by calling its constructor and passing in the group name, name. g(i) must initially be a nullptr.
aa g(i) email Uses Group::addAddress to add email to g(i) . g(i) must not be a nullptr.
ag g(i) g(j) Uses Group::addGroup to add g(j) to g(i) and sets g(j) to nullptr. Neither g(i) nor g(j) must be a nullptr.
ra g(i) email Uses Group::removeAddress to remove the first occurrence of email from g(i). g(i) must not be a nullptr.
ra g(i) name Uses Group::removeGroup to remove the first subgroup of g(i) that has a name that matches name. g(i) must not be a nullptr.
sg g(i) email Uses Group::findAddress to return an Group::EmailNode* set to the node that contains the first occurrence of email in g(i) or nullptr if no such address can be found. g(i) must not be a nullptr.
sa g(i) name Uses Group::findGroup to return a Group::GroupNode* set to the node that contains the first occurrence of name in g(i) as a subgroup or nullptr if no such subgroup can be found. g(i) must not be a nullptr.
p g(i) Uses operator<< to output group g(i) to standard output. g(i) must not be a nullptr.