Results 1 to 4 of 4

Thread: Sos Q3

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    India
    Posts
    203

    Sos Q3

    Design suitable class/classes for a Library which allows issuing a maximum of 10 books to its members. A member is allowed to reserve a book if its not avauilible. the design shd cater to Defaullters. Time limit ( 20-25 mins)


    Ans:

    I have none...cdnt even get around 2 finding sumthing close....



    Guys...please help...this is a serious problem fr me.

  2. #2
    Zaei
    Guest
    Asking us to do your homework isnt going to get you very far =).

    Think about it this way... a Book is an object... A customer is an Object, that can hold several books (array of 10 book objects).... A library is an Object, that holds books, and customers.

    Z.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    India
    Posts
    203
    Howzz this ???


    Class Book
    {
    char name[];
    int ID;
    issued=0;

    public:
    void getdetails(){//entering details}
    void putdetails(){//showing details}

    void issue() { issued=1;}
    int issued() { return issued;}
    }

    Class customer
    {
    book b1[10];
    int num=0;

    public:
    void getdetails(){//entering details}
    void putdetails(){//showing details}

    void issue(book& b2)
    {
    if (b2.issued=1){//make reervations}
    if (num>=10){// check}
    else{
    b1[num]=b2;
    num++;
    b2.issue();
    }
    }
    };

    Class Library
    {

    void issue(Book b1,member m1)
    {
    m1.issue(b1);

    }
    };


    void main()
    {
    book b1;
    Member m1;
    b1.getdata();
    m1.getdata();
    library l1;
    l1(b1,m1);
    }


    meanwhile Ill try2 figure out the reservatiions bit...will create an 2-Dimesnional array I think....what say ?

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I would use string for names, make book::issued a bool...
    You can't initialize member variables directly, you have to do it in the constructor (I guess you know this)

    The Library should contain all books and customers. It should have a register function (add a customer). It should have a Issue and a Return function. It doesn't need to keep track which books are issued (the books do that).
    The Book should keep track if it is issued and how long. It should have a Issue and a Return function. The Return function should return the time the book was issued.
    The Customer should simply have a pointer to the Library and a array of the Books issued. It too should have a Issue and a Return, but it should only call the Library's functions. The Library can then check for availability and such. It can also reserve the Book. It should do that internally, maybe with a queue attached to the Book. It should report to the customer if a reserved book gets available.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width