How Draw C++ Shapes

Posts 1–9 of 9 · Page 1 of 1
How Draw C++ Shapes
For Shape Class Use this code bellow....
Code:
class Shape {

public:
   Shape(int newx, int newy);
   int getX();
   int getY();
   void setX(int newx);
   void setY(int newy);
   void moveTo(int newx, int newy);
   void rMoveTo(int deltax, int deltay);
   virtual void draw();

private:
   int x;
   int y;
};
For the Shape .cpp use code bellow....
Code:
#include "Shape.h"

// constructor
Shape::Shape(int newx, int newy) {
   moveTo(newx, newy);
}

// accessors for x & y
int Shape::getX() { return x; }
int Shape::getY() { return y; }
void Shape::setX(int newx) { x = newx; }
void Shape::setY(int newy) { y = newy; }

// move the shape position
void Shape::moveTo(int newx, int newy) {
   setX(newx);
   setY(newy);
}
void Shape::rMoveTo(int deltax, int deltay) {
   moveTo(getX() + deltax, getY() + deltay);
}

// abstract draw method
void Shape::draw() {
}
Now lets start with example class...... we do a easy shape...
Code:
Rectangle(int newx, int newy, int newwidth, int newheight);
   int getWidth();
   int getHeight();
   void setWidth(int newwidth);
   void setHeight(int newheight);
   void draw();

private:
   int width;
   int height;
};
Now to draw the shape... add this code..
Code:
// draw the rectangle
void Rectangle::draw() {
   cout << "Drawing a Rectangle at:(" << getX() << "," << getY() <<
      "), width " << getWidth() << ", height " << getHeight() << endl;
}
00000000000000000000000000
And remember...
#include "Shape.h"
#include "Rectangle.h"
#include <iostream.h>

--------------------------------------------------
To make a circle...
Code:
void Circle::draw() {
  cout << "Drawing a Circle at:(" << getX() << "," << getY() <<
      "), radius " << getRadius() << endl;
You get it....
-----------

--------
Credits
computer engW
VernonDozier
Boomdocks
CA*****(name is wrong to say)
I will update you new code....
Quote Originally Posted by ultahackers View Post
// Own post>> Just tested it using and empty project it works.....
Give pic? I dun believe you
what does this gotta do with ca?
Quote Originally Posted by GodHack2 View Post
what does this gotta do with ca?
I dont know.. Make a hack with cool shape around it? wat else?
Quote Originally Posted by ultahackers View Post
I dont know.. Make a hack with cool shape around it? wat else?
I made boobs with this. In CA i have a boob as my menu
Quote Originally Posted by Fabolous View Post


I made boobs with this. In CA i have a boob as my menu
Hm....... see great idea?
Quote Originally Posted by Fabolous View Post


I made boobs with this. In CA i have a boob as my menu
FUCK YEAH I AM USING THIS NOW!
Quote Originally Posted by Fabolous View Post


I made boobs with this. In CA i have a boob as my menu
You can't code shit... and shit can't code you...
Posts 1–9 of 9 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us