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

Assignment Help has assembled a team of highly skilled writers with diverse experience in the online writing circles. Our aim is to become a one stop shop for all your Academic/ online writing. Check out below our amazing service!

Essays

Essay Writing Services

At Assignment Help, we prioritize on all aspects that creates a good grade such as impeccable grammar, proper structure, zero-plagiarism, and conformance to guidelines. The principal purpose of essay writing is to present the author's evaluation concerning a singular subject about which they have made. Since Professionalism is the mother of every success, try our team of experienced writers in helping you complete your essays and other assignments.

Admissions

Admission Papers

You have been trying to join that prestigious institution you long yearned for, but the hurdle of an admission essay has become a stumbling block. We have your back, with our proven team that has gained invaluable experience over time, your chance of joining that institution is now! Just let us work on that essay.How do you write an admission essay? How do you begin the essay? For answers, try Quality Custom Writers Now!

Editing

Editing and Proofreading

Regardless of whether you're pleased with your composing abilities, it's never an impractical notion to have a second eye go through your work. The best editing services leaves no mistake untouched. We recognize the stuff needed to polish up a writing; as a component of our editing and proofreading, we'll change and refine your write up to guarantee it's amazing, and blunder free. Our group of expert editors will examine your work, giving an impeccable touch of English while ensuring your punctuation and sentence structures are top-notch.

Coursework

Technical papers

We pride ourselves in having a team of clinical writers. The stringent and rigorous vetting process ensures that only the best persons for job. We hire qualified PhD and MA writers only. We equally offer our team of writers bonuses and incentives to motivate their working spirit in terms of delivering original, unique, and informative content. They are our resources drawn from diverse fields. Therefore your technical paper is in the right hands. Every paper is assessed and only the writers with the technical know-how in that field get to work on it.

Coursework

College Essay Writing

If all along you have been looking for a trustworthy college essay service provider that provides superb academic papers at reasonable prices, then be glad that you search has ended with us. We are your best choice! Get high-quality college essay writing from our magnificent team of knowledgeable and dedicated writers right now!

Coursework

Quality Assignment/Homework Help

We give the students premium quality assignments, without alarming them with plagiarism and referencing issues. We ensure that the assignments stick to the rules given by the tutors. We are specific about the deadlines you give us. We assure you that you will get your papers well in advance, knowing that you will review and return it if there are any changes, which should be incorporated.