-
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.
-
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.
-
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 ?
-
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.