I have an assignment about methods, and 2 variables of Date type:
- _borrowedDate(which is related to a- Datemethod as well)
- _returnDate(which is also a- Datetype)
I also have an int MAX_DAYS = 30
I need to set up a borrowdate, then accept a returndate, and if the days of the return date are greater then 30 (MAX_DAYS), compared to the borrowed date, I'm supposed to output true.
public class Book {
    private String _title;
    private String _author;
    private int _yearPublished;
    private int _noOfPages;
    private boolean _borrowed;
    private String _studentName;
    private Date _borrowedDate;
    private Date _returnDate;
    final int MAX_DAYS = 30;
    final int FINE = 5;
    final int MIN_YEAR =1800;
    final int MAX_YEAR = 2018;
    final int DEFAULT_YEAR = 2000;
    int d1;
    int days;
    public Book( String title, String author, int yearPublished, int noOfPages)
    {
        if (yearPublished <MIN_YEAR || yearPublished >MAX_YEAR){
            _yearPublished = DEFAULT_YEAR;
            _title = title;
            _author = author;
            _noOfPages = noOfPages;}
        else{
            _title = title;
            _author = author;
            _yearPublished = yearPublished;
            _noOfPages = noOfPages;
        }
    }
    public Book ( Book other) {
        _title = other._title;
        _author = other._author;
        _yearPublished = other._yearPublished;
        _noOfPages = other._noOfPages;
        _borrowed = other._borrowed;
        _studentName = other._studentName;
        _borrowedDate = other._borrowedDate;
        _returnDate = other._returnDate;
    }
    public boolean equal(Book compare){
        return ((_title == compare._title)&&(_author==compare._author)&&(_yearPublished==compare._yearPublished)
            &&(_noOfPages==compare._noOfPages)&&(_borrowed==compare._borrowed)&&(_studentName==compare._studentName)
            &&(_borrowedDate==compare._borrowedDate)&&(_returnDate==compare._returnDate));
    }
    boolean olderBook(Book other){
        return other._yearPublished > _yearPublished;
    }
    public int getYear(){
        return _yearPublished;
    }
    public int getPages(){
        return _noOfPages;
    }
    public String getTitle(){
        return _title;
    }
    public String getAuthor(){
        return _author;
    }
    public boolean getBorrowed(){
        return _borrowed;
    }
    public String toString(){
        return "Title:"+_title+"Author:"+_author+ "Year:"+_yearPublished+","+_noOfPages+"pages";
    }
    private  int calculateDate(int day, int month,int year){
        if(month<3){
            year--;
            month += 12;
        }
        return  365*year+year/4-year/100+year/400+((month+1)*306)/10+(day-62);
    }
    public void borrowBook(String name, Date d){
        _studentName = name;
        _borrowedDate = new Date(d);
        _borrowed = true;
    }
    public boolean returnBook(Date d){
        _returnDate = new Date(d);
        _studentName = null;
        return (_returnDate.after(_borrowedDate));
    }
    public int howLongBorrowed(Date d){
        return 5;   
    }
    public void setYear(int n){
        if(n > MAX_YEAR || n<MIN_YEAR){
            _yearPublished = _yearPublished;
        }
        else
            _yearPublished = n;
    }
    public Date getBorrowedDate(){
        return _borrowedDate;   
    }
    public String getStudentName(){
        return _studentName;
    }
    public Date getReturnDate(){
        return _returnDate;
    }
    public void setTitle(String s){
        _title = s;
    }
    public void setAuthor(String s){
        _author = s;
    }
    public void setPages(int n){
        _noOfPages = n;
    }
    public boolean sameAuthor(Book other){
        return other._author.equals(_author);
    }
}
The code is yet been completed, just having trouble with this specific thing.
I've tried the obvious >, which didn't work because of different variable types.
.after works but I need to specifically do 30 days after, and that's about it.
 
     
     
    