**Program Action**
1. Your program will take 3 arguments at the command line.
Syntax: program e|d filein fileout
Arg 1. A single letter. Either a 'd' or an 'e'.
Arg 2. The name of a file to be read in.
Arg 3. The name of a file to be written to.
2. If the letter is a 'e' your program will read in filein and write out its content encoded in
morse code format to fileout
3. If the letter is a 'd' your program will read in filein and decode the morse code it reads to
english letters and write the result out to fileout.
For example, assuming your program was compiled to
morse, the following would
demonstrate its use.
sally% cat [login to view URL]
sos
the quick brown fox
sally% morse e [login to view URL] [login to view URL]
sally% cat [login to view URL]
*** --- ***
- **** * --*- **- ** -*-* -*- -*** *-* --- *-- -* **-* --- -**-
sally% morse d [login to view URL] [login to view URL]
sally% cat [login to view URL]
sos
the quick brown fox
## Deliverables
You will also find the code implementations for
bintree.h and binnode.h. You will need
these files as well.
**Program Action**
1. Your program will take 3 arguments at the command line.
Syntax: program e|d filein fileout
Arg 1. A single letter. Either a 'd' or an 'e'.
Arg 2. The name of a file to be read in.
Arg 3. The name of a file to be written to.
2. If the letter is a 'e' your program will read in filein and write out its content encoded in
morse code format to fileout
3. If the letter is a 'd' your program will read in filein and decode the morse code it reads to
english letters and write the result out to fileout.
For example, assuming your program was compiled to
morse, the following would
demonstrate its use.
sally% cat [login to view URL]
sosa
the quick brown fox
sally% morse e [login to view URL] [login to view URL]
sally% cat [login to view URL]
*** --- ***
- **** * --*- **- ** -*-* -*- -*** *-* --- *-- -* **-* --- -**-
sally% morse d [login to view URL] [login to view URL]
sally% cat [login to view URL]
sos
the quick brown fox
*31251 Assignment 3 ??" Autumn 2008 Page*
*2 of 6*
**Details**
The first thing your program must do is load in the file
[login to view URL] and create two
separate data structures.
1. An STL vector containing the english letters and associated morse codes in english letter
order. You will use this vector when encoding the english to morse. You will use the find
function from the
<algorithm> library to find the code associated with a particular letter
in the vector.
2. A bintree (using the code supplied) containing the english letters and associated morse code
in morse code order. You can consider the morse code as a string which can be ordered using
the overloaded relation operators. Make sure you rebalance the tree after storing the codes in
it. You will use the tree to find the english letter associated with a particular morse code.
While there are other data structures that would work, you must implement these data
structures to store the letters and their codes. Do not use any other data structure to store the
text .
To simplify matters, you can assume that all files used to test your program will only contain
lower case english letters or valid morse codes, spaces and new lines. The files will only
contain letters or code but not both. However, your program will have to correctly handle
spaces and new lines in the files.
You will need to create a couple of
structs to contain the lettercode and codeletter and
place these in the data structures. While you would normally put this in separate files you will
contain all your code in the one
.cpp file to be submitted. Do not make any modifications to
the
bintree.h and binnode.h files.
Restrictions:
Use spaces instead of tabs for program indentation
The program must use multiple functions
No function can be greater than 60 lines
No line can be greater then 80 characters
*PLEASE NOTE*
. It is a fundamental requirement of this assignment that you use the STL
vector and bintree data structure to store the lettercode combinations, as outlined in the
details section. Furthermore, the conversion must be done as you read and write to the files.
Do not copy parts of the file to an array for the coding.