DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Thread: c++ class

  1. #1
    martin Guest

    c++ class


    Hi dear sir
    I live in Turkey & there is no help here in fact
    no one can help me here.
    could you help me please.
    I have folloing question & I have to write three files (like:bitmap.h bitmap.cpp
    main.cpp)but I have already written
    bitmap.h & I have prablem with other 2 .I really heve prablem for impelementation.I
    really heve prablem for impelementation.I do not know how should I start
    for impelementing for bitmap.cpp?
    just I need some help for impelementation.

    <<<<<<<<<<<<<<<<<<<<<question>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.....


    An image can be represented as a two-dimensional array (or matrix) of pixels
    each of which can be off (white) or on (black). A bitmap is a two-dimensional
    matrix of 0's and 1's where zero corresponds to an off pixel and one corresponds
    to an on pixel. Below is a 11*11 bitmap representing a cross.

    10000000001
    01000000010
    00100000100
    00010001000
    00001010000
    00000100000
    00001010000
    00010001000
    00100000100
    01000000010
    10000000001

    Overview
    Your task is to write a c++ program which displays the following menu on
    the screen and implements the required bitmap functions until the user quits
    (or end-of-file).
    L Load (Read) from file
    S Save to file
    D Display
    I Invert
    E Enlarge
    R Rotate
    U Undo
    Q Quit

    The functions
    Load (Read) from file
    The user is prompted to "Enter a filename " and the named file is read in.
    The file MUST consist of 2 integers giving the number of rows and the number
    of columns followed by a matrix of char (with these dimensions) as shown
    below.
    3 5
    00000
    00000
    01100

    Save to file
    The user is prompted to "Enter a filename " and the bitmap representation
    is written to the named file. The file MUST consist of 2 integers giving
    the number of rows and the number of columns followed by a matrix of char
    (with these dimensions) as shown below.
    3 5
    00000
    00000
    01100

    Display
    The image is displayed on the screen with spaces for zeroes and stars for
    ones. The earlier cross example would be displayed on the screen as :
    * *
    * *
    * *
    * *
    * *
    *
    * *
    * *
    * *
    * *
    * *

    Invert
    The image is inverted (zeroes changed to ones and vice verse).

    Enlarge
    The user is prompted for a vertical and a horizontal enlargement and the
    image is enlarged accordingly.

    Rotate
    The user is prompted with a sub-menu of:
    90 degree rotation
    180 degree rotation
    270 degree rotation
    and the image is rotated accordingly.

    Undo
    Undoes the most recent change to the image.

    Quit
    The program terminates.
    ================================================================
    I think I have to write three files(I already done bitmap.h):
    .bitmap.h
    .bitmap.cpp
    .main.cpp
    =================================================================
    bitmap.h :
    #ifndef BITMAP
    #define BITMAP

    #include <string>
    #include <iostream>
    #include <fstream>
    const int MaxSize=100;
    using namespace std;
    enum colour{black,white};
    enum direction{west,south,east};
    class BitMap
    {
    public:
    BitMap(); // generates a 1*1 grid of black
    BitMap(const BitMap& b); // copy constructor
    void display() const; // display grid
    int getRows() const; // get dimensions: rows
    int getCols() const; // get dimesnions: cols
    bool save (string filename); // writes the image to file filename
    bool read (string filename); // reads an image from file filename
    // initializes numrows numcols and myGrid
    void invert(); // changes black to white and vice versa

    void enlarge(int horiz, int vert);
    // pre : horiz >0 && vert > 0 &&
    // horiz*numcols < MaxSize &&
    // vert*numrows < MaxSize
    // post : image has been enlarged by given

    // dimensions
    void rotate (direction d); // rotates image in given direction

    private:
    int numrows; int numcols;

    char myGrid[MaxSize][MaxSize];
    };

    #endif


    =====================================
    #include <iostream>
    #include <iostream>
    #include <string>
    #include "bitmap.h"
    using namespace std;

    BitMap :: BitMap(){ numrows =0; numcols=0;

    }
    //--------------------------------------------------------------------------------------

    BitMap ::BitMap(const BitMap& b) {



    }
    //-------------------------------------------------------------------------------------------

    void BitMap :: display() const {
    }

    //----------------------------------------------------------------------------------------------

    int BitMap :: getRows() const {
    }
    //-----------------------------------------------------------------------------------------
    int BitMap :: getCols() const {
    }
    //------------------------------------------------------------------------------
    bool BitMap :: save (string filename) {

    }

    //------------------------------------------------------------------------------------------------------

    bool BitMap :: read (string filename) {
    }
    //-----------------------------------------------------------------
    void BitMap :: invert() {
    }
    //---------------------------------------------------------------------
    void BitMap :: enlarge(int horiz, int vert {
    }
    //---------------------------------------------------------------------------

    void BitMap :: rotate (direction d) {
    }
    //---------------------------------------------------------------------------------------



    thanks for your helping







  2. #2
    Frank Oquendo Guest

    Re: c++ class

    Martin,

    You've got the wrong C dialect. C# is not C++. You might try asking for help
    in a more appropriate group.

    --
    There are 10 kinds of people:
    Those who understand binary and those who don't
    http://www.acadx.com
    http://vbxtender.sourceforge.net



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links