Assignment 4
Due Date : 2/20 @ 11:59pm
Instructions
Each of you should have a repository in CCIS’s GitHub with the name
assignment4-ccisLogin
. Use this repository
and add all your work there. In order to clone the repositories
from CCIS GitHub to your machine (or watch this video video instructions):
-
Sign in to GitHub.
-
On your CCIS GitHub home page your Github Handle should appear on the left as a button/drop down menu. Click that button and from the drop down menu select
cs8674sp15-seattle
. The CCIS GitHub page will then navigate to the class' web page and to the contents that is available to you. -
On the right you should be able to see all repositories to which you have been given access. Find the repository whose name matches the pattern
assignment4-ccisLogin
, where ccisLogin is your CCIS login name, e.g,assignment4-john123
, and click on it. -
On the repositories home page look at the bottom right hand corner for a button with the text Clone in Desktop. By clicking on this button your browser will launch the GitHub client that we installed in Lab1 and ask for a location on your drive to store the repository.
If you are not using the GitHub client the clone URL is located above the Clone in Desktop button. Copy the URL and issue the following command on your shell
git clone URL
. - Create a file and save it under the folder on your drive that you selected in the preceding step.
Remember to push your changes to the CCIS GitHub repository often.
Grading Criteria
- For any Java class that you create you are expected to provide valid Javadoc documentation. This means that running Javadoc on your your source code should successfully compile and generate documentation in HTML with no errors or warning. Errors and/or warnings during Javadoc generation will cost you points.
- For all methods that you implement as part of this assignment you are expected to provide
pre
andpost
conditions. Place your pre and post conditions in your Javadoc and use the same format we used in class. - For any Java class that contains methods you are expected to provide tests using JUnit. Failing unit tests will cost you points
Problem 1
All Java source code that is part of your solution to this problem must reside inside a java package with the name
edu.neu.ccs.cs8674.sp15.seattle.assignment4.problem1
We are going to extend/add more operations to our implementation of binary trees (BT) from our previous assignment.
-
add the operation
deleteNode
to BT; the operation takes in aNode
,n
, and ifn
is in the BT then removen
from the BT and return the new BT, else ifn
is not in the BT return the BT unchanged. The BT returned must be a valid BT, i.e., no dead nodes. CallingdeleteNode
on an empty BT should signal an error. -
add the operation
mirror
to BT; the operation returns a mirror image of the current BT. Here is an example
Problem 2
All Java source code that is part of your solution to this problem must reside inside a java package with the name
edu.neu.ccs.cs8674.sp15.seattle.assignment4.problem2
You have been tasked to implement the filesystem for a small embeded device called Duke. The company that is creating the device has given you the following list of requirements
File System for Duke
The filesystem is made up of folders and files. The device will be delivered with an initial filesystem that will contain one folder, the root folder. The filesystem should allow the creation of files and folders. All files and folders created will be under the root folder.
Files
A file must have the following properties
- A filename; this is typically a string that the user will type in and will represent the name of the file.
- A file size; this is the number of bytes occupied by this file on the filesystem.
-
A file name extension; this is given as a string but it can be one of the following values
-
txt
to denote a file that contains plain text -
cfg
to denote a file that contains configuration information written in our proprietary format -
res
to denote a file that contains resources, e.g. images -
bin
to denote a file that contains an executable
-
- A creation date; this is the date the file was created. The date format is discussed later in this document.
- A last updated date; this is the date the file was last modified. The date format is discussed later in this document.
There are certain restrictions when it comes to files
- A file's size cannot exceed 100MB, where 1024 bytes = 1KB, and 1024KB = 1MB
- A file's name cannot be longer than 128 characters
- A file is always part of (or inside) a folder
For our initial testing phase the QA and the hardware engineers asked that at a minimum the following operations are available and working
- Create the empty root folder
- Create a file under a folder
- Create a folder under another folder
- Create any number of nested folders
- A save operation on files that can alter the size of the file as well as its last modified date
Folders
By default the filesystem comes with a folder called the root folder. All files and sub-folder can be accessed by starting at the root folder and navigating down to files and/or folders. Here is the initial list of properties for folders
- A folder name; this is typically a string value that the user provides. The root folder must have the name "/".
- A folder size; the size of the folder is the sum of all its files and sizes of sub-folders (see below for more on sub-folders)
- A creation date; this is the date the folder was created. The date format is discussed later in this document.
- A last updated date; this is the date the folder was last modified. A folder is modified if a file that is within this folder (and not in a sub-folder) is modified. If a sub-folder is modified the parent folder's last modified date does not change. The date format is discussed later in this document.
There are certain restrictions when it comes to folders and their properties
- A folder's name cannot exceed 128 characters
- A folder's size cannot exceed 2GB, where 1024MB = 2GB
-
The names of files and sub-folders must be different.
Capitalization is not taken into account so a file with the name
README
is considered to have the same name asReadme
,READme
etc.
Dates
A Date from the point of you of our system consists of
- The year as a 4-digit number
- The months as a 2-digit number within the range 1-12
- The day as a 2-digit number within the range 1-31
- The hours as a 2-digit number within the range 1-24
- The minutes as a 2-digit number within the range 0-59
All ranges are inclusive, i.e., 1-12 allows for numbers 1,2,3,4,5,6,7,8,9,10,11 and 12.
To help us test and debug we also need the ability to print out a filesytem. For now we can display that on the console. The print out of a filesystem should show the following information for each filesystem element
- File
- File name
- File extension
- File size in bytes
- Creation date
- Last modified date.
-
Folder
- Folder name
- Folder size
- Creation date
- Last modified date
Here are a few more requirements on how the print out should be displayed.
- Sub folder should be indented 2 spaces to the right.
- Folder names should be postfixed with the character "/".
- File names should be postfixed with the character "." followed by the three letter acronym of their extension.
- The size of folders and files must be displayed in the appropriate units if the size is greater or equal to 1 unit value, e.g., if a file or folder has size 1024 bytes that should be displayed as 1Kb, if a file or folder has size less than 1024 (i.e., 1020) display 1020 bytes. Print "bytes" for byte units "Kb" for kilobytes, "Mb" for megabytes and "Gb" for gigabytes.
Here are is one possible way of printing out the filesystem.
2014.01.02 (10:10) 2015.02.12 (23:12) 2.6 Mb / 2014.01.02 (10:10) 2015.02.12 (23:12) 50 Kb README.txt 2014.01.02 (10:10) 2015.01.12 (23:12) 1.6 Mb resources/ 2014.01.02 (10:10) 2015.01.12 (23:12) 450 Kb logo.res 2014.01.02 (10:10) 2015.01.01 (23:12) 200 Kb error.res 2014.01.02 (10:10) 2015.01.20 (23:12) 300 Kb popup.res 2014.01.02 (10:10) 2015.01.20 (23:12) 720 Kb documentation.res 2014.01.02 (10:10) 2015.02.12 (23:12) 1000 Kb bin/ 2014.01.02 (10:10) 2015.02.12 (23:12) 400 Kb install.bin 2014.01.02 (10:10) 2015.02.12 (23:12) 250 Kb uninstall.bin 2014.01.02 (10:10) 2015.02.12 (23:12) 350 Kb update.bin 2014.01.02 (10:10) 2014.11.18 (23:12) 1.3 Kb cfg/ 2014.01.02 (10:10) 2014.11.18 (23:12) 440 bytes endpoints.cfg 2014.01.02 (10:10) 2014.02.12 (23:12) 220 bytes layout.cfg 2014.01.02 (10:10) 2014.02.20 (23:12) 520 bytes logging.cfg 2014.01.02 (10:10) 2014.02.25 (23:12) 120 bytes updates.cfg
The filesystem should also support an operation that will print out the disk usage of the filesystem. For this operation the output should be the full path of the file/folder starting from the root folder as a string followed by the size occupied by that file/folder. Printing out the size should follow the same rules as described above concerning filesystem size units.
We should be able to call disk usage on the filesystem and optionally provide a sorting criterion. The possible sorting criteria are
- by name, lexicographical order on the names of files and folders.
- by size, smallest in size element first, largest in size element last.
Here are some possible ways of printing out the disk usage of a filesystem.
## disk usage with no sorting criterion 2.6 Mb / 50 Kb /README.txt 1.6 Mb /resources/ 450 Kb /resources/logo.res 200 Kb /resources/error.res 300 Kb /resources/popup.res 720 Kb /resources/documentation.res 1000 Kb /bin/ 400 Kb /bin/install.bin 250 Kb /bin/uninstall.bin 350 Kb /bin/update.bin 1.3 Kb /cfg/ 440 bytes /cfg/endpoints.cfg 220 bytes /cfg/layout.cfg 520 bytes /cfg/logging.cfg 120 bytes /cfg/updates.cfg
## disk usage sorted lexicographically (ignore case) 2.6 Mb / 1000 Kb /bin/ 400 Kb /bin/install.bin 250 Kb /bin/uninstall.bin 350 Kb /bin/update.bin 1.3 Kb /cfg/ 440 bytes /cfg/endpoints.cfg 220 bytes /cfg/layout.cfg 520 bytes /cfg/logging.cfg 120 bytes /cfg/updates.cfg 50 Kb /README.txt 1.6 Mb /resources/ 720 Kb /resources/documentation.res 200 Kb /resources/error.res 450 Kb /resources/logo.res 300 Kb /resources/popup.res
## disk usage sorted by size (smallest to largest) 120 bytes /cfg/updates.cfg 220 bytes /cfg/layout.cfg 440 bytes /cfg/endpoints.cfg 520 bytes /cfg/logging.cfg 50 Kb /README.txt 200 Kb /resources/error.res 250 Kb /bin/uninstall.bin 300 Kb /resources/popup.res 350 Kb /bin/update.bin 400 Kb /bin/install.bin 450 Kb /resources/logo.res 720 Kb /resources/documentation.res 1000 Kb /bin/ 1.3 Kb /cfg/ 1.6 Mb /resources/ 2.6 Mb /