Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,916 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,102 people online right now. Registration is fast and FREE... Join Now!




Image process help

 
Reply to this topicStart new topic

Image process help, need pointers on how to setup the screen

C++beginner
12 Dec, 2007 - 04:10 PM
Post #1

New D.I.C Head
*

Joined: 1 Dec, 2007
Posts: 5


My Contributions
Hello,
I'm doing a project that I've got started, but needs some pointers of how to use the class code from my instructor. I got a little bit, but I'm kind of stumped on what's next. Here is what I got. Any help would be really helpful. Thanks in advance.
CODE

#include <iostream>
#include <stdlib.h>
using namespace std;

const int YMAX = 20; // Array bound for screen height
const int XMAX = 70; // Array bound for screen length

/*****************************************************************
*Function Name: class Draw
*Parameters: None
*Return Value: int and char
*Purpose: Draws a figure from user's input
*****************************************************************/
class Draw {
    protected:
        char display[XMAX][YMAX]; // 20 by 70 character array to hold the picture
        int input, xpos, ypos;
    public:
        // Constructor to initialize object member data
        Draw() : input(0), xpos(0), ypos(19)
        {    }
        void greeting(); // Greeting screen to let the user know what this program is and to instruct the user on how to use the program
        void setup_screen(); // Setup the array
        void process_picture(); // Process the user provided string and store into the array
        void display_picture(); // Print the picture onto the screen
};

void Draw::greeting() {
        //This function will display to the user the instructions on how to use this program
        cout << "Welcome to the picture string generator!" << endl
             << "Please enter a string of numbers representing " << endl
             << "a picture that you would like to display." << endl
             << "Numbers print as the following:" << endl << endl
             << "8   1   2" << endl
             << " \\  |  /" << endl
             << "7 --+-- 3" << endl
             << " /  |  \\" << endl
             << "6   5   4" << endl << endl
             << "Positive numbers will draw an *." << endl
             << "A negative number will move the cursor but not draw a *." << endl;
    }

    void Draw::setup_screen() {
        //This function will initialize the "display" array so that when it is printed all array elements will be ' ' (blank)
    }

    void Draw::process_picture() {
        //This function will process the users input and create the picture by storing characters in the "display" array
    }

    void Draw::display_picture() {
        //This function will print the "display" array to the screen
    }
/*****************************************************************
*Function Name: main()
*Parameters: None
*Return Value: int
*Purpose: Draw a figure that user inputs
*****************************************************************/
    int main(){
        
        Draw dot;
        string opt;
        int numbers;
        dot.greeting();

        cout<<"\nEnter dreawing sequence below followed by the nubmer (0).\n"<<endl;
        cin>>numbers;
        
        dot.process_picture();
                    
        dot.setup_screen();
        
        dot.display_picture();
        cout<<"Your picture:\n\n"<<endl;
        
system ("PAUSE");
     return 0;
}

User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Image Process Help
12 Dec, 2007 - 04:41 PM
Post #2

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,351



Thanked: 51 times
Dream Kudos: 25
My Contributions
What exactly is the problem?
User is online!Profile CardPM
+Quote Post

C++beginner
RE: Image Process Help
12 Dec, 2007 - 04:55 PM
Post #3

New D.I.C Head
*

Joined: 1 Dec, 2007
Posts: 5


My Contributions
Oh, Sorry I'm suppose to get a output that goes like this, but I can't alter the existing class Draw, so I have to inherit from the class Draw and come up with a second class that has the functions.

This programs is suppose to draw a picture 1moves up, 2 moves up-right, 4 moves down-right, 5 moves down, and seven moves left thenwith the users input the "0" program exits and drawing the sequence and print on the screen the picture.

I just not sure how to inherit from the class.
Any pointers would be really nice.


SAMPLE OUTPUT:

CODE

Enter drawing sequence below.

1112244557770

Your picture:



     *
    * *
   *   *  
   *   *
   *****


This post has been edited by C++beginner: 13 Dec, 2007 - 12:09 AM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/8/09 02:31PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month