Master Computers and Technology with Fun Quizzes & Brain Teasers!
Build a class and a driver for use in searching your computers secondary storage (hard disk or flash memory) for a specific file from a set of files indicated by a starting path. Lets start by looking at a directory listing. Note that every element is either a file or a directory.Introduction and DriverIn this assignment, your job is to write a class that searches through a file hierarchy (a tree) for a specified file. Your FindFile class will search a directory (and all subdirectories) for a target file name.For example, in the file hierarchy pictured above, the file "lesson.css" will be found once in a directory near the root or top-level drive name (e.g. "C:\") . Your FindFile class will start at the path indicated and will search each directory and subdirectory looking for a file match. Consider the following code that could help you build your Driver.java:String targetFile = "lesson.css";String pathToSearch ="C:\\WCWC"; FindFile finder = new FindFile(MAX_NUMBER_OF_FILES_TO_FIND);Finder.directorySearch(targetFile, pathToSearch);File SearchingIn general, searching can take multiple forms depending on the structure and order of the set to search. If we can make promises about the data (this data is sorted, or deltas vary by no more than 10, etc.), then we can leverage those constraints to perform a more efficient search. Files in a file system are exposed to clients of the operating system and can be organized by filename, file creation date, size, and a number of other properties. Well just be interested in the file names here, and well want perform a brute force (i.e., sequential) search of these files looking for a specific file. The way in which well get file information from the operating system will involve no ordering; as a result, a linear search is the best we can do. Wed like to search for a target file given a specified path and return the location of the file, if found. You should sketch out this logic linearly before attempting to tackle it recursively.FindFile Class InterfaceFindFile(int maxFiles): This constructor accepts the maximum number of files to find.void directorySearch(String target, String dirName): The parameters are the target file name to look for and the directory to start in.int getCount(): This accessor returns the number of matching files foundString[] getFiles(): This getter returns the array of file locations, up to maxFiles in size.RequirementsYour program should be recursive.You should build and submit at least two files: FindFile.java and Driver.java.Throw an exception (IllegalArgumentException) if the path passed in as the starting directory is not a valid directory.Throw an exception if you've found the MAX_NUMBER_OF_FILES_TO_FIND and catch and handle this in your main driver. Your program shouldn't crash but rather exit gracefully in the unusual situation that we've discovered the maximum number of files we were interested in, reporting each of the paths where the target files were found.The only structures you can use in this assignment are basic arrays and your Stack, Queue, or ArrayList from the previous homeworks. Do not use built-in data structures like Java's ArrayList. To accomplish this, put in the following constructor and method to your ArrayList, Stack, or Queue:public ArrayList(Object[] input) { data = input; numElements = input.length;}public Object get(int index) { return data[index];}
Visual Basic Help:Code a program that reads a test score (number) from a text-box, each time a button is clicked. In other words, every time a new score is entered in the text-box, the score should be taken by the program, stored and the text-box should be cleared, so that the user can enter a new score. The program should be able to check that the user is entering a number. If the user enters something different than a number (or leaves the text-box empty), the program should not continue and it should display a warning message to the user. After entering as many scores as wanted, the user should be able to click on a second button to display the two highest scores, among all the ones entered until that point. The program should also display the total number of scores entered by the user. Also, once the user clicks on the button to display the results and the results are displayed, the program should get ready to get a new set of scores and start again. If the user starts writing a new score, the text-boxes with the results should be cleared.Example: Assume the user enters the following scores: 10, 5, 20. The scores are entered once at the time in the top text-box; when a score is entered, the user presses the button to "Read" the score. The score is taken by the program and the text-box is cleared, so that the next score can be entered. This process can be repeated as many times as the user wants and for as many scores as the user wants. Once all the scores are entered and read(or taken-in)by the program, the user clicks on the second button to display the results. The program should then display the two highest scores, among the ones entered. So, in the example, this would be 10, 20. And it should display the total number of scores entered by the user. In the example, it would be 3.After that, the user should be able to repeat the process and enter a new set of scores, if wanted. The program should therefore be ready to take in new inputs and start the process again. When the user starts typing the new score, the text-boxes with the previous results (two highest scores and total num. of scores) should get cleared