100% found this document useful (1 vote)
329 views2 pages

09 Lab (Graded) - Morning

This document provides instructions for Lab 09 which involves implementing a BookList class to store Book objects in an unsorted order. The BookList class is to have functions for inserting books, removing books, searching by title, replacing books, checking if the list is empty/full, moving the cursor position, retrieving the cursor book, and outputting the book structure. The main function will read book data from a text file and store it in the BookList. Students are to work individually and test the BookList class functionality.

Uploaded by

Asad Ali Bhatti
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
329 views2 pages

09 Lab (Graded) - Morning

This document provides instructions for Lab 09 which involves implementing a BookList class to store Book objects in an unsorted order. The BookList class is to have functions for inserting books, removing books, searching by title, replacing books, checking if the list is empty/full, moving the cursor position, retrieving the cursor book, and outputting the book structure. The main function will read book data from a text file and store it in the BookList. Students are to work individually and test the BookList class functionality.

Uploaded by

Asad Ali Bhatti
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Data Structures and Algorithms

Lab 09

Da t a
Lab 09 Instructions

S t r u c tu r e s

A n d

A l g o r i th m s
Marks 100

End Time: 05:00

Work on this lab individually. You can use your books, notes, handouts etc. but you are not allowed to borrow anything from your peer student. What you have to do Implement the BookList class which stores Books in unsorted order. Your class declarations should look like: class Book { friend class BookList; private: int id; string title; float price; Book *next;

//id of a book. //name of a book. //price of a book. //address of the next available object. //parameterized constructor

public: Book(int id, string title, float price, Book *next); }; class BookList { private: Book *head; Book *cursor; public: BookList(); ~BookList(); };

//start of the list //current item of the list //default constructor //destructor

The BookList class should also have the following public member functions: void insert (const Book &newItem) Inserts newItem into a list. If the list is not empty, then inserts newItem after the cursor. Otherwise, inserts newItem as the first (and only) data item in the list. In either case, moves the cursor to newItem. void remove () Remove the data item marked by the cursor from a list. If the resulting list is not empty, then moves the cursor to the data item that followed the deleted data item. If the deleted data item was at the end of the list, then moves the cursor to the beginning of the list. void search (string title) This function searches for book(s) based on its title in the book list. It should dispaly all the information about the book(s) if found otherwise display an appropriate message. void replace (const Book &newItem) Replace the data item marked by the cursor with newItem. The cursor remains at newItem. bool isEmpty () const Returns true if a list is empty. Otherwise, returns false. bool isFull () const Returns true if a list is full. Otherwise, returns false. void gotoBeginning () Moves the cursor to the beginning of the list

Umair Babar, PUCIT PU. Lahore.

Page 1 of 2

Data Structures and Algorithms

Lab 09

void gotoEnd () Moves the cursor to the end of the list. Book getCursor () Returns a copy of the data item marked by the cursor. void showStructure () const Outputs the data items in a list. If the list is empty, outputs Empty list. In the main function, your program should take the data of books from a text file input.txt and store the info of each book into the book list. The file is in the following format: id; line break, title; line break, price and then a blank line followed by the data of next book, exactly in the same order as described above. Test the functionality of your BookList class by creating some of its objects.

BEST OF LUCK

Umair Babar, PUCIT PU. Lahore.

Page 2 of 2

You might also like