Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-08-2012, 09:09 PM   PM User | #1
searcher
New to the CF scene

 
Join Date: Jan 2012
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
searcher is an unknown quantity at this point
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.
searcher is offline   Reply With Quote
Old 01-08-2012, 09:11 PM   PM User | #2
nomanic
Regular Coder

 
nomanic's Avatar
 
Join Date: Feb 2009
Location: United Kingdom
Posts: 252
Thanks: 9
Thanked 33 Times in 33 Posts
nomanic is an unknown quantity at this point
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/
nomanic is offline   Reply With Quote
Users who have thanked nomanic for this post:
searcher (01-08-2012)
Old 01-08-2012, 09:23 PM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,168
Thanks: 59
Thanked 3,992 Times in 3,961 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Old 01-08-2012, 09:24 PM   PM User | #4
searcher
New to the CF scene

 
Join Date: Jan 2012
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
searcher is an unknown quantity at this point
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
searcher is offline   Reply With Quote
Old 01-08-2012, 09:27 PM   PM User | #5
searcher
New to the CF scene

 
Join Date: Jan 2012
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
searcher is an unknown quantity at this point
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.
searcher is offline   Reply With Quote
Old 01-09-2012, 05:07 AM   PM User | #6
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,168
Thanks: 59
Thanked 3,992 Times in 3,961 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Tags
code needed

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:39 AM.


Advertisement
Log in to turn off these ads.