Question: Based off the code attached in the picture answer the following questions: 1 ) Which code snippet correctly implements the addPoint method a ) points

Based off the code attached in the picture answer the following questions:
1) Which code snippet correctly implements the addPoint method
a) points[count]= Point(x,y); count++; resize();
b)count++; points[count]= Point (x,y); if (count == capacity){resise(); }
c) points[count]= Point (x,y);count++; if (count == capacity){resise(); }
d)points[count]= Point (x,y); if (count == capacity){resise(); } count++;
2) Which code snipper correctly implements the resize method?
a) void resize(){capacity *=2; delete[] points; points = new Point[capacity]; }
b) void resize(){capacity *=2; Point* old = points; points = new Point[capacity]; for (int i =0; i count; i++){points[i]= old [i]i;} delete[] old; }
c) void resize(){capacity *=2; Point* old = points; points = new Point[capacity]; delete[] old; for (int i =0; i count; i++){points[i]= old [i]i;}}
d) void resize(){capacity *=2; Point* old = points; for (int i =0; i count; i++){points[i]= old [i]i;} points = new Point[capacity]; delete[] old; }
3) Which code snippet correctly implements the draw method?
a) void draw (){for (int i =0; i count; i++){points[i].draw();}}
b) void draw () glBegin (GL_LINES); {for (int i =0; i count; i++){points[i].draw(); glVertex2f(points[i].getX(), points[i].getY()); glVertex2f(points[i+1].getX(), points[i+1].getY()); } glEnd(); }
c) void draw () glBegin (GL_LINES); {for (int i =0; i count; i++){points[i].draw()} glEnd(); }
d) void draw (){for (int i =0; i count; i++){points[i].draw();} glBegin (GL_LINES); glVertex2f(points[i].getX(), points[i].getY()); glVertex2f(points[i+1].getX(), points[i+1].getY()); } glEnd(); }
4) Which code snippet correctly implements the destructor?
a) ~ List (){delte points; }
b) ~ List(){delte[] points;}
c) ~List(){ for (int i =0; i capacity; i++){delte[i] points;}}
d) ~ List(){ for (int i =0; i capacity; i++){delte[i] points;} delete [] points;}
Based off the code attached in the picture answer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!