Where do I start with my recursion homework?

So, I have to do this assignment: https://faculty.utrgv.edu/robert.schweller/CS2380/homework/hw10.pdf
However, I don't really know where to start. The functions I think I would need would be a fill, load and save function. After that I really don't know what to do. What else am I missing? Any help would be appreciated.
The best way to start the recursion assignment is to first start the recursion assignment. The way you do that, is by starting the recursion assignment. For further detail, review this message.
You should really have continued your previous thread, where @tpb made a decent suggestion of a vector<string> (one string for each row: an array of characters).
http://www.cplusplus.com/forum/general/233995/#msg1051010

I would suggest in this order:
(1) int main() - to call the other functions

(2) a LOAD function (as per @tpb's suggestion; there is no need for same-length strings, although you could use resize to extend to the longest length if you wanted that)
vector<string> LOAD( string inFileName );

(3) a DRAW function - so you can check your current status.
void DRAW( const vector<string> &drawing );

(4) a SAVE function (the opposite of load).
void SAVE( const vector<string> &drawing, string outFileName );

(5) a FILL function (you could always do a loop version before you changed to recursion).
void FILL( vector<string> &plot, ... various other argments ... );

Don't proceed from one to the next until you have compileable code. i.e DON'T TRY TO WRITE THE WHOLE THING IN ONE GO.
Once you have a DRAW function available, debugging should become easier.

The only difficult one is (5). Don't start that until the rest is working.
Last edited on
Agreed, there are near independent subtasks. When you cut a monster into tiny peaces, it does not look so scary any more.


Note:
(4) a SAVE function (the opposite of load).
SAVE( const vector<string> &drawing, string outFileName );

This is good, but there is a variant with a perk:
SAVE( const vector<string> &drawing, std::ostream & out );

There is "one function, one task" philosophy. The first version (1) opens a stream to a file and (2) writes data to the stream. The second version writes data to the stream.

The second version can be called either with a file stream or with cout.
Yes, agreed; I missed that. (3) and (4) in my list fundamentally do the same thing with different output streams. Go with @Keskiverto's more flexible version. Maybe just name it OUTPUT.

See if you can produce some modular code @joshgarza, and we can then look to help you ... but it is your assignment.
Last edited on
Topic archived. No new replies allowed.