0

This is my first project in university, I need to develop an application for a library so I have 4 classes
1- sub class (Book): it have the book info
2-sub class (libMember): it have the members info
3-main class (LibrarySystem): I have the methods of adding, removing etc. to both Book and libMember classes
4-test class (LibraryMain): basically the main functions in it.

it's an easy concept but I'm struggling with connecting all the classes together.
do I use interface (implement) or should I use inheritance (extends)?
i know that i can't extend multipule classes in java, but how else would be doing it.

  • 3
    As a rule, inheritance-based solutions are really bad. You should not look for reasons to actively use it. Unless there is some requirement of the assignment to use it (i.e. to demonstrate your understanding), then try to avoid it. – Michael Dec 07 '21 at 12:48
  • 1
    I'm not sure either inheritance or interfaces are the correct solution. A Book isn't a more specific Library System and neither is a Library Member. The typical examples for inheritance are usually something like `Dog extends Animal` which makes sense because a Dog is a more specific type of animal. `Book extends LibrarySystem` makes little sense to me. – OH GOD SPIDERS Dec 07 '21 at 12:53
  • 2
    Nothing here seems to have an inheritance relationship: a book isn't a member, a member isn't a book; a book isn't a library system, a library system isn't a book etc. – Andy Turner Dec 07 '21 at 12:53
  • 1
    Unless your assignment specifically states to use inheritance you should rather just use [composition](https://stackoverflow.com/questions/3441090/what-is-composition-as-it-relates-to-object-oriented-design). A Library System is composed of multiple books and members. – OH GOD SPIDERS Dec 07 '21 at 12:56

0 Answers0