Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
its what i thought, tell me is it correct

class Member
Feilds: Name , type, member ID,password, Address, borrowing limitation
methods: registeration, login, borrow, return book, reciept

Class Librarian
Fields: Name, ID, password
Methods: login, Add book, delete book, update book

Class Book
Fields: name, author, edition, publisher, no of books, status , rack no

book class is inherited in Member and librarian class
Posted

Why would a book inherit from a member or librarian? A librarian is a person who can check out a book, so the librarian class would contain a list of books checked out by that person.
 
Share this answer
 
Comments
Аslam Iqbal 21-Aug-11 11:38am    
I think this is the best reply. 5
BillWoodruff 23-Aug-11 1:53am    
Yes, John ! Strange: I put in a comment expressing a similar idea last night, and today ... it was gone. So I have restored it.
u need to have a person class and library class
inheritance in member, Librarian from Person (member is-a person)
composition of book, member, librarian in Library (library has books, members and librarian)

Class Person:
Fields: Name, ID, Address, Email etc
Methods: Related To Fields

Class Member: Person
Fields: Username, Password, Borrowed[], ReturnedBooks[], Receipt, BorrowingLimitation, IsDefaulter
Methods: Related to Fields, but u should add Login Method to Library

Class Librarian: Person
Fields: Username, password, Rank
Methods: Add book, delete book, update book

(since in true OOP, Librarian doesn't have any info of book, so it will cal methods of books class to set their properties, fields accordingly)

Class Book
Fields: ID, name, author, edition, publisher, InStock(total no of books), Issued(total no of Issued Books), rack no
Methods: IssueBook, ReturnBook, EditBook


Class Library
Fields: Name, Address, TelePhone, Books[], Members[], Librarians[]
Methods: AddMemebr, RomoveMemebr, . . .. . AddBook, RemoveBook


Hope u get it.
 
Share this answer
 
Comments
Sweety Khan 21-Aug-11 15:46pm    
yeh it is quite clear. just one thing why AddBook and RemoveBook is in library?
dontumindit 21-Aug-11 15:54pm    
this AddBook and RemoveBook is for adding the new books to library and removing the old books from library. With Passage of time some books get out of library bcz they r of no use etc.

Ur question reminds me one of my own assignment, wel best of luck
Sweety Khan 21-Aug-11 16:01pm    
yeh but the librarian's AddBook , deleteBook is doing the same thing.
yes its my assignment n i have to submit it after 2 days :)
dontumindit 22-Aug-11 11:25am    
hmmmmmmm then its fine, actually there are lots of ways to solve one problem, both ways its correct, best of luck for assignment. i think u r going in right direction.
fjdiewornncalwe 21-Aug-11 18:33pm    
Abdur, please write complete words in your answers and avoid the "text-speak". If you choose not to, you will find that many members here will downvote the answer on that basis alone. I have not on this occasion because I always extend the courtesy of mentioning it first. Cheers.
Khan, do you mean the book class inherit Member & Librarian? IMO, The Librarian & Member class should inherit books so that you can access the book properties that the Liberian has added, modified or deleted and you can access the the books that each members have access to. This seems like a 'crappy' method, but I think it produce the desired results.
 
Share this answer
 
v2
Comments
Sweety Khan 21-Aug-11 9:11am    
no i mean exactly wht u said in the second sentence
Sweety Khan 21-Aug-11 10:25am    
no i dont want to do it by crappy method. tell me something tht is best
Hi, I think it's always valuable to think in terms of 'is-a', 'has-a' and 'contains' relationships.

A Librarian is-a Person; a Member is-a Person.

A Library contains a collection of Books, Librarian(s), Members.

'Book' is your 'atomic element' here.

A Member has-a collection of books: the ones they've checked out.

A Librarian's has-a collections of books may be several : books just returned, and not yet put back on the shelves, books ordered, books overdue for return.

Your methods seem right.
 
Share this answer
 
Comments
Аslam Iqbal 21-Aug-11 11:42am    
how? Member inherits book. there is no one-to-many relation(member to book). If that exist you can say member has a collection of books. inheritance is no a relation having collection.
BillWoodruff 23-Aug-11 1:52am    
In my opinion having Member or Librarian inherit from Book is bad design, and so would be Book inheriting from Member or Librarian !
Can i have a look on the sample code? i need it for practical purpose...beginners for OOP ...ur kindness would be very much appreciated. thX
 
Share this answer
 
Comments
[no name] 28-Jun-12 13:12pm    
This is not an answer to the question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900