By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,646 Members | 1,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,646 IT Pros & Developers. It's quick & easy.

Book Library system

P: 20
Please can someone help in correcting the following attempt of the questions below. I have included my attempt at the problem
I have been asked to write class definations which does the following among other things in C++.
a) Library needs to able to get the following information about its customers: firstname, last name, address and telephone numbers.

b) the library needs to be able to add customers and books to its records.

Assume these records need not be modified or deleted in any way

Expand|Select|Wrap|Line Numbers
  1.     // This program get or request the customer to enter their details and or details of the book.
  2. # include <iostream.h>
  3. # include “Library.h”
  4. int Main ()
  5. {
  6. Void display Customer details (Char*Char[], String);
  7. Void display books details (Char*Char[], double);
  8. Void display books on loan (Char, date)
  9. Void display books due (Char, date);
  10.  
  11.  
  12.  
  13.  
  14. Void add customers, books (Char*Char[], double);
  15. Void print report details (Char, double, string);
  16. }
  17. Void Library: : display customers details ()
  18. {
  19. cout << “Enter First name” <<endl;
  20. cin >> First name;
  21. cout << “Enter Last Name” <<endl;
  22. cin >> Last name;
  23. cout << “Enter Address” <<endl;
  24. cin >> Address;
  25. cout << “Enter telephone number” <<endl;
  26. cin >> telephone number;
  27. }
  28. Void Library: : Display Book details ()
  29. {
  30. cout << “Enter Title” <<endl;
  31. cin >> Title;
  32. cout << “Enter Author” <<endl;
  33. cin >> Aithor;
  34. cout << “Enter ISDN Number” <<endl;
  35. cin >> ISDN Number;
  36. cout << “Enter Number of pages” <<endl;
  37. cin >> Number of pages;
  38. }
  39. Void Library: : Display book loans ()
  40. {
  41. int on loan date;
  42. int date due returned;
  43. cout << “enter on loan date” <<endl;
  44. cin >> on loan date;
  45. cout << “Enter date due returned” <<endl;
  46. cin >> Date due returned;
  47. }
  48.  
  49. Void Library: : Add Customer, Books ()
  50. {
  51. cout << “Add First name”<<First name<< “Last name” <<Last name<< “Address” <<Address<< “telephone number” <<telephone number<<endl;
  52. cin >>First name >>last name >>Address >>Telephone number;
  53. cout << “Add Title<< Title<< “Author”<< Author<< “ISDN Number”<< ISDN Number<< “number of pages”<< Number of pages <<endl;
  54. cin >> Title>> Author>> ISDN number>> Number of pages;
  55. }
  56. Void Library: : Display customer loans ()
  57. {
  58. int on loan date;
  59. int date due returned;
  60. cout << “enter on loan date” <<endl;
  61. cin >> on loan date;
  62. cout <<”Enter date due returned” <<endl;
  63. cin >> Date due returned;
  64. }
  65. Void Library: : Print detail report ()
  66. cout << “The details of each customer with loan books is”<<customer<<endl;
  67. cout<< “The detail of each book on loan is”<<book<<endl;
  68. cout << “The detail of loan is” <<loan<<endl;
  69.                 or
  70. }
  71. Void Library: : print detail report()
  72. cout << “customer”<< “book”<< “loan”<<endl;
  73. cin >> customer>>book>>loan>>endl;
  74. }
  75. Return 0;
  76.  
c) wrie the implementation of the customers class in C++

iii) Class Customer
Expand|Select|Wrap|Line Numbers
  1. {
  2. Public: :        // Modifiers
  3.     Customer (); // default constructor
  4. Void display customer details (Char*Char [], String);
  5. Private: :        // Queries
  6.     Char First name [20], Last name[25];
  7.     Char Address;
  8.     String Telephone number;
  9. };
  10.  
D) SUPPOSE THE CUSTOMER WANTS TO FIND A SPECIFIC book and knows the title of the book. Write a program that iterates through its records of books and return to a pointer to the matching book

iv) Class Library
Expand|Select|Wrap|Line Numbers
  1. {
  2. Public : 
  3.         Library ();
  4.         Void display total records of books (Char, double);
  5.  
  6. Private:
  7.         Char Title, Author;
  8.         Double ISDN number, Number of pages
  9.  
Feb 15 '07 #1
Share this Question
Share on Google+
4 Replies


Ganon11
Expert 2.5K+
P: 3,652
OK, so what parts are you having trouble with?
Feb 15 '07 #2

P: 10
What I would do is create three classes: one class for the book object, one for the customer object, and one class for the library, that is a collection of both books and one of customers, implemented as lists.
Henceforth, my headers would look something like:

Expand|Select|Wrap|Line Numbers
  1. class Book{
  2.     private:
  3.         string Title;
  4.         string Author;
  5.         int ISSBN;
  6.     public:
  7.         Book *pnext;
  8.  
  9.         Book();
  10.         Book(string tit, string aut, string ed, int i);
  11.  
  12.         string getTitle();
  13.         string getAuthor();
  14.         int getIssbn();
  15. };
  16.  
  17. class Customer{
  18.     private:
  19.         string Name;
  20.         string Surname;
  21.         string Address;
  22.                         string Phone;
  23.     public:
  24.         Customer *pnext;
  25.  
  26.         Customer();
  27.         Customer(string name, string surname, string addres, string phone);
  28.  
  29.         string getName();
  30.         string getSurname();
  31.         string getAddress();
  32.                         string getPhone();
  33. };
  34.  
  35. class Library{
  36.     private:
  37.         Book *collection;
  38.                         Customer *contacts;
  39.  
  40.     public:
  41.         Library();
  42.         ~Library();
  43.  
  44.         Book* getFirst_book();
  45.         void Insert_book(Book *pl);
  46.         void Display_book(Book *pl);
  47.                         void Search_book(string title);
  48.                         Customer* On_loan(Book *pl) 
  49.  
  50.                         Customer* getFirst_customer();
  51.         void Insert_customer(Customer *pl);
  52.         void Display_customer(Customer *pl);
  53.  
  54. };
Feb 15 '07 #3

P: 20
OK, so what parts are you having trouble with?

Could you check the code for me especially the last part part D
Feb 15 '07 #4

AdrianH
Expert 100+
P: 1,251
What you have written is pseudo-code, yes? Because, just by looking at it, it is not even close to be compliable.

What problems are you having exactly?


Adrian
Feb 15 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.