Book Library system

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jchimanzi
    New Member
    • Feb 2007
    • 20

    Book Library system

    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

    Code:
    	// This program get or request the customer to enter their details and or details of the book.
    # include <iostream.h>
    # include “Library.h”
    int Main ()
    {
    Void display Customer details (Char*Char[], String);
    Void display books details (Char*Char[], double);
    Void display books on loan (Char, date)
    Void display books due (Char, date);
    
    
    
    
    Void add customers, books (Char*Char[], double);
    Void print report details (Char, double, string);
    }
    Void Library: : display customers details ()
    {
    cout << “Enter First name” <<endl;
    cin >> First name;
    cout << “Enter Last Name” <<endl;
    cin >> Last name;
    cout << “Enter Address” <<endl;
    cin >> Address;
    cout << “Enter telephone number” <<endl;
    cin >> telephone number;
    }
    Void Library: : Display Book details ()
    {
    cout << “Enter Title” <<endl;
    cin >> Title;
    cout << “Enter Author” <<endl;
    cin >> Aithor;
    cout << “Enter ISDN Number” <<endl;
    cin >> ISDN Number;
    cout << “Enter Number of pages” <<endl;
    cin >> Number of pages;
    }
    Void Library: : Display book loans ()
    {
    int on loan date;
    int date due returned;
    cout << “enter on loan date” <<endl;
    cin >> on loan date;
    cout << “Enter date due returned” <<endl;
    cin >> Date due returned;
    }
    
    Void Library: : Add Customer, Books ()
    {
    cout << “Add First name”<<First name<< “Last name” <<Last name<< “Address” <<Address<< “telephone number” <<telephone number<<endl;
    cin >>First name >>last name >>Address >>Telephone number;
    cout << “Add Title<< Title<< “Author”<< Author<< “ISDN Number”<< ISDN Number<< “number of pages”<< Number of pages <<endl;
    cin >> Title>> Author>> ISDN number>> Number of pages;
    }
    Void Library: : Display customer loans ()
    {
    int on loan date;
    int date due returned;
    cout << “enter on loan date” <<endl;
    cin >> on loan date;
    cout <<”Enter date due returned” <<endl;
    cin >> Date due returned;
    }
    Void Library: : Print detail report ()
    cout << “The details of each customer with loan books is”<<customer<<endl;
    cout<< “The detail of each book on loan is”<<book<<endl;
    cout << “The detail of loan is” <<loan<<endl;
    				or
    }
    Void Library: : print detail report()
    cout << “customer”<< “book”<< “loan”<<endl;
    cin >> customer>>book>>loan>>endl;
    }
    Return 0;
    c) wrie the implementation of the customers class in C++

    iii) Class Customer
    Code:
    {
    Public: :		// Modifiers
    	Customer (); // default constructor
    Void display customer details (Char*Char [], String);
    Private: :		// Queries
    	Char First name [20], Last name[25];
    	Char Address;
    	String Telephone number;
    };
    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
    Code:
    {
    Public : 
    		Library ();
    		Void display total records of books (Char, double);
    
    Private:
    		Char Title, Author;
    		Double ISDN number, Number of pages
    Last edited by sicarie; Feb 15 '07, 06:05 PM. Reason: Added code tags.
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    OK, so what parts are you having trouble with?

    Comment

    • enri
      New Member
      • Feb 2007
      • 10

      #3
      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:

      Code:
      class Book{
      	private:
      		string Title;
      		string Author;
      		int ISSBN;
      	public:
      		Book *pnext;
      
      		Book();
      		Book(string tit, string aut, string ed, int i);
      
      		string getTitle();
      		string getAuthor();
      		int getIssbn();
      };
      
      class Customer{
      	private:
      		string Name;
      		string Surname;
      		string Address;
                              string Phone;
      	public:
      		Customer *pnext;
      
      		Customer();
      		Customer(string name, string surname, string addres, string phone);
      
      		string getName();
      		string getSurname();
      		string getAddress();
                              string getPhone();
      };
      
      class Library{
      	private:
      		Book *collection;
                              Customer *contacts;
      
      	public:
      		Library();
      		~Library();
      
      		Book* getFirst_book();
      		void Insert_book(Book *pl);
      		void Display_book(Book *pl);
                              void Search_book(string title);
                              Customer* On_loan(Book *pl) 
      
                              Customer* getFirst_customer();
      		void Insert_customer(Customer *pl);
      		void Display_customer(Customer *pl);
      		
      };
      Last edited by enri; Feb 15 '07, 07:01 PM. Reason: indentation

      Comment

      • jchimanzi
        New Member
        • Feb 2007
        • 20

        #4
        Originally posted by Ganon11
        OK, so what parts are you having trouble with?

        Could you check the code for me especially the last part part D

        Comment

        • AdrianH
          Recognized Expert Top Contributor
          • Feb 2007
          • 1251

          #5
          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

          Comment

          Working...