

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A lab assignment for a csci 3110 course focused on inheritance, abstract base classes, and the standard template library (stl). Students are required to modify their seller and product classes, implement a sortedlist class, and read data from a file to create a vector of sellers. The document also includes instructions for creating derived classes of product, such as movie and book, and details on how to read and print data from the file.
Typology: Lab Reports
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Objective : To become familiar with the STL list and vector, inheritance and abstract base classes. Description : This assignment is a revision of the previous program assignment. The revisions include: Your client will create a vector containing sellers. Modify your seller class to contain all required methods when using a class with the Standard Template Library. Implement a SortedList that inherits from the STL list class. In the client, you will maintain a sorted list of pointers to products for each seller. The list will be sorted by product name. This class should provide an insertInOrder method that inserts an item into a list in order. This method should use methods from the STL class to insert the item. It should also contain any other items needed (that are not provided by STL) to allow the client to do its job. The product class is revised as follows: o It is now an abstract base class. o Instead of bidding information, it should contain a field called price. o It should contain a virtual method print() that prints the data members in product. The friend << is no longer needed. o It should also contain a virtual method read() that allows the product’s data members to be read from a data file. The friend >> is no longer needed. o It should contain a pure virtual function cost() that determines the cost of the product. o Add to the product class any methods necessary to use it with STL. Your revised program will contain the following derived classes of Product: o add a new class called Movie that contains additional members: upc – a string containing the universal product code (bar code) for the movie movie rating – an integer value used to rate a movie from 1 to 5 ( being the highest). The cost() of the movie is proportionally to the movie rating. It is the price plus the rating. o Add a new class called Book that contains additional members: Isbn – a string containing the ISBN number of the book Author – a string containing the author’s name in the form lastname, firstname Whether the book is new or used (bool) An enumerated type indicating the condition of the book (EXCELLENT, GOOD, FAIR, POOR) The cost of the book is just the price if it is new. However, if it is used, the price is discounted as follows: if the book’s condition is EXCELLENT, discount by 20%; if condition is GOOD, discount by 40%; if condition is FAIR, discount by 50%; and if condition is POOR, discount by 70%. Your client will read data from “sellers.txt” as in the previous programs. However, now after the information for a seller is entered, the list of products will appear as follows:
name). The name is followed by the price. Next will be a string for the movie’s UPC, then an integer for the movie’s rating.