Disvengeance
9 Oct 2005, 5:52am
Im writing this program for my programming class, when you use the setRefNumber method, it is supposed to set it to what you type if ref is greater than 3. But the problem is when you type in something greater than 3, it just sets it back to the default. any help? (i didnt include all of the source code)
public class Book
{
private String author;
private String title;
private int pages;
private String refNumber;
private int borrowed;
public Book(String bookAuthor, String bookTitle, int bookPages)
{
author = bookAuthor;
title = bookTitle;
pages = bookPages;
refNumber = " ";
}
public int getBorrowed() {
return borrowed;
}
public void setBorrowed(int booksBorrowed) {
borrowed = booksBorrowed;
}
public String getAuthor() {
return author;
}
public String getBookTitle() {
return title;
}
public int getBookPages() {
return pages;
}
public void setRefNumber(String ref) {
if(ref.length() > 3) {
ref = refNumber;
}
else {
refNumber = " ";
System.out.println("Error, Reference Number must be atleast 3 digits");
}
}
public class Book
{
private String author;
private String title;
private int pages;
private String refNumber;
private int borrowed;
public Book(String bookAuthor, String bookTitle, int bookPages)
{
author = bookAuthor;
title = bookTitle;
pages = bookPages;
refNumber = " ";
}
public int getBorrowed() {
return borrowed;
}
public void setBorrowed(int booksBorrowed) {
borrowed = booksBorrowed;
}
public String getAuthor() {
return author;
}
public String getBookTitle() {
return title;
}
public int getBookPages() {
return pages;
}
public void setRefNumber(String ref) {
if(ref.length() > 3) {
ref = refNumber;
}
else {
refNumber = " ";
System.out.println("Error, Reference Number must be atleast 3 digits");
}
}