How do I go about doing this?

I'm taking a class right now on C++ and I don't understand the next assignment. I don't know how to begin it, and I'm not sure what I'm not understanding.
Here is the complete assignment:

Drawing Program Your assignment is to write a C++ program that extends the interactive sketching program that you did for homework problem 4. This time, however, the program will have a class that will be able to maintain the data for drawing objects as well as draw the objects.

The following variables should be in the class:

objects -- an array of objects that stores the number of objects
n -- number of objects stored in array

The following methods should be in the class:

constructor -- constructor to initialize n=0
createObject -- a method to create the initial data of an object
updateObject -- a method to update second position of object
draw -- a method that draws all objects
drawLine -- a method that will draw a line of a given object in the array
drawRectangle -- a method that will draw a filled or unfilled rectangle
of a given object in the array
drawCircle -- a method that will draw a filled or unfilled circle of
a given object in the array

The program should be written in two files (for example, sketch.h and sketch.cpp). The header file, sketch.h, should only contain the class definitions where the sketch.cpp will contain the implementation of the methods that are further defined from sketch.h. Your program should be able to compile, but will not be expected to work until assignment #6.

I don't even know how to begin this. What is supposed to go in Sketch.h? How do I do the class thing? I've been reading up on things but it still doesn't make sense to me. Someone pleeeeeeease help, I'm in desperate need.

Here is my previous assignment that I'm supposed to build on.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
  #include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>

#include <iostream>
#include <cmath>
using namespace std;

#define WIDTH    	700
#define HEIGHT   	600

#define MENUWIDTH 	100
#define BOXHEIGHT	(HEIGHT/NCOLORS)

#define DSLEFT    	MENUWIDTH
#define DSRIGHT  	WIDTH
#define DSBOTTOM  	0
#define DSTOP     	HEIGHT

#define NCOLORS 	6

#define RGBRED 		1, 0, 0
#define	RGBGREEN	0, 1, 0
#define RGBBLUE		0, 0, 1
#define RGBYELLOW	1, 1, 0
#define RGBMAGENTA	1, 0, 1
#define RGBCYAN		0, 1, 1

#define RGBWHITE	1, 1, 1

#define R		0
#define G		1
#define B		2

static float colormenu[6][3] = {{RGBRED}, {RGBGREEN}, {RGBBLUE}, {RGBYELLOW}, {RGBMAGENTA}, {RGBCYAN}};
static float selectedcolor[3];

static int _x;
static int _y;

static bool tracking=false;

int incolormenu(int x, int y) 
{
  return (x >= 0 && x <= MENUWIDTH && y >= 0 && y <= HEIGHT);
}

int canvas(int x, int y)
{
  return (x>DSLEFT && x<DSRIGHT && y>DSBOTTOM && y<DSTOP);
}

int colormenuindex(int x, int y) 
{

  if(!incolormenu(x, y))
    	return -1;

  else
    	return(y / BOXHEIGHT);
}

void handleButton(int button, int state, int x, int y)
{
  
  static int menuindex = -1;

  y = HEIGHT - y;

  if(button != GLUT_LEFT_BUTTON)
    	return;

  if(state == GLUT_DOWN)
  {
    	if(incolormenu(x, y))
    	{
     		menuindex = colormenuindex(x, y);
	
       		selectedcolor[0]=(colormenu[menuindex][R]);
		selectedcolor[1]=(colormenu[menuindex][G]);
		selectedcolor[2]=(colormenu[menuindex][B]);
	}
	if(canvas(x,y))
	{
		tracking=true;
		_x=x;
		_y=y;
	}
  }
  else
  {
	tracking=false;
    
    glFlush();
  }
}

void m_motion(int x, int y)
{
	y=DSTOP-y;

	if (tracking=true && canvas(x,y))
	{
		glColor3f(selectedcolor[0],selectedcolor[1],selectedcolor[2]);

		glBegin(GL_LINES);
			glVertex2i(_x,_y);
			glVertex2i(x,y);

		glEnd();
		glFlush();
		_x=x;
		_y=y;
	}
}

void drawMenu() 
{

  glClear(GL_COLOR_BUFFER_BIT);

  for(int i = 0; i < NCOLORS; i++)
  {
		glColor3f(colormenu[i][R], colormenu[i][G], colormenu[i][B]);
		glRecti(1, BOXHEIGHT * i + 1, MENUWIDTH - 1, BOXHEIGHT * (i + 1) - 1);
  }
  
  glFlush();
}

int main(int argc, char* argv[]) 
{
		glutInit(&argc, argv);

		glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
		glutInitWindowSize(WIDTH, HEIGHT);
		glutCreateWindow("Color Menu");
		gluOrtho2D(0, WIDTH, 0, HEIGHT);

		glutDisplayFunc(drawMenu);
		glutMouseFunc(handleButton);
		glutMotionFunc(m_motion);
		   
	        glClearColor(RGBWHITE, 1);

		glutMainLoop();

		return 0;
}


Someone please help :(
Last edited on
Topic archived. No new replies allowed.