Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Java searcher program CHALLANGE

    JAVA not JavaScript
    create an application, searcher that takes two command line arguments: the starting directory and the target to find.

    Searcher makes use of a recursive algorithm with the method signature: public static void scan (String path). This recursive algorithm needs to scan through directories and over file names in order to locate the specified file from the command line. You will, in all likelihood, need to make your FileIOHelper class described below. once you located your file you can stop executing and display the output of where the file was located.

    Create a class called FileIOHelper. This has two private String arrays, directories and files. It also includes two public instance int variables dirLength and fileLength witch stores length of directories and files String arrays respectively.

    it has one constructor that takes a file object, witch is used to determine the directory where you are going to be getting the information from. the constructor needs to iterate through each array element provided and assign the String to the right array(it's either a dir or file). Your arrays need to resize properly as you iterate through them.

    The fileIOHelper has two public methods, getDirectories() and getFiles() both return their respective protected String arrays.

    The FileIOHelper also has 2 private methods addToFile() and addToDirectory() witch both take a String and return a String array

    extra
    1)keeping track of witch stack your working on currently - loggin information to a file through a static logger class.
    2)using assertions where posible.

  • #2
    Regular Coder nomanic's Avatar
    Join Date
    Feb 2009
    Location
    United Kingdom
    Posts
    255
    Thanks
    9
    Thanked 33 Times in 33 Posts
    if s you say its JAVA not javascript, then you have posted in the wrong forum
    There is another one for JAVA
    <DmncAtrny> I will write on a huge cement block "BY ACCEPTING THIS BRICK THROUGH YOUR WINDOW, YOU ACCEPT IT AS IS AND AGREE TO MY DISCLAIMER OF ALL WARRANTIES, EXPRESS OR IMPLIED, AS WELL AS DISCLAIMERS OF ALL LIABILITY, DIRECT, INDIRECT, CONSEQUENTIAL OR INCIDENTAL, THAT MAY ARISE FROM THE INSTALLATION OF THIS BRICK INTO YOUR BUILDING."
    <DmncAtrny> And then hurl it through the window of a Sony officer
    <DmncAtrny> and run like hell

    Portfolio, Tutorials - http://www.nomanic.biz/

  • Users who have thanked nomanic for this post:

    searcher (01-08-2012)

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,602
    Thanks
    78
    Thanked 4,387 Times in 4,352 Posts
    But in any case, read rule 1.5 here: http://www.codingforums.com/rules.htm

    You aren't supposed to post homework problems. We aren't supposed to answer them.

    *IF* you do maybe 90% of the work and get stuck on *ONE OR TWO* aspects of it, then most people hill will give you a hand. But we aren't supposed to--and most of us won't--do your entire homework for you.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    then shud i remove it and how only option i see is to edit it but it wont be revoved just a blank thread which is not cool

  • #5
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Cool

    it's not a homework project im not at school anymore its a challenge to ppl who seem up to it i came across it and thought it was fun so y not share it.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,602
    Thanks
    78
    Thanked 4,387 Times in 4,352 Posts
    I hope you won't take this wrong, but that's really only a "challenge" to a real Java novice. Somebody doing maybe a first class in Java.

    Also, the directions make the task considerably more complicated than it needs to be.

    The Java class java.io.File will automatically provide you with an array of all files and directories in a given directory and there is no reason to further separate them into one array of files and one of directories. There is also no reason for the four methods called for. Two methods (one static main method and one non-static recursive scan method) are all that are needed. Why would anybody complicate it beyond that?

    Your whole "challenge" here can be written in a dozen or so lines of Java code, though admittedly it will be maybe 30 to 40 lines if you write it the silly way it is specified.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Tags for this Thread

    Posting Permissions

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