aspose file tools*
The moose likes Beginning Java and the fly likes Very new and confused Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Very new and confused" Watch "Very new and confused" New topic
Author

Very new and confused

Vlada Den
Ranch Hand

Joined: Dec 19, 2004
Posts: 32
Hi all,

I am very new to Java. Could you, please, help me out with the following code:

public class Librarian extends User {
private String category;

public Librarian(String aName, int aUserID, String aTelephoneNo,
String category) {
super(aName, aUserID, aTelephoneNo);
this.category = category;
}

public String getCategory() {
return category;
}

public void setCategory(String category) {
this.category = category;
}

public String toString() {
return super.toString() + "\t Category: " + category;
}
}

The class Librarian should be changed to reflect the situation where a librarian should be able to be associated with a list of categories (each category is still registered as a String).

My code may not be perfect, too

Please, help!

Thanks a lot,

Vlada
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9052
    
  12
Can you give an example of a Catagory?

I think you probably do not want to have String catagory in the constructor.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Vlada Den
Ranch Hand

Joined: Dec 19, 2004
Posts: 32
Thanks for reply!

Category is a String holding the book-category in which the librarian is considered an expert. But librarians are often experts in more than one book-category. So how to implement this. I guess, it's something to do with an array list.

Vlada
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9052
    
  12

Rather than a member variable of type String named catagory, I suggest you use a private member variable of type ArrayList named catagory. You can store the Strings in the ArrayList.

Also remember to remove it from the constructor.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Very new and confused