Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code in c++ DONT COPY OTHER ANSWERS WRITE A FULL PROGRAM INCLUDING THE main Description In this assignment, you are going to build a subprogram

Code in c++
DONT COPY OTHER ANSWERS
WRITE A FULL PROGRAM INCLUDING THE main image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Description In this assignment, you are going to build a subprogram that maintain a unoredered list of user accounts. Each node of the list will store the information of one user account. You need to implement the following classes User AccountType, User AccountNode and User AccountListType. Their specifications are shown in the UMLs (Figures 1.2 and 3). User AccountType is the class that define the attributes of a user account including the user ID, the user password, First Name, Last Name. It is very important to implement a default constructor beside the parametrized constructor of User Account'Type , otherwise you will get a syntax error when you implement the class User AccountNode that has a composition of the class User AccountType. (Alternatively, one can create parameterized constructor of User AccountNodo that passes the argument to the parameterized constructor of User AccountNode. but you don't have to implement it that way) User AccountNode is the type that you will use to create nodes and them to a list (object) of the class User AccountListType. Each node you will create has two member elements: 1) an ) object of the type User AccountType, 2) a link (pointer of the type User AccountNode) that points to the next node in the list. User AccountListType is used to create an unordered list of user accounts. The list a collection of nodes of the type CarNode. Each user account in the list has user id, these user ids should be unique. Which means that it is not acceptable to have two nodes in the list with the same user id. In other words, the user id is a key. Figure 4 is a sample user accounts list of type in User AccountListType. class User AccountType (pts) # userld: string 1/user ID, e.g.,ahmadali # encrypted_password: string # FirtsName : string #LastName : string User AccountType() Ildefault constructor that set all of the member vraibles to +User Account'Type (string, string, string, string) // Set the values of the parameters to the member variable, you need to make sure that the password is a valid password, otherwise set it to ". if it is a valid password, it should be encrypted first and then being set to the member variable encrypted_password. +setUserId(string): void +setFirstName(string): void +setLastName(string): void +setPassword(string): void you need to make sure that the password is a valid password, otherwise set it to **, if it is a valid password, it should be encrypted first and then being set to the member variable encrypted password +getUserId():string return the userld Figure 1: UML of the class User Account Type class User AccountNode // 1 pts) + user_account: UserAccountType object of type User AccountType + link: User AccountNode Figure 2: UML of the class user AccountNode class User AccountListType (20) first: User AccountNode. Pointer to the first node of the list. last: User AccountNode Pointer to the last node of the list counter: int A corinter to hold the number of nodes of the list. +UserAccountListType(): ici pts) default constructor: Initializes the list to an empty state +-User AccountListType (): // destructor: //Deletes all the nodes from the list. #destroyList():void // (1 pts) Delete all the nodes from the list. +print() const: void (3 pts) Prints the contents of the book User Account list +bool IsuserIdExist(string ud); 4 pts) return true if the list has user account with the user id ud +void insertUser Account(const userAccounttype newItem); (4 pts) If all information userid, FirstName, LastName, encrypted_password of the parameter newitem (an object of of type user AccountType) are set to non-empty strings (I mean none of them is set to **), then insert the object to the end of the list if no user exist in the list with the same use id. Hint: you need to use the functions isComplete serccount and IsUserIdExist +void deleteUser Account(string ud); //(Apts) delete from the list the user account node in which userId equals the parameter ud +void printInfo_of_userId(string user_id); (4pts//print the information of the userAccountNode in the list that for which the value of userId equals the parameter ud Figure 3: UML of the class User AccountListType Almal Ali Tig Halus Hata Moitammal 1df Aler_1909 Ah Khalid el first last Figure 4. A sample user account list Password Encryption You are NOT allowed to use string operations Or array declaration in the encryption process. You are asked to declare lists stacks and Queues of type char from the STL to encrypt the password to get full score. Encryption Algorithm Step 1: (2 points) In this step the password characters will be inserted into list object to be ready for the coming encryption stages. (objects to use only list) Step 2: (2 points) In this step, the first and last characters of the password (within the list) will be reversed. (eg H21*10 0711H) (objects to use only list) Step 3: (5 Points) In this step, the ASCII value of the characters will be changed and the new characters (after changing the ASCII) will be in original order in the list. The new ASCII value for each character will be calculated by adding to the current ASCII value the least significant digit from the ASCII of the next character. (e.g. After step 2, the password is: Dell with ASCII values: 0: 111 7:55, 1: 108 *:42 1: 108. H: 72 The new ASCII values will be t: 111.5, ?: 55, 1012 2:48 n: 10+2, H: 72 The password will be: t?nnel Note: The ASCII for the last character will not be changed because there is no character next to the last one. (objects to use list and stack or list and queue or both) give explanation for your choice. Step 4: (4 points) Finally, in this step, the characters in even positions will be reversed and you keep the characters in the odd positions in their original order. (e.g. After step 3, the password is : thanh so after applying step 4 the password will be : ninath (objects to use list and stack Ok list and queue or both) glve explanation for your choice. Important notes: No templates are used. Add the time complexity of each function as a comment before the function header Implement the functions outside the classes Implement the classes and their functions as specified in the UML. (by the green comment). You must write a driver program (main function) to test the functions you implemented. You are responsible for designing test code (main function) that helps us to see if your functions are implemented properly. In the test code, you define an object of the class User AccountListType and call the functions. You need to place your test code inside a file called main.cpp. During grading, we are also going to use our own test code to check if your code is written properly or not. A sample test run is presented in figure 5. Think of the following seenarios when you test your code: on a. Creating a list and add three accounts and print it b. Try to add user account with add incorrect password to the list c. Try to add an incomplete user account to the list. d. Search the list for existing user id and print the account info e. search the list for a user who doesn't exist. f. Delete from the list the account node of some user id You need to compare string in different places in the code, please use the function compare from the library instead of using the equality operator (==), because ( == ) may not work properly with string. The function compare is described http://www.cplusplus.com/reference/string/string compare/. if two strings are equal, then it return 0, if the compared string is less than comparing string then it return a negative value, if the compared string is less than comparing string, it return a positive value, for example: #include > clang++-7-pthread -std-CH17 0 IQ xa #include in.cpp using namespace std; > ./main 0 int main() { -65793 65793 string sl="aaa", s2="bbb"; cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

Students also viewed these Databases questions