Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

For this assignment, you will simulate a file system. You will be neither creating files nor reading or writing disk files. Rather, you will have a simulation of a file system that resides entirely in memory in your computer.

Each file system has a top level or "root" directory. At this level, there may be an unlimited number of files. In addition to files, this top level directory may also have an unlimited number of subdirectories. These subdirectories may also have an unlimited number of files and/or subdirectories. Thus, just like on a real file system, you may have an unlimited number of files and/or directories in each directory. Since directories may contain other directories, you may have directories nested an unlimited number of levels deep.

You are required to write two files: FileSystem.java, and FileException.java. For FileException.java you will extend the class Exception in java.lang (no import needed). Your FileSystem.java source code file must include the following methods:

public class FileSystem {

                private static final String DEFAULT_NAME = "root";

                /**

                 * Constructor, creates a FileSystem instance,

                 * with the root directory given the name

                 * of the single parameter.

                 *

                 * @paramrootDirectory

                 */

                publicFileSystem(String rootDirectory) {

                }

 

                /**

                 * constructor, creates a FileSystem instance,

                 * with the root directory given the default

                 * name DEFAULT_NAME.

                 */

                publicFileSystem() {

                }

                /**

                 * creates a new subdirectory in the current directory with the directory

                 * name given as a parameter. Throws a FileException if a subdirectory

                 * with the same name or a file with the same name already exists in the

                 * current directory.

                 *

                 * @paramdirName

                 * @throws FileException

                 */

                public void makeDirectory(String dirName)

                throwsFileException {

                }

                /**

                 * Changes the current working directory to the directory specified in

                 * thenewDir string. Changes at only one level at a time (up or down)

                 * are supported. If the user specifies the string .., then the current

                 * working directory moves upward one level. If any other string parameter

                 * is given, then the current working directory moves down one level

                 * to the directory specified. If the directory indicated does not

                 * exist, then a FileException is thrown.

                 *

                 * @paramnewDir

                 * @throws FileException

                 */

                public void changeDirectory(String newDir)

                throwsFileException {

                }

                /**

                 * Creates a new file in the current working subdirectory.

                 * If a file or directory already exists with that name,

                 * then a FileException is thrown.

                 *

                 * @paramfName

                 * @param contents

                 * @throws FileException

                 */

                public void createFile(String fName, String contents)

                throwsFileException {

                }

                /**

                 * Returns true if there exists a directory with the

                 * given name in the current working subdirectory.

                 * Otherwise returns false.

                 *

                 * @paramdirName

                 * @return

                 */

                publicbooleandirectoryExists(String dirName) {

                }

                /**

                 * Returns true if there exists a file with the given

                 * name in the current working subdirectory.

                 * Otherwise returns false.

                 *

                 * @paramfName

                 * @return

                 */

                publicbooleanfileExists(String fName) {

                }

                /**

                 * Removes the directory with the given name from the

                 * current working subdirectory, if it exists, and is

                 * empty. Throws a FileException otherwise.

                 *

                 * @paramdirName

                 * @throws FileException

                 */

                public void deleteDirectory(String dirName)

                throwsFileException {

                }

                /**

                 * Deletes the file with the given name from the current

                 * working subdirectory, if it exists, otherwise throws

                 * aFileException.

                 *

                 * @paramfName

                 * @throws FileException

                 */

                public void deleteFile(String fName)

                throwsFileException {

                }

                /**

                 * Prints the directory and file names in the current working

                 * subdirectory. All directories should be printed before

                 * files. Within each group (directories and files)

                 * entries must be in sorted order (dictionary order)

                 */

                public void printDirectoryContents() {

                }

                /**

                 * Prints the entire contents of the file system tree.

                 * For each subdirectory starting with the root or top level

                 * directory, all directories and files are printed. Levels of

                 * nesting should indicated by inserting spaces before the

                 * nested directory or filename. Use 5 blank spaces for each

                 * level of nesting. Entries in a subdirectory must immediately

                 * follow that directory name in the listing.

                 */

                public void printAll() {

                }

 

 

                /**

                 * Returns the content of a file stored in the current

                 * working subdirectory identified by the parameter fName.

                 * Throws a FileException if the file is not found, or it is

                 * a directory instead of a file.

                 *

                 * @paramfName

                 * @return

                 * @throws FileException

                 */

                public String getContents(String fName)

                throwsFileException {

                }

                /**

                 * Returns the String representation of the current working directory.

                 *

                 * @return

                 */

                public String getCurrentDirectory() {

                }

 

 

                /**

                 * Returns the current number of subdirectories and files in the file

                 * system. A FileSystem with only a root directory has size == 0

                * (provided that the root directory is empty).

                 *

                 * @return

                 */

                publicint size() {

                }

The source code has been placed in your CVS accounts.

Additional Details and Requirements

The constructor will create an empty file system with a top level directory, either a name provided or DEFAULT_NAME.

File and directory names consist of a single String object. Any valid string is a valid filename except for the String ".." which indicates the parent subdirectory.

Each new entry in the file system has the following information. 1) name of directory or file, 2) text contents if the entry is a file. Text contents is a single string representing the file contents.

Each subdirectory may contain additional subdirectories and files, with no limit on the number of entries.

Within each directory, all contents should be kept in alphabetical order. All subdirectories must appear first (in dictionary order) followed by all files (in dictionary order).

When printing directories, the directory name should always be followed by a "/".

The printAll() method must be recursive.

You may use any classes that you wrote for program #1.

You may import only java.io.*, data_structures.*, java.util.Iterator, java.util.NoSuchElementException, and java.util.StringTokenizer.

Your project must include the FileSystem class and the FileException class, named appropriately. Additionally, you must implement all of the methods specified in the FileSystem class, and the name and signature of each method must match the specifications.

You may include as many additional classes as you need. Any data structures or ADT's you use must be in a package named data_structures. You must write any data structures or ADT's you need yourself, and they should handle Objects of any type, not just directories and files.

Much of the work in this assignment involves developing a good design. Give careful thought to the organization of directory/file information. The overall quality of your design will be worth approximately 30% of your grade for the assignment.

You will submit a report (maximum 5 pages) along with your source code that describes your design.

None of your public methods may return pointers to private internal objects. In particular, if you use a linked list data structure, you must not return a Node in any public method. Proper use of information hiding and encapsulation are expected.

Be careful about storing extraneous information along with files and directories. Useless replication of data is inappropriate, and will lower your overall grade.

Your project will be graded with a driver program not available to you. The driver program will instantiate instances of the class FileSystem only. Drivers must not reference any other classes in your project.

Java, Programming

  • Category:- Java
  • Reference No.:- M9524931

Have any Question?


Related Questions in Java

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As