C++ linked lists | Computer Science homework help

  

Instructions: 

1. The declaration of the ReadingList class has been changed, in the private area, to use a std::list instead of an array as its implementing data structure.

Because a std::list can grow arbitrarily long, there is no need to pre-allocate a space to hold the books, so the parameters and function for tracking the capacity have been removed.

2. Your task is to follow through on that change, making the necessary alterations to readingList.h and readingList.cpp to make this a working class. The necessary changes have already been made to the unit tests and to the main mergeLists.cpp application.

3. The major difference between lists and the earlier sequential structures that we have looked at is that elements are accessed via iterators instead of integer-based indices. Accordingly, you will need to: 

– Rewrite the indexing-based code in readingList.cpp with iterator-based code.

– Remove the indexing-based get function from readingList.h and add appropriate declarations of iterator and const_iterator types and associated functions allowing access to a ReadingList object’s sections.

4. To improve the usability of the ReadingList class, you will also need to add

– A constructor to allow ReadingList objects to be constructed from a pair of iterators denoting a range of Book values from some arbitrary container.

– A constructor to allow ReadingList objects to be constructed from an initializer_list of books.

5. Your code will be evaluated both on its ability to function correctly within the mergeLists application and on its ability to pass the various unit tests provided.

– In the test report, tests 0…7 test the mergeLists application. Tests numbered 8…25 check the unit tests.

– Each even-numbered test checks for correct behavior of the code.

– Each odd-numbered test checks to see if that same behavior is correct and entails no memory leaks or other common pointer/memory handling problems.

6. Submit files readingList.h and readingList.cpp

Problem Description: 

This assignment centers on a program that accepts as input two lists of e-books (derived from Project Gutenberg) and merges the two into one, eliminating any duplicate entries during the process. Each e-book is is described by three fields, an ID, the author info, and the title. In input and output, these appear together on a line separated by tab (“t”) characters.

For example, given the input

etext19640  Twain, Mark, 1835-1910   Adventures of Huckleberry Finn
etext13 Carroll, Lewis, 1832-1898   The Hunting of the Snark
etext9038   Twain, Mark, 1835-1910    The Adventures of Tom Sawyer

and

etext9038   Twain, Mark, 1835-1910    The Adventures of Tom Sawyer
etext20595  Twain, Mark, 1835-1910   The Awful German Language
etext23717  Carroll, Lewis, 1832-1898    Jabberwocky

the merge will be

etext13 Carroll, Lewis, 1832-1898   The Hunting of the Snark
etext19640  Twain, Mark, 1835-1910   Adventures of Huckleberry Finn
etext20595  Twain, Mark, 1835-1910   The Awful German Language
etext23717  Carroll, Lewis, 1832-1898    Jabberwocky
etext9038   Twain, Mark, 1835-1910    The Adventures of Tom Sawyer

The output is sorted by the project Gutenberg ID (the “etext…” field).

You are being supplied with a nearly complete working version of the mergeLists application.

Your task is to complete the implementation of the ReadingList class in accordance with the principles for robust and reusable ADTs as described in the lecture notes. You must use a dynamically allocated array as the basis for storing books within the reading list.

System Tests: 

The program takes its input from two files named in the command line and produces its output on standard out (cout). For example, if you have compiled the program into an executable named “mergeLists”, and had saved the sample input above in files tinyList.txt and tinyList2.txt in the same directory, you could run the program as

./mergeLists tinyList.txt tinyList2.txt

If you are working in Windows, use “.” instead of “./”. Of course, if you have your files in different directories or use different names, you will need to adjust your paths in the above command accordingly.

In general, you are responsible for designing and running your own systems tests.

That said, you have been provided with several input files of various lengths that you can use “as is” or chop up and recombine as you see fit.

Unit Tests: 

The unit tests will form a separate executable, named unittest. It can be run without parameters to run all tests on the ReadingList class.

You can, however, list one or more test names as parameters to run those tests only. For example, if you are failing the testRLRemove test, run

./unittest testRLRemove

to focus on just that one test. This can be very useful when debugging your code, because the unit tests are simpler and will get to your Faculty code a great deal more directly than the full application.

You can also abbreviate test names to run all tests beginning with a string.

For example,

./unittest testRLR

would suffice to run that same single test.

Notes: 

  • You may use any of the techniques covered for manipulating data via iterators, including range-based loops, the auto keyword, and generic functions from the next lesson, if you are reading ahead.
  • In designing the iterators for the ReadingList class, consider carefully the options of creating an new iterator class versus reusing an existing iterator type. 
  • The ReadingList class keeps its Books in order. Allowing application code to alter or      reassign the internal sections via an iterator, e.g.,

· ReadingList::iterator it = myReadingList.begin();

· *it = Book(“99999”, “Zzarg, Jonathan”, “The Last Book Ever Written”);

would risk breaking that ordering, making any code that relies on the ordering fail.

That means that ReadingList needs to be one of those classes that use a single const iterator type as both iterator and const_iterator.

  • You may find it a much more efficient use of your time to focus on passing the unit tests first and worry about system testing the full mergeLists application afterwards.

CURRENT ERRORS: 

make all 

touch book.d

touch counted.d

touch mergeLists.d

touch readingList.d

touch sanityCheck.d

touch testReadingList.d

touch unittest.d

cat book.d counted.d mergeLists.d readingList.d sanityCheck.d testReadingList.d unittest.d > make.dep

g++ -g -std=c++17 -MMD -pthread -D_GLIBCXX_DEBUG -Wall -o book.o -c book.cpp

g++ -g -std=c++17 -MMD -pthread -D_GLIBCXX_DEBUG -Wall -o counted.o -c counted.cpp

g++ -g -std=c++17 -MMD -pthread -D_GLIBCXX_DEBUG -Wall -o mergeLists.o -c mergeLists.cpp

mergeLists.cpp: In function ‘ReadingList mergeReadingLists(const ReadingList&, const ReadingList&)’:

mergeLists.cpp:25:39: error: ‘const class ReadingList’ has no member named ‘begin’

   25 |  ReadingList::const_iterator i = cat1.begin();

      |                                       ^~~~~

mergeLists.cpp:26:39: error: ‘const class ReadingList’ has no member named ‘begin’

   26 |  ReadingList::const_iterator j = cat2.begin();

      |                                       ^~~~~

mergeLists.cpp:27:19: error: ‘const class ReadingList’ has no member named ‘end’

   27 |  while (i != cat1.end() && j != cat2.end())

      |                   ^~~

mergeLists.cpp:27:38: error: ‘const class ReadingList’ has no member named ‘end’

   27 |  while (i != cat1.end() && j != cat2.end())

      |                                      ^~~

mergeLists.cpp:29:20: error: invalid type argument of unary ‘*’ (have ‘ReadingList::const_iterator’ {aka ‘int’})

   29 |   const Book& b1 = *i;

      |                    ^~

mergeLists.cpp:30:20: error: invalid type argument of unary ‘*’ (have ‘ReadingList::const_iterator’ {aka ‘int’})

   30 |   const Book& b2 = *j;

      |                    ^~

mergeLists.cpp:42:19: error: ‘const class ReadingList’ has no member named ‘end’

   42 |  while (i != cat1.end())

      |                   ^~~

mergeLists.cpp:44:14: error: invalid type argument of unary ‘*’ (have ‘ReadingList::const_iterator’ {aka ‘int’})

   44 |   result.add(*i);

      |              ^~

mergeLists.cpp:47:19: error: ‘const class ReadingList’ has no member named ‘end’

   47 |  while (j != cat2.end())

      |                   ^~~

mergeLists.cpp:49:14: error: invalid type argument of unary ‘*’ (have ‘ReadingList::const_iterator’ {aka ‘int’})

   49 |   result.add(*j);

      |              ^~

make: *** [makefile:54: mergeLists.o] Error 1

“make all” terminated with exit code 2. Build might be incomplete.

14:37:11 Build Failed. 11 errors, 0 warnings. (took 4s.338ms)

Get 20% Discount on This Paper
Pages (550 words)
Approximate price: -

Try it now!

Get 20% Discount on This Paper

We'll send you the first draft for approval by at
Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

Custom Writings Help is a Quality-Oriented Company in Online Writing as a result of hiring exceptional professionals to execute clients' tasks.

Essays

Research Papers

At Custom Writings Help,We understand the struggle of research paper writing, and that is why at Custom WritingS Help, we are all out to help you. We pride ourselves on having a team of clinical writers. The stringent and rigorous vetting process ensures that only the 'BEST' Writers are chosen for the job. We have highly qualified Ph.D. and MA writers working with us; we equally offer these experienced writers specific bonuses and incentives to make them deliver highly original, unique, and informative content at reasonably low prices.

Admissions

Thesis Writing Service

Worlwide, Many Masters Students are struggling with Thesis Completion. A thesis is likely to be the longest and most challenging piece of work a student has ever completed. However, unlike essays and other assignments, a student can pick a particular interest topic and work on their initiative. Fortunately, we are there for you. At Custom Writings Help, you are assured of an authentic, imaginative, informative, linguistically great, and advantageous thesis that adheres to all your needs. So, why continue considering different writers when you have discovered the best in the field?

Editing

Custom Papers

Not a single student can avoid writing custom papers. However, a total lack of experience, skills, and time makes it very hard to produce a superb writing piece. Therefore, if you are seeking professional help, turn to us. Our specialized and experienced writers compose a variety of model papers, including custom essays, college term papers, research papers, book reports, MBA essays, executive summaries, dissertations, Ph.D. theses, admission essays, and research proposals for college and university students at any level.

Coursework

Essay Writing

Most of the students disregard the critical principles of essay writing and compose papers below sensible guidelines. Therefore, with Custom Writings Help, one should not worry about his/her essay. Our Writers compose informative and engaging content on all complexities and topics. We write meaningful and smart essays while prioritizing all aspects that bring about a good grade, such as impeccable grammar, proper structure, zero-plagiarism, and conformance to guidelines.

Coursework

Coourse Work Writing

Don't let the seemingly never-ending onslaught of writing assignments get you down. If you are looking where to get course work assistance online, the writers at Custom Writings Help are here to assist you with all of your writing needs. We undertake to unique delivery of papers that meet the professor's requirements. The content is proofread, edited, and checked plagiarism before submission to customers. No matter how big or small your work is, we will deliver on time. Try US Now! !

Coursework

Dissertation Writing Service

High-Quality Dissertation Writing Services are rare. They require Ph.D. academicians – not easily found. However, are an exception. The years, time, and resources we have invested in the dissertation world has given us a competitive advantage over others. Choose to come to Custom Writings Help; You will find perfect Ph.D. consultants who have written hundreds of dissertations theses ready to help you. Let our dissertation-writing services help you craft your dissertation, for you are assured we will give you the results.