Hi!. I'm going to ask for a long question so if anyone has time to respond I will appreciate it. I have this assignment but i'm really stuck in some parts. Here is the assignment
Create class Book that modulates a book and has two attributes : name(String) and ISBN(int) that is
read-only. Create class Library that modulates an library and has two attributes: name(String) and books(array of type book)
Class Book: a) Create constructor that gets two parameters (name, ISBN) and initialize them.
b) Offer get and set methods for class attributes
c) If name is empty or ISBN is smaller than zero(0), throw an LibraryException with a clear
message on why user can't create Book instance
d) Offer method that represent object like String(toString). The format should be:
e) Offer method that compares for equality two objects of type Book.
Notice: two objects of type book are equal if they have ISBN attribute equal
Class Library: a) Create constructor of this class that gets as parameters name of the Library and
number of books in the library. The Library should have at least 500 books. If it
has less than 500 books throw an LibraryException whith the message that there aren't
b) Offer method addBook that make possible to save the book in array of books. If the
book exist or it doesn't have space in array throw an LibraryException with the message that
the book exist or there isn't enough space.
c) Offer method indexOf(Book book) that returns value of index where book is located.
If the book isn't there than return -1.
d) Offer main() method and create instance of class Library with name "DanBrown" and
the possibility to save 750 books. Chose three books and add them in this library.
Also in main method handle all LibraryExtension cases
Class LibraryException: Create this specific Exception that will be used in Book and Library classes.
Below are codes of three classes that I tried to do so if anyone has time please check them and if you can give me some hints on how to continue. Thanks
loni gashi wrote:Hi!. I'm going to ask for a long question so if anyone has time to respond I will appreciate it. I have this assignment but i'm really stuck in some parts. Here is the assignment:
Below are codes of three classes that I tried to do so if anyone has time please check them and if you can give me some hints on how to continue.
It's very difficult to advise anything until we know what the problem is. What exactly are the issues you have?
Apart from what Campbell already said, and this business about "read-only", which would seem to conflict with the request for "setters" - but that's a problem with the requirements, not you - I can't see a lot to advise on.
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here