Thread: Fractal Drawer Project - STL and OOP - C++

  1. #1
    Registered User
    Join Date
    Nov 2019
    Posts
    135

    Fractal Drawer Project - STL and OOP - C++

    Hello everyone.

    My new project is released and I have to submit it till 07/01.
    The exercise actually aims to practice us with the concept of STL, inheritance, program design according to OOP concepts (Polymorphism and Abstract),.

    At the previous semester I took a JAVA-OOP course in which I was really bad. So I'm really anxious now about this exercise.

    Background of the exercise:

    We have to actually draw fractals using '#' and single white-space.

    The program will run through a main function which receives a CSV file declaring the fractals we have to draw (The output has to be in reverse order). Each line in this declaration file is at the following form:
    <Kind of fractal>, <Dimension of fractal>.
    Kind of fractal (a number between 1 to 6 - each digit expresses another kind of fractal)
    Dimension of fractal (a number between 1 to 4 - it actually expresses the "size" of the fractal).

    Of course, we have to parse the file, print to STDERR if any line is defected/not in the right format/out of range/more than/less than two columns in line.

    * We are encouraged to use only two libraries of boost: filesystem and tokenizer. Actually we didn't learn about boost at all...
    * We must use C++ STL.


    Guidelines:
    - We have to include all the classes dealing with drawing the fractals inside exactly one cpp file and one header file.
    - The program design must consider the following constraints:
    Each class which is related to the creation of the fractals has to consist of the following members: the "output board" as a vector, the type of the objects inside the vector (T), the dimension of the vector (Implementation as a vector or vector of vectors - our decision). (What do they mean with a vector of vectors or a vector? Why does a dimension have to hold a type of vector at all?)
    - Consider the following questions: Do you need to use concepts of encapsulation, polymorphism, abstraction? Are there any design patterns that we should use in this exercise?


    The next part of the exercise description dives into the specific kinds of fractals, their output format:
    They demonstrate the building process of each fractal - printing inductively using ASCII art.
    I didn't understand their meaning with the induction etc... But I don't think I have to tackle it right now.

    Can someone help me with that? How can I organize my work here? How do I think of the classes I have to construct, the required members, their relationship? I'm really afraid of this project.

    Thanks in advance.

  2. #2
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    It sounds like an interesting project. I guess the first thing I'd do is stop being afraid of it even though that might be challenging at first. The second thing I'd do is prepare a list of things you might want to clarify with your teacher/TA/professor (e.g. what exactly is meant by "printing inductively"?) so that as soon as you can next see them you can ask [1] -- I'd ask them as soon as possible. In the meantime it would probably be useful to ensure that you know and understand how to generate the fractals. Is there a list of what the 6 fractals are? I think that scribbling things down on paper will assist with the design of the classes and their relationships (and that those two things are more important, IMO, than the actual required members of the classes). Do you need to "use concepts of encapsulation, polymorphism, abstraction"? You probably do if they're mentioned in the exercise description. Off hand I can't really think of how *I* would use polymorphism in this exercise but it might depend on what the actual fractals are. Anyway, the most important things to do are: a) not panic; and b) start thinking about things and scribbling down notes/ideas on paper. That's what I'd do anyhow.

    [1] It's their responsibility to properly describe what they want. It's your responsibility to ask for clarification if there is ambiguity. Pretend your teachers are a client; you'll be asking clients or employers questions for the rest of your life, so may as well get used to it now. Personally I don't really know what that phrase means either (I can guess and I might get it right but... yeah, just ask). Chances are that if you can't understand it properly and I can't understand it properly lots of other people probably can't as well. Nothing wrong with asking for clarification.
    Last edited by Hodor; 12-28-2019 at 10:41 PM.

  3. #3
    Registered User
    Join Date
    Nov 2019
    Posts
    135
    @Hodor - Thank you for the encouragement and the suggestions - I have done it.

    The fractal's output:
    There are three kinds of fractals: Sierpinski Carpet (indicated by 1), Sierpinski Triangle (indicated by 2), Vicsek fractal (indicated by 3).
    We have to print the fractals using ASCII Art: Every time we are printing a part from the fractal: we have to use # and when we want to skip and not to print anything, we have to print a single white-space. Each fractal is printed by induction on n (n is in Naturals including 0) - the base case is 0 which is not legal if as the whole dimension of some fractal. That is, if some kind of fractal inside the CSV is provided with a dimension less than 1 - We are printing an error to STDERR.

    Sierpinski Carpet We describe this fractal by induction on n as follows:
    Base case: when n = 0: we mark this by a single #
    The step: At each stage we'll create 9 sub-squares which can be described by the following table:
    https://media.discordapp.net/attachm...15/unknown.png
    That is, in this case, at each stage of the recursion, 3X3 grid is created, in which we represent the sub-fractal at n-1'th order if and only if it is not the middle sub-fractal.
    For example, when the dimension is 0 what will be printed is only one #, when the dimension is 1:
    https://media.discordapp.net/attachm...08/unknown.png
    When the dimension is 2:
    https://media.discordapp.net/attachm...08/unknown.png

    To describe the printing process:
    At each level, you have a 3X3 grid but the 9 cells get bigger at each level. n = 0: 1 char n = 1: 3X3 chars (each of the 9 cells is the size of n = 0) n=2: 9X9 chars (each of the 9 cells is the size of n = 1, which is 3X3) outer cells is short for the cells that have a # for n = 1.

  4. #4
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Quote Originally Posted by HelpMeC View Post
    @Hodor - Thank you for the encouragement and the suggestions - I have done it.
    You've done... the assignment? Or asked for clarification? I'll assume you haven't finished the assignment yet and you asked for clarification. Ok, that's a good start! Are there any parts of the assignment that you can do now (and in the meantime keep jotting ideas down on paper)? E.g. can you design and code a class or function [1] to read the CSV file? I don't know if that's the best place to start (it seems the easiest part to design and code to me, though), it's just an idea, but you need to start somewhere and once you make progress maybe it'll help relieve your fear.

    [1] Addendum: After some thought, maybe a class is what they expect rather than a function considering the assignment description but you decide
    Last edited by Hodor; 12-29-2019 at 08:00 PM.

  5. #5
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    So is printing inductively meant to do something like this (for n = 0 to 2)? (Note that this is a question... I'm still confused by the "printing inductively" part )

    Code:
    #
    
    ###
    # #
    ###
    
    #########
    # ## ## #
    #########
    ###   ###
    # #   # #
    ###   ###
    #########
    # ## ## #
    #########
    Last edited by Hodor; 12-29-2019 at 08:19 PM.

  6. #6
    Registered User
    Join Date
    Nov 2019
    Posts
    135
    @Hodor
    So, for a line in the CSV like: 1, 2 we have to print this one:
    Code:
    #########
    # ## ## #
    #########
    ###   ###
    # #   # #
    ###   ###
    #########
    # ## ## #
    #########
    For a line: 1, 1:
    Code:
    ###
    # #
    ###
    For a line: 1, 0:
    Code:
    "error message to STDERR"
    As for the parsing section:

    We are recommended actually to use BOOST library (only the filesystem and tokenizer) - they provide us with some links of download instruction etc.. but we didn't learn about that formally.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fractal Zooming
    By Valdo in forum C++ Programming
    Replies: 1
    Last Post: 04-11-2013, 10:19 AM
  2. Fractal Generator
    By darren78 in forum C++ Programming
    Replies: 4
    Last Post: 10-12-2010, 09:01 AM
  3. 2D Fractal Terrain
    By TheSpook in forum C++ Programming
    Replies: 15
    Last Post: 01-14-2010, 10:28 PM
  4. fractal maker
    By arjunajay in forum C++ Programming
    Replies: 2
    Last Post: 07-04-2005, 07:08 AM
  5. Fractal Operating System
    By DiskJunky in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 07-11-2002, 01:17 AM

Tags for this Thread