Forums Register Login

Please help!!!

+Pie Number of slices to send: Send
Hi!
Can't seem to manage the following code:

public class Expert extends User {
private String category;
private int categoryIndex;

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

private List categoryList = new ArrayList();


public String getCategory(int categoryIndex) {
String empty = "";
for (int i = 0; i < categoryList.size(); i++) {
if(i==categoryIndex) {
empty = "" + categoryList.get(i);
}
}
return empty;
}

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

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

Any help would be greatly appreciated.
Thanks!
+Pie Number of slices to send: Send
hi vlada den,

where is the problem? what do you want the class to do that it is not doing or what is it doing wrongly?
+Pie Number of slices to send: Send
 

Originally posted by Vlada Den:
Can't seem to manage the following code:
...
Any help would be greatly appreciated.
Thanks!



How are you trying to "manage" it? Do you mean you don't know how to create an application from it? You'd need a main() method.

Are you getting compilation errors? What are they?

Can you compile but get runtime errors? What happens?

Do you get an Exception? What is it?
[ January 30, 2005: Message edited by: Marilyn de Queiroz ]
+Pie Number of slices to send: Send
I'm doing it in NetBeans, so the main method will be added, when I create A GUI. I get a compilation error in this line:

private List categoryList = new ArrayList();

Can't find out what's wrong here.
+Pie Number of slices to send: Send
 

Originally posted by Vlada Den:
I get a compilation error in this line:

private List categoryList = new ArrayList();

I'm going to guess (please don't make us guess!) that the errors you're getting areIf so, this is telling you that your Expert class doesn't define List and ArrayList.

If a class needs to use another class, it must import it. Import statements tell the compiler where to find the definition for another class that you want to use. They go at the top of the file after the package statement (if any) and before the class or interface definitions. They look like this:Your job is to find where the List and ArrayList classes are located. If you don't know, use the JavaDocs to find out.
[ January 30, 2005: Message edited by: David Harkness ]
+Pie Number of slices to send: Send
Now I see...
Thank you so much, David.
And I'll try to ask more to-the-point questions next time.
They weren't very bright, but they were very, very big. Ad contrast:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1367 times.
Similar Threads
SQL Results
Chain of Responsibility Pattern
how do i connect java to my oracle server i,m just beginning on jdbc
Chain of Responsibility Pattern
Very new and confused
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:42:03.