setRefNumber
Spørgsmålet lyder:Add a further field, refNumber, to the Book class. This field can store a reference number for a library, for example. It should be of type String and initialised to the zero length string ("") in the constructor as its initial value is not passed in a parameter to the constructor. Instead, define a mutator for it with the following signature:
public void setRefNumber(String ref)
The body of this method should assign the value of the parameter to the refNumber field. Add a corresponding getRefNumber accessor to help you check that the mutator works correctly.
____________________________
class Book
{
private String author, title;
private int pages,
public Book(String bookAuthor, String bookTitle, int pages)
{
author = bookAuthor;
title = bookTitle;
this.pages = pages;
}
// Add the methods here ...
public String getAuthor()
{
return author;
}
public String gettitle()
{
return title;
}
public void printAuthor()
{
System.out.println(author);
}
public void printTitle()
{
System.out.println(title);
}
public int getpages()
{
return pages;
}
public void printDetails()
{
System.out.println(" Title:" + title + ", Author:" + author + ", pages:" + pages);
}
}
Det eneste jeg har lavet er de blå mærker, men håber i kan hjælpe mig videre?
Mvh Mads