hey guys im having problems at the moment finding any relevant information on the addEntry () code for the java language. any help as to how i can implement this in my program would be very appreciated. im a java newcomer.
Printable View
hey guys im having problems at the moment finding any relevant information on the addEntry () code for the java language. any help as to how i can implement this in my program would be very appreciated. im a java newcomer.
Ahem? What? I'm totally lost on what you are trying to do and what your question is, some context would be helpful.
hey PhHein this is the code stub i have to work off. this is new to me the addEntry() method, and the others too.. a bit of direction would be great. thanx
Code:public class Directory {
private static final int NO_ENTRIES = 100;
Entry[] theDirectory = new Entry[NO_ENTRIES];
// add an entry to theDirectory
// if theDirectory is full do not add the entry
public void add(Entry anEntry) {
}
// deletes an existing entry
public void delete(String nameToDelete) {
}
// change the number of an existing entry
public void change(String name, String newTelNo) {
}
// finds and returns the number for the search name
public String find(String searchName) {
}
// returns the entire directory as a String
public String toString() {
}
}
Wow. Did you get that or did you implement that yourself? If you implemented that yourself, I'd suggest some major changes.
i was given that to work off. coudl you be of any help to point me in the right direction. ive been looking at the java api but no luck, do u have any other websites you could advise?
You need these two:
Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)
Strings (The Java™ Tutorials > Learning the Java Language > Numbers and Strings)
Start off with the last two mehods, as you'll need them for the other methods.
I'm out for today, will check tomorrow.
Phil
Cheers Phil.. much appreciated
It seems to me that this has nothing to do with looking stuff up in the API and all to do with the most basic array handling code. Do you understand arrays fully? If not, what are you having trouble with?
public void addEntry(java.lang.String name,
java.lang.String s)
throws java.io.IOException
Throws:
java.io.IOException
WTF!!? :confused:
hey guys ive made an attempt on this part could anyone tell me if im going in the right direction??
Code:import java.io.IOException;
public class Directory {
private static final int NO_ENTRIES = 100;
Entry[] theDirectory = new Entry[NO_ENTRIES];
// add an entry to theDirectory
// if theDirectory is full do not add the entry
public void addEntry(Directory entry) {
Directory newSection;
if (entry < NO_ENTRIES)
Entry.addEntry(entry);
return;
}
Shouldn't you store something in your array theDirectory and you should increment a counter variable if you add something to your array. It would be quite convenient if the method returned something that indicates whether or not an entry was added to the array. Oh, and you don't use that local variable newSection at all so why define it? btw, by convention all variables start with a lower case letter. Is addEntry( ... ) a static method or not? IMHO your code snippet is a mess.
kind regards,
Jos
JosAH thanks for the speedy reply, im new to java and in many cases all is a new field to myself. any hints on how i could make it easier for myself would be appreciated?? any good websites that i could posibly learn from? ive been doin java for the past 2 months
The List™:
Sun's basic Java tutorial
Sun's New To Java Center
Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
jGuru
A general Java resource site. Includes FAQs, forums, courses, more.
JavaRanch
To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
Yawmarks List
The Java Developers Almanac
Java Examples from The Java Developers Almanac 1.4
Bruce Eckel's Thinking in Java(Available online.)
Joshua Bloch's Effective Java
Bert Bates and Kathy Sierra's Head First Java
James Gosling's The Java Programming Language
Gosling is the creator of Java. It doesn't get much more authoritative than this.
Joshua Bloch and Neal Gafter Java Puzzlers.
thank you PhHein =) quite a few good links you have gave me