Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By jbarke12

Thread: Help

  1. #1
    M.west is offline Member
    Join Date
    Dec 2013
    Posts
    1
    Rep Power
    0

    Default Help

    I am using blue j and I need to help to write the coding for two scenarios.

    1. The Book class is a subclass of the LoanItem class and has just one attribute, which corresponds to the return date (YYMMDD) , which is a string of text. The parameters of the constructor represent the ISBN, the title and the Publisher , and these three values are passed together to the constructor of the LoanItem class. The return date is initialised in the constructor by being assigned the value of 000000 and has a corresponding accessor method.

    The Book class has a method to borrow a book, which accepts a borrower number and a return date as parameters.
    The month and day are extracted from the return date. If the borrower number is less than or equal to 0, a suitable error message is output. Otherwise (i.e. if the borrower number is ok), the month and day are checked together in a compound condition and, if either the month is greater than 12 or the day is greater than 31, a suitable error message is output. Otherwise (i.e. if there are no errors in the parameters) the return date of the book is given the value input and the method to set the borrower number residing in the LoanItem class is called. A method to return a book will call the method in the LoanItem class that resets the borrower number to 0 and will assign the return date to 000000. A method to display a book will call the method in LoanItem to display the ISBN, the title of the item, the publisher. and the borrower number before displaying the return date.

    2. The Offprint class is also a subclass of the LoanItem class and has two attributes, which correspondto a chapter of the book and the hour the chapter is to be returned. Both attributes are integers. The parameters of the constructor represent the ISBN, the title of the item, the publisher and these three values are passed together to the constructor of the LoanItem class. The chapter and hour to be returned are initialised to 0 in the constructor and they both have corresponding accessor methods.

    The Offprint class has a method to release a chapter of a book, which accepts a borrower number, the chapter of the book and the current hour as parameters. If the borrower number is less than or equal to 0,a suitable error message is output. Otherwise (i.e. if the borrower number is ok), the chapter and the current hour are checked together in a compound condition and, if either the chapter is less than or equal to 0, or the current hour is less than 9 (i.e. before the library opens at 9am), a suitable error message is output. Otherwise (i.e. if there are no errors in the parameters) the method to set the borrower number residing in the LoanItem class is called, the chapter of the book is given the value input and the hour the offprint is to be returned is given the following value. If the current hour is greater than or equal to 18, the hour the offprint is to be returned is set to 21 (because the library closes at 9pm), otherwise the hour the offprint is to be returned is set to the current hour + 3 (because the offprint can be loaned for up to 3 hours)

    A method to return an offprint will call the method in the LoanItem class that resets the borrower number to 0 and will assign the hour the offprint is to be returned to 0 and the book chapter to 0. A method to display an off print will call the method in LoanItem to display the ISBN, the title of the item, the publisher and the borrower number, before displaying the hour the offprint is to be returned and the book chapter.

    I have done the LoanItem class myself but I need help on the other 2 classes. I would really appreciate if someone helps. Thanks.

  2. #2
    jbarke12's Avatar
    jbarke12 is offline Member
    Join Date
    May 2013
    Location
    Charleston, South Carolina USA
    Posts
    88
    Rep Power
    0

    Default Re: Help

    We can't help you till you try and show us you are having issues with a particular part.
    tricky2 likes this.

  3. #3
    tricky2 is offline Member
    Join Date
    Dec 2013
    Posts
    1
    Rep Power
    0

    Default Re: Help

    Hi,

    Im having a problem with the same question also done the Loan class and has compiled. Im having a problem with book class...

    This is what i done so far for the book class...

    public class Book extends LoanItem
    {

    public Book(String ISBN, String theTitle, String thePublisher, String date)
    {

    super (ISBN, theTitle, thePublisher);
    date = "000000";
    }

    public void setdate(String YYMMDD)
    {
    date = YYMMDD;
    }

    public String getdate()
    {
    return date;
    }

    }

  4. #4
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,277
    Rep Power
    6

    Default Re: Help

    You need to study how class attributes work. You keep referring to a "date" property that does not exist.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Posting Permissions

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