hi guys
could some one explain this code for urgent case.
i'll say what the code does in brief, this code take some values to make a window on the screen which contain a rectangle shape thats all.
there's some difficults in the declaration of the attributes & behaviors of this fragment which i'll indicated by arrow from the left side of the code, here is the code.
class RectangleShape {
public:
// here some obstacles in the constructor delaration
rectangleShape(===>SimpleWindow &window ,float Xcoord ,float Ycoord , ===>const color &Color ,float width , float height);
void Draw();
===>color GetColor() const; //what ment by color here
void GetSize(float &width , float &height)const;
float Getwidth() const;
float GetHeight() const;
void GetPosition(float &Xcoord , float Ycoord);
void SetSize(float Width , float height);
private:
===>SimpleWindow &Window; //what does this mean
float Xcente;
float Ycenter;
===>color Color; //what is the kind of variable Color
float Width;
float Height;
};
#include "rect.h"
SimpleWindow W("Main Window" , 8.0 , 8.0);
int ApiMain()
{
W.Open();
RectangleShape R(W , 4.0 , 4.0 , Blue , 2.0 , 3.0);
R.Draw();
return 0 ;
}
Comments
: could some one explain this code for urgent case.
: i'll say what the code does in brief, this code take some values to make a window on the screen which contain a rectangle shape thats all.
:
: there's some difficults in the declaration of the attributes & behaviors of this fragment which i'll indicated by arrow from the left side of the code, here is the code.
:
: class RectangleShape {
: public:
:
: // here some obstacles in the constructor delaration
:
: rectangleShape(===>SimpleWindow &window ,float Xcoord ,float Ycoord , ===>const color &Color ,float width , float height);
:
: void Draw();
:
: ===>color GetColor() const; //what ment by color here
:
: void GetSize(float &width , float &height)const;
: float Getwidth() const;
: float GetHeight() const;
: void GetPosition(float &Xcoord , float Ycoord);
: void SetSize(float Width , float height);
:
: private:
:
: ===>SimpleWindow &Window; //what does this mean
:
: float Xcente;
: float Ycenter;
:
: ===>color Color; //what is the kind of variable Color
:
: float Width;
: float Height;
:
: };
:
: #include "rect.h"
: SimpleWindow W("Main Window" , 8.0 , 8.0);
: int ApiMain()
: {
: W.Open();
: RectangleShape R(W , 4.0 , 4.0 , Blue , 2.0 , 3.0);
: R.Draw();
: return 0 ;
: }
:
:
Obviously you need the classes SimpleWindow and color or it won't run.
What those classes are, I have no idea, but it sounds like a bunch of user defined classes.
It's a user-defined type. GetColor() returns a value of that type.
:===>SimpleWindow &Window; //what does this mean
It's a reference. If you don't know what a reference is, you would be well served to get a C++ book and learn the language before you start actually trying to write software with it.
: ===>color Color; //what is the kind of variable Color
It's of type 'color', which is presumably defined somewhere else in the program.