Question

Part 1 The purpose of this part of the assignment is to give you practice in...

Part 1

The purpose of this part of the assignment is to give you practice in creating a class. You will develop a program that creates a class for a book. The main program will simply test this class.

The class will have the following data members:

A string for the name of the author

A string for the book title

A long integer for the ISBN

The class will have the following member functions (details about each one are below:)

A default constructor

A Print function which prints out all the information about the book.

A GetData function which reads information from a file into the data members.

A function GetISBN that returns the integer containing the ISBN. (This will be needed in Part 2).

You must create your program using the following three files:

book.h – used for declaring your class. In this header file, the declarations of the class and its members (both data and functions) will be done without the definitions. The definitions should be done in the book.cpp file.

book.cpp – contains the definitions of the member functions:

The default constructor will initialize the author's name to “No name”, the title to "Unknown title", and the ISBN to 0.

The Print function will display all of the information about a book in a clear format. This will be a const function because it does not change the data members. For formatting purposes, you may assume that no name will have more than 20 characters and that no book title will have more than 50 characters.

The GetData function will have the input file as a parameter, will read information from the file and put appropriate values into the data members. (See below for the format of the data file.)

The GetISBN function will simply return the long integer containing the ISBN. It also will be a const function.

Mp8bookDriver.cpp – should contain the main program to test the class.

It should declare two book objects (book1 and book2) using the default constructor. Call the print function for book1 (to show that the default constructor is correct). Open the input file and call the GetData function for book2 and then print its information. Finally, test the GetISBN function for book2 and output the result returned from the function.

Format of Data file
The name of the data file is mp7book.txt
It has data for one book arranged as follows:

The name is on one line by itself (hint: use getline).

The title is on a line by itself.

The ISBN is on the third line.

mp7book.txt

Jane Smith
History Of This World
12349876

Get this part of the program working and save all the files before starting on Part 2. The output should be similar to the following:

Testing the book class by (your name)

The information for book 1 is:
No name Unknown title 0
The information for book 2 is:
Jane Smith History Of The World 12349876
book2 has ISBN 12349876
Press any key to continue

Part 2

Now you will use the book class to create an array of books for a small library. Note that the book.h and book.cpp files should not have to be changed at all - you just have to change the main program in the Mp8bookDriver.cpp file.

There is a new data file, mp7bookarray.txt. It contains the information for the books in the library using the same format as described above for each book. There will be exactly 10 books in the file.

Declare an array of books that could hold 10 book objects. Open the new data file and use a loop to call the GetData function to read the information about the books into the objects in the array. Print out the list of books in the library in a nice format. Notice that the books are arranged in order by ISBN in the data file.

Now imagine customers coming into the library who want to know whether a particular book is in the collection. Each customer knows the ISBN of the book. Open the third data file (mp8bookISBN.txt) which contains ISBN's, read each one, and use a binary search to find out whether the book is in the array. If it is found, print out all the information about the book, if not, print an appropriate message. Then repeat the process for each of the ISBN's until you get to the end of the file.

mp8bookarray.txt

H. M. Deitel
C++ How to Program
130895717
Judy Bishop
Java Gently
201593998
Jeff Salvage
The C++ Coach
201702894
Thomas Wu
Object-Oriented Programming with Java
256254621
Cay Horstmann
Computing Concepts with C++
471164372
Gary Bronson
Program Development and Design
534371302
Joyce Farrell
Object-Oriented Programming
619033614
D. S. Malik
C++ Programming
619062134
James Roberge
Introduction to Programming in C++
669347183
Nell Dale
C++ Plus Data Structures
763714704

mp8bokkISBN.txt
201593998
888899999
763714704
111122222
256254621
130895717
488881111
534371302
619033614

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Part 1 The purpose of this part of the assignment is to give you practice in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • You need to program a simple book library system. There are three java classes Book.java   //...

    You need to program a simple book library system. There are three java classes Book.java   // book object class Library.java   //library class A2.java //for testing The Book.java class represents book objects which contain the following fields title: a string which represents the book title. author: a string to hold the book author name year: book publication year isbn: a string of 10 numeric numbers. The book class will have also 3 constructors. -The default no argument constructor - A constructor...

  • Using C++ Skills Required Create and use classes Exception Handling, Read and write files, work vectors....

    Using C++ Skills Required Create and use classes Exception Handling, Read and write files, work vectors. Create Functions, include headers and other files, Loops(while, for), conditional(if, switch), datatypes,  etc. Assignment You work at the computer science library, and your boss just bought a bunch of new books for the library! All of the new books need to be cataloged and sorted back on the shelf. You don’t need to keep track of which customer has the book or not, just whether...

  • please Code in c++ Create a new Library class. You will need both a header file...

    please Code in c++ Create a new Library class. You will need both a header file and a source file for this class. The class will contain two data members: an array of Book objects the current number of books in the array Since the book array is moving from the main.cc file, you will also move the constant array size definition (MAX_ARR_SIZE) into the Library header file. Write the following functions for the Library class: a constructor that initializes...

  • C++ In this homework, you will implement a single linked list to store a list of computer science textbooks. Ever...

    C++ In this homework, you will implement a single linked list to store a list of computer science textbooks. Every book has a title, author, and an ISBN number. You will create 2 classes: Textbook and Library. Textbook class should have all above attributes and also a "next" pointer. Textbook Туре String String String Attribute title author ISBN Textbook* next Library class should have a head node as an attribute to keep the list of the books. Also, following member...

  • C++ Help. I am new to Visual Studio and C++ so please include comments! Please follow...

    C++ Help. I am new to Visual Studio and C++ so please include comments! Please follow the directions and make as simple as possible. Write a C++ program that reads the following list of input data (book.dat) and then allows users to search and view the books from a Menu List all available books Search for book using A. Title or B. ISBN? Exit Program The format of the file is as follows: //    The title of the book //   ...

  • Assignment Overview In Part 1 of this assignment, you will write a main program and several...

    Assignment Overview In Part 1 of this assignment, you will write a main program and several classes to create and print a small database of baseball player data. The assignment has been split into two parts to encourage you to code your program in an incremental fashion, a technique that will be increasingly important as the semester goes on. Purpose This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of...

  • C++ project we need to create a class for Book and Warehouse using Book.h and Warehouse.h header ...

    C++ project we need to create a class for Book and Warehouse using Book.h and Warehouse.h header files given. Then make a main program using Book and Warehouse to read data from book.dat and have functions to list and find book by isbn Objectives: Class Association and operator overloading This project is a continuation from Project 1. The program should accept the same input data file and support the same list and find operations. You will change the implementation of...

  • C++ program Correctly complete the following assignment. Follow all directions. The main purpose is to show...

    C++ program Correctly complete the following assignment. Follow all directions. The main purpose is to show super and sub class relationships with an array of super media pointers to sub class objects and dynamic binding. The < operator will be overloaded in the super class so all subclasses can use it. The selection sort method will be in the main .cpp file because it will sort the array created in main. The final .cpp file, the three .h header class...

  • Don't attempt if you can't attempt fully, i will dislike a nd negative comments would be...

    Don't attempt if you can't attempt fully, i will dislike a nd negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book tit le, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an...

  • Don't attempt if you can't attempt fully, i will dislike and negative comments would be given...

    Don't attempt if you can't attempt fully, i will dislike and negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book titnle, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an HTML web...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT