Polygon is drawable and it has several vertices. colors that can be stored by a vector and a flag of boolean type. What can you use to declare the member variables of this class? a.) Object b.) boolean c.) vertice d.) Vector e.) Polygon From my point of view the answer should be b,d. Any comments.
Polygon is drawable and it has several vertices. colors that can be stored by a vector and a flag of boolean type. What can you use to declare the member variables of this class? a.) Object //No b.) boolean //Yes ,Since the qstn says it has a boolean type member var c.) vertice //may or may not be d.) Vector // Yes, because the qstn particularly asks to store the vertices and color in a Vector object e.) Polygon //NO I think the qstn is not very clear in what it says so. What I understand is the Polygon object has many vertices (x1,y1) , (x2,y2).....(xn,yn) and it has a Color as a member var using which the Polygon is drawn. It also implements an interface drawable (it may be the name of the interface).This info can be stored in many ways in a Vector. The storing and retriving mechanism must be compatible. For color, A new Color object may be created and added to the Vector object. For the vertices there can be int[n] array which has the (x,y) coordinates. For storing the vertices we may have to create an int[n] where n is total no of vertices to be drawn. In this case the 3rd answer comes as just a var name 'vertice' not a Type. So we CAN use this vertice as a var name. Otherwise there may be a class named 'vertice' which has x,y as instance member vars. In that case, to store the vertices of the Polygon we may have to create an array of type 'vertice' and add this array to the Vector object. Or we can directly create this 'vertice' class type object and add to Vector object without creating as an array as a member var. Since the qstn asks about member var of the Polygon we have to ignore the last one which i just described. Generally we use CAPITALIZED FIRST letter for class Types and LOWERCASE first letter for var/methodNames etc. If we see in that angle the 3rd ans 'vertice' more likely a member var name which we CAN USE for declare the members. This is my thought. Others can add to this. regds maha anna
The question must be... A Polygon is Drawable.Polygon has several vertices which are stored in a vector,Color for filling and a flag which is of type boolean. and hence the memeber variables used in Class Polygon are of type Color, Vector and boolean So, the answer is b and d.
[This message has been edited by Saritha Pilla (edited March 09, 2000).]
Can somebody rephrase the question so it is clearer? From what i understand: A Polygon is Drawable, it has a number of vertices, a number of colors and a boolean flag. What are the types that you will need to use for the member variables of a Polygon? is that what the question is?
May the Moose be with you.
posted 18 years ago
Again carelesness .I didn't notice "member variable" . So gone ahead with objects.