Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / You will be building a linked list

You will be building a linked list

Computer Science

You will be building a linked list. Make sure to keep track of both the head and tail nodes.

(1) Create five files to submit.

  • BooklistNode.h - Class declaration (template provided)
  • BooklistNode.cpp - Class definition
  • Booklist.h - Class declaration (template provided)
  • Booklist.cpp - Class definition
  • main.cpp - main() function

Build the BooklistNode class per the following specifications. Note: Some functions can initially be function stubs (empty functions), to be completed in later steps. All book names must be unique.

  • Default constructor
  • Parameterized constructor
  • Destructor
  • Public member functions
    • SetNext(BooklistNode* nodePtr) - Mutator, sets next to nodePtr
    • GetBookName() - Accessor
    • GetAuthorName() - Accessor
    • GetYearPublished() - Accessor
    • GetNext() - Accessor
    • string PrintBooklistNode()
  • Private data members
    • string bookName - Initialized to "none" in default constructor
    • string authorName - Initialized to "none" in default constructor
    • int yearPublished - Initialized to 0 in default constructor
    • BooklistNode* next - Initialized to NULL in default constructor

Ex. of PrintBooklistNode output string:

War and Peace

Author Name: Leo Tolstoy

Year Published: 1867

Build the BookList class per the following specifications. Note: Some functions can initially be function stubs (empty functions), to be completed in later steps.

  • Default constructor
  • Destructor - must destruct all nodes
  • Public member functions
    • BooklistNode* getHead() //returns the first node with actual data, if using a dummy node, don't return it as the head
    • BooklistNode* getTail() //return the last node with actual data.
    • bool add(string, string, int) //adds to the end of the Linked List, returns true if added, returns false if book name already used.
    • BooklistNode* found(string bookName) //returns the pointer to the BooklistNode if found, returns NULL if not found
    • bool remove(string bookName) //returns true if book is removed, returns false if book not found
    • bool moveFront(string stringName) //returns true if book moved to front of linked list, returns false if book not found
    • string displayAuthor(string authorName) //displays all books with this authorName. Look at examples for format. Use the PrintBookListNode() from the BookListNode.
    • int totalBooks(); //returns total number of books in the linked list
    • string displayList(); //returns a string of all books in the linked list. Look at examples for format. Returns null if list is empty.
  • Private data members
    • BooklistNode* head - Initialized to NULL in default constructor
    • BooklistNode* tail - Initialized to NULL in default constructor

(2) In main(), prompts the user for the title of the booklist.

Ex:

Enter booklist's title:

Favorites


and calls the PrintMenu() function. PrintMenu() takes the booklist title as a parameter and displays a menu of options to manipulate the booklist. Each option is represented by a single character. PrintMenu() calls the appropriate function in the BookList class, and outputs messages to the user.

If an invalid character is entered, continues to prompt for a valid choice.

Ex:

Favorites BOOKLIST MENU

a - Add book

d - Remove book

m - Move book to front

s - Output books by specific author

t - Output total number of books in booklist

o - Output full booklist

q - Quit

 

Choose an option:


(3) Implement the displayList function needed for the "Output full booklist" menu option. If the list is empty, outputs: Booklist is empty

Ex:

Favorites - OUTPUT FULL PLAYLIST

1.

War and Peace

Author Name: Leo Tolstoy

Year Published: 1867

 

2.

The Great Gatsby

Author Name: F. Scott Fitzgerald

Year Published: 1925

 

3.

Moby Dick

Author Name: Herman Melville

Year Published: 1851

 

4.

Anna Karenina

Author Name: Leo Tolstoy

Year Published: 1877

 

5.

The Curious Case of Benjamin Button

Author Name: F. Scott Fitzgerald

Year Published: 1922


(4) Implement the add function needed for the "Add book" menu item. New additions are added to the end of the list. If the book already exists, outputs "This book already exists" and is not added to the linked list

Ex:

ADD BOOK

Enter book's name:

Anna Karenina

Enter author's name:

Leo Tolstoy

Enter year published:

1877


(5) Implement remove for the "Remove book" function. Prompt the user for the name of the book to be removed. If the book is not in the list, outputs "(book name) not in list"

Ex:

REMOVE BOOK

Enter book's name:

The Great Gatsby

"The Great Gatsby" removed


(6) Implement moveFront for the "Move book to front" menu option. Prompt the user for the name of the book to be moved to the front. If the book is not in the list, outputs "(book name) not in list"

 

Ex:

MOVE BOOK TO BEGINNING

Enter book's name:

The Great Gatsby

"The Great Gatsby" moved to front of list


(7) Implement displayAuthor for the "Output books by specific author" menu option. Prompt the user for the author's name and output the node's information with this author's name, starting from the beginning of the list.

Ex:

OUTPUT BOOKS BY SPECIFIC AUTHOR

Enter author's name:

Leo Tolstoy

 

1.

War and Peace

Author Name: Leo Tolstoy

Year Published: 1867

 

2.

Anna Karenina

Author Name: Leo Tolstoy

Year Published: 1877


(8) Implement totalBooks for the "Output total number of books in booklist" menu option. Output the number of books in the booklist.

Ex:

OUTPUT TOTAL NUMBER OF BOOKS IN BOOKLIST

Total books: 5 books

 

Option 1

Low Cost Option
Download this past answer in few clicks

22.99 USD

PURCHASE SOLUTION

Already member?


Option 2

Custom new solution created by our subject matter experts

GET A QUOTE

Related Questions