写作COMP282程序  辅导C/C++语言

” 写作COMP282程序 辅导C/C++语言University of LiverpoolDepartment of Computer ScienceCOMP282 Advanced Object-Oriented C LanguagesCoursework 1 C++Deadline: Tuesday 13th April at 17:00Weighting: 50%Make sure your student ID is clearly shown in a Comment at the top of your source code. Compress yourVisual Studio project into a single zip file and submit it via SAM. Penalties for late work will be applied inaccordance with the Code of Practice on Assessment.Project OverviewYou will create a small interactive program toinput details about people, manipulate them, anddisplay them. The project consists of severaltasks, which you should tackle in order. Each taskbuilds on the previous one. Do as much as youcan and then Package your project forsubmission. Begin by downloading the VisualStudio project template for this assessment.Read through this entire document before youstart coding, so youre aware of all tasks and theoverall structure of the Program. Your solutionshould demonstrate your knowledge of C++.Important: Each task requires you to add extracode. You shouldnt need to remove any code.Keep the code from previous tasks in yourprogram so we can see it and mark it.Important: Each part requires you to change thecode in the main() function, potentially losing theprevious version. Therefore we have providedfunctions called main_Part1(), main_part2() andmain_part3(). Place your code for each partinside the relevant function. You can uncommentthe relevant lines in the real main() function torun and test each part.Part 1 (Worth 15%)Task 1 Person Class Definition (5%)Create a Person class that stores a name and age. The name should be stored as a string, and the age as aninteger. Declare and define a constructor that takes appropriate parameters and stores them in the object.Also declare and define a default constructor that sets the name to an empty string and the age to zero.Task 2 Person I/O (5%)Implement the and Operators so you can output and input a Person object with the following stringformat.Jasmine 18In other words, the name of the person is output followed by the age. When the user types a similar stringas input, the first token (up to the space) should be stored as the name, and the second (after the space) asthe age. For this task you do not need to do any input validation or error handling. Assume the user willalways type the correct format.Task 3 Comparison Operators (5%)Implement comparison operators (, , and ==) for the Person class. These should work numerically, basedon the ages of the people involved.Add relevant test code to the main_Part1() function. Make sure its sufficient to test all the implementedaspects of the Person class from all tasks so far.Part 2 (Worth 45%)Task 4 Adding Listing People (Fixed Storage) (20%)Implement this and subsequent tasks in the main_part2() function. Create a loop to present menu itemsand input user choices. At this stage the menu will only have three options.1. Add Person2. List EveryoneQ. QuitYou will need to use a suitable data structure to store Person objects. For the purposes of this task you canassume we will never want to store more than 9 people. An example run of this program is shown below.Example Output (Task 4)1. Add Person2. List EveryoneQ. QuitEnter Option: 1Enter Details: Martin 421. Add Person2. List EveryoneQ. QuitEnter Option: 1Enter Details: Jenny 311. Add Person2. List EveryoneQ. QuitEnter Option: 2[1] Martin 42[2] Jenny 311. Add Person2. List EveryoneQ. QuitEnter Option: QYou should check that the storage is not full up (ie. already holds 9 people) before allowing a new personto be added. Display an error message if the user tries to add too many people.Task 5 Finding the Oldest Person (10%)Add another menu option so the user can find the oldest person in the data structure. An example run isshown on the next page, assuming there is already some data in the system. Youve already definedcomparison operators for the Person class that should be useful in this task. The algorithm itself is fairlystraightforward.Task 6 Removing People (15%)Add another menu option so the user can remove people from the data structure. An example run isshown below, assuming there is already some data in the system.Example Output (Task 5)1. Add Person2. List Everyone3. Remove Person4. Find OldestQ. QuitEnter Option: 2[1] Martin 42[2] Jenny 31[3] Alice 56[4] Freddie 181. Add Person2. List Everyone3. Remove Person4. Find OldestQ. QuitEnter Option: 4Oldest: Alice 561. Add Person2. List Everyone3. Remove Person4. Find OldestQ. QuitEnter Option: QExample Output (Task 6)1. Add Person2. List Everyone3. Remove Person4. Find OldestQ. QuitEnter Option: 2[1] Martin 42[2] Jenny 31[3] Alice 56[4] Freddie 181. Add Person2. List Everyone3. Remove Person4. Find OldestQ. QuitEnter Option: 3Enter Index: 21. Add Person2. List Everyone3. Remove Person4. Find OldestQ. QuitEnter Option: 2[1] Martin 42[2] Alice 56[3] Freddie 181. Add Person2. List Everyone3. Remove Person4. Find OldestQ. QuitEnter Option: QYou should make sure that you handle a situation where the user enters an index greater than the numberof people in the data structure.You should shuffle data within the structure so there are no gaps when a user is removed. Remember youcan refer back to lecture examples and similar code used during lab sessions. Note also that the indexnumbers in the output will reflect this shuffling of data, so they wont always refer to the same person.Part 3 (Worth 40%)Task 7 Refactored Program (Dynamic Data) (25%)Implement this and subsequent tasks in the main_part3() function. You might like to copy the code fromthe previous part as a starting point.Refactor the program so it uses a dynamic data structure. In other words, there is no limit on the numberof people the program could store (assuming unlimited memory). The actual behaviour of the programwont change from the users perspective, but internally it will be very different.You should use a dynamic data structure from the Standard Template Library, such as a vector. You shouldalso use a corresponding STL iterator. Note that the vector class has an erase() function to remove items.Make full use of functions and algorithms from the STL where appropriate.Task 8 Sorting the Data (15%)Add another menu option to sort the data in ascending order of age. Note that this will only sort the data,not display it. If the user wants to see the sorted list, they can select that option afterwards.1. Add Person2. List Everyone3. Remove Person4. Find Oldest5. Sort DataQ. QuitYou should use the full range of functions and algorithms provided by the Standard Template Library, andimplement any necessary helper functions, as explained in the relevant lecture material.How to SubmitLocate your Visual Studio project folder and compress it into a single .zip archive. If you use any otherformat we wont be able to extract and mark your work. Rename your archive so it has the module codeand your student ID in the filename (eg. comp282_cw1_201212345.zip).If you want to draw our attention to anything, make a comment in the code itself. We will not read or markany other documents.Submit your archive via SAM ( httpss://sam.csc.liv.ac.uk/COMP/CW_Submissions.pl). You can submitmultiple attempts. If you submit more than one, we will only look at and mark the most recent.Marking DescriptorsWe draw your attention to the standard Department Grade Descriptors, which are listed in the StudentHandbook.如有需要,请加QQ:99515681 或WX:codehelp

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导