I am currently writing a program (lui) that will compress and decompress files with hufman encoding (first encoding exercise) NOTE:the files i will be compressing and decompressing are .txt files as i only got started.
the problem i have now is designing the class hierarchy as i'm not sure i use the "has a" and "is a" relationships correctly for now my thoughts are:
-----------
|relations|
-----------
A compressor is an option
A decompressor is an option
A compressor has a node
A compressor has a scanner
A compressor has a file_controller
A decompressor has a node
A decompressor has a scanner
A decompressor has a file_controller
class option {
//prints a menu with 4 options
//1)compress
//2)decompress
//3)show file info (use file_controller class only)
//4)quit
}
class compressor : public option {
private:
//an object of class node
//an object of class scanner
//an object of class file_controller
public:
//functions
}
class decompressor : public option {
private:
//an object of class node
//an object of class scanner
//an object of class file_controller
public:
//functions
}
class node {
//to create a hufman tree
}
class scanner {
//to scan the file and store data like sizes
//and what characters appear at which frequency
}
class file_controller {
//controls all file operations
}
it was a bug i guess because the browser showed me an error that it didn't post it at first and now as you said it got duplicated so i'l close the second one
It's always a good idea to separate computation from presentation. In other words, the human interface components of the program should be separate from the part that does the actual work. With this in mind, the class compressor and decompressor should not be derived from class option. If fact they should be completely unaware of the class option.
Class file_controller should probably be class stream_controller instead. In other words, it should operate on a stream, or perhaps two streams: input and output.