Reference no: EM132407406
OBJECTIVE
The objective of this assignment is to apply your newly learned Erlang knowledge to build a program from scratch.
ASSIGNMENT DESCRIPTION
For this assignment you will rewrite the programming assignment you have done in C. All high-level program logic remains the same. Since, however, now you are modelling this logic in Erlang, the following requirements must be met:
• Each directory entry / file in the program is to be modeled by a tuple that consists of a filename and its size in bytes that will be entered by the user, and the number for the beginning block and the number of blocks used by the file that will be generated by the program
• The directory table should be modeled by a list
• Each block in the program is to be modeled by a tuple that consists of a block number, how much of this block is used and the amount of internal fragmentation
• The block table should be modeled by a list
I/O: Since we haven't discussed interactive input, examine the small sample functions below for interactive input handling.
integer input handling:
input() ->
S = io:get_line("Enter: "),
{Int,_} = string:to_integer(S), io:fwrite("echo ~i ~n", [Int]), case Int of
1 -> input();
2 -> input();
3 -> input();
4 -> done
end.
string input handling:
input() ->
S = io:get_line("prompt: "),
{Strip,_} = lists:split(length(S)-1, S), io:fwrite("echo ~s ~n", [Strip]), case string:equal(Strip, "quit") of
true -> done;
_ -> input()
end.
PROGRAM SPECS
Your program is to include the following functions (follow the naming conventions if you want your program to be graded):
• mymain() this function is similar in its logic to how main functions in C and Java, i.e. starts and drives the program; the user will call this function from the shell in order to start the program
• printMenu() prints the menu choices to the shell
• blocksAsString( ListOfBlockTuples) given a list of tuples representing the blocks returns that list as a string
• directoryAsString(ListOfFileTuples) given a list of tuples representing the files returns that list as a string
• other functions you deem appropriate to achieve proper modularization
In addition, your program must fulfill the following requirements:
• Only lists and tuples are to be used, no other data structures allowed
• Your driver file should be called pr2.erl
• Helper functions should NOT be listed in an export statement
• Include comments - the header with your name, program name, date; function headers that describe the purpose of each function; code comments that describe the high-level logic
• Your program is to be contained within one file called pr2.erl ; If you decide to use a multiple file structure, you can call your other files according to your preference but function mymain must reside in pr2.erl
• Your program has to follow basic stylistic guidelines, such as proper indentation (it is better to use whitespaces to ensure that's the case), meaningful variable names, etc.
• You are to save your shell with sample calls to your functions to a file called pr2_tests.erl
EXECUTIVE SUMMARY
You are to write an executive summary. It should be written as a txt file. In the file, describe what you have done to complete the assignment in about 500 words and compare your C and Erlang approaches to this program. How has programming paradigm affected your work/choices? Which one do you prefer and why? The word count is not strict, so do not worry about going slightly over; however, summaries that are < 400 words or are trivial in nature (representing little thought or effort) will not get full credit.