[Solved] CSE240 Homework8- You are given a partially completed project

$25

File Name: CSE240_Homework8-_You_are_given_a_partially_completed_project.zip
File Size: 574.62 KB

SKU: [Solved] CSE240 Homework8- You are given a partially completed project Category: Tag:
5/5 - (1 vote)

  1. You are given a partially completed project containing:
  • header file:

book.h (contains the class Book)

  • C++ files:

book.cpp (contains the class function definitions)

hw08q1.cpp (contains the program to work on array of Book objects)

If you use VS, then create an empty C++ project. Then add the header file and CPP files, respectively, into your project as shown in the following screenshot:

If you use ASU General g++, then simply put the .h and .cpp files in one folder and compile with this command:

g++ book.cpp hw08q1.cpp -o out Execute with:

./out

Follow the instructions given in the comments of the hw08q1.cpp and book.cpp files to complete the missing parts of the project so that the program executes properly. You should first complete book.cpp and then go on to hw08q1.cpp. NOTE: In the homework, list means an array (not a linked list).

This is a menu-driven program that uses the following options:

  1. Add a new book. The book details (title, ID, aisle , bookType) are given as function arguments. You should add the book only if the book is not already present in the array and there is space in the array to add a new book.
  2. Display the all books information. See expected output below.
  3. Display only the books whose ID falls within a range (in descending order)
  4. Display the book with the longest title among the books whose bookType contain a specific substring. Ask the user for a substring. This function is used to demonstrate garbage collection.

You should start completing the program beginning from Q1. Question numbers are given on line 29 in hw08q1.cpp. (Q1 Q2 in book.cpp and Q3 Q6 in hw08q1.cpp)

Expected outputs:

addBook( ):

  • This function adds a new book with the details given in function arguments.
  • Add the book in b (array of objects) only if there is remaining capacity in the array and if the book does not already exist in the list (title or ID)
  • This function returns 1 if the book is added successfully, else it returns 0 for the cases mentioned above.
  • Assume user enters ID and aisle in 0 any positive integer range.

displayBooks( ):

  • This function displays the list of books.
  • Parse the object array b and display the details of all books in the array. See expected output given in question file.
  • You can call the class function displayBook() here. Note that these are two different functions.

sort( ):

  • This function sorts the books in descending order of ID, and then display the books within a given range.
  • You need to get lower bound and higher bound from user after printing a prompt.

bookTypeWithSpecificString( ):

  • This function displays a book with the longest title among the books whose bookType contain a specific substring.
  • You should find the book as follows:
    1. By traversing all books, you should find the books whose bookType include a specific substring.
    2. After step 1, you should find the book whose title is the longest. You may use titleLength and index variable.
    3. After step 2, copy the details of the book to bookWithLengthyTitle object created using new and display the books details using bookWithLengthyTitle object.
    4. Finally delete the bookWithLengthyTitle object.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSE240 Homework8- You are given a partially completed project
$25