Results 1 to 16 of 16
  1. #1
    Chewart is offline Member
    Join Date
    Nov 2009
    Posts
    75
    Rep Power
    0

    Exclamation AddEntry in Java..

    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.

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Ahem? What? I'm totally lost on what you are trying to do and what your question is, some context would be helpful.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    Chewart is offline Member
    Join Date
    Nov 2009
    Posts
    75
    Rep Power
    0

    Default

    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

    Java 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() {
    
    	}
    
    }

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Wow. Did you get that or did you implement that yourself? If you implemented that yourself, I'd suggest some major changes.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  5. #5
    Chewart is offline Member
    Join Date
    Nov 2009
    Posts
    75
    Rep Power
    0

    Default

    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?

  6. #6
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    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
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  7. #7
    Chewart is offline Member
    Join Date
    Nov 2009
    Posts
    75
    Rep Power
    0

    Default

    Cheers Phil.. much appreciated

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    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?

  9. #9
    Elshan0011 is offline Member
    Join Date
    Nov 2009
    Location
    India
    Posts
    3
    Rep Power
    0

    Default

    public void addEntry(java.lang.String name,
    java.lang.String s)
    throws java.io.IOException
    Throws:
    java.io.IOException

  10. #10
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    WTF!!? :confused:
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  11. #11
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,022
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by PhHein View Post
    WTF!!? :confused:
    I'm with Phil here: what is this darn thread all about?

    kind regards,

    Jos

  12. #12
    Chewart is offline Member
    Join Date
    Nov 2009
    Posts
    75
    Rep Power
    0

    Default

    hey guys ive made an attempt on this part could anyone tell me if im going in the right direction??

    Java 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;
    	
    	}

  13. #13
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,022
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Chewart View Post
    hey guys ive made an attempt on this part could anyone tell me if im going in the right direction??

    Java 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
    Last edited by JosAH; 12-17-2009 at 02:58 PM.

  14. #14
    Chewart is offline Member
    Join Date
    Nov 2009
    Posts
    75
    Rep Power
    0

    Default

    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

  15. #15
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    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.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  16. #16
    Chewart is offline Member
    Join Date
    Nov 2009
    Posts
    75
    Rep Power
    0

    Default

    thank you PhHein =) quite a few good links you have gave me

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •