I cannot compile the code, below, because i have 17 errors regarding "non-static variable this cannot be referenced from a static context".
It is always pointing at the this
keyword.
package MyLib;
import java.util.*;
class Book {
static int pages;
static String Title;
static String Author;
static int status;
static String BorrowedBy;
static Date ReturnDate;
static Date DueDate;
public static final int
BORROWED = 0;
public static final int
AVAILABLE = 1;
public static final int
RESERVED = 2;
//constructor
public Book ( String Title, String Author, int pp) {
this.Title = Title;
this.Author = Author;
this.pages = pp;
this.status = this.AVAILABLE;
}
public static void borrow(String Borrower/*, Date Due*/){
if (this.status=this.AVAILABLE){
this.BorrowedBy=Borrower;
this.DueDate=Due;
}
else {
if(this.status == this.RESERVED && this.ReservedBy == Borrower){
this.BorrowedBy= Borrower;
this.DueDate=Due;
this.ReservedBy="";
this.status=this.BORROWED;
}
}
}