What does the following code do? The first code listing contains the declaration of the Shape class. Each Shape object represents a closed shape with a number of sides. The second code listing contains a method (Mystery) created by a client of the Shape class. What does this method do?


public class Shape
{
private int m_intSides;

// constructor with number of sides
public Shape( int intSides )
{
Side = intSides;

} // end constructor Shape

// set and get side value
public int Side
{
// return m_intSides
get
{
return m_intSides;

} // end of get accessor

// set m_intSides
set
{
if ( value > 0 )
{
m_intSides = value;
}
else
{
m_intSides = 0;
}

} // end of set accessor

} // end property Side

} // end class Shape



public string Mystery( Shape objShape )
{
string strShape;

switch ( objShape.Side )
{
case 0:
case 1:
case 2: strShape = "Not a Shape";
break;

case 3: strShape = "Triangle";
break;

case 4: strShape = "Square";
break;

default: strShape = "Polygon";
break;
}
return strShape;

} // end method Mystery

Computer Science & Information Technology

You might also like to view...

Two types of audit records used are Detection-specific audit records and _________ audit records. ?

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

You can press ____ to access Photoshop Help.

a. F1 b. F2 c. F5 d. F8

Computer Science & Information Technology

Which of the following is NOT true about Facebook?

A) Facebook was opened to high school students in 2005, and to all users above the age of 13 in 2006. B) When Facebook was launched it was initially called "Yourfacebook." C) Facebook surpassed MySpace in both users and page views in April 2008. D) Facebook might be the largest social network, but others have followed such as Google+ and Pinterest.

Computer Science & Information Technology

What technology is an open source federation framework and supports the development of authorization protocols?

A. Shibboleth B. OAuth C. SAML D. Kerberos

Computer Science & Information Technology