Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Java by Yassi ( 15 years ago )
/**
* A class that maintains information on a book.
* This might form part of a larger application such
* as a library system, for instance.
*
* @author (Insert your name here.)
* @version (Insert today's date here.)
*/
class Book
{
// The fields.
private String author;
private String title;
private int pages;
private String refNumber;
/**
* Set the author and title fields when this object
* is constructed.
*/
public Book(String bookAuthor, String bookTitle, int nrPages)
{
author = bookAuthor;
title = bookTitle;
pages = nrPages;
refNumber = "";
}
// Add the methods here ...
public String getAuthor () {
return author;
}
public String getTitle () {
return title;
}
public void print() {
System.out.println (author);
System.out.println (title) ;
}
public int getPages(){
return pages;
}
public void printDetails() {
System.out.println("##################################");
System.out.println ("Title: " + title);
System.out.println ("Author: " + author);
System.out.println ("NoPages: " + pages);
System.out.println("###################################");}
}
public void set refNumber(String ref){
refNumber = ref;
}
public String getrefNumber(){
return refNumber;
}
Revise this Paste