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?
What will be an ideal response?
The Shape class defines a shape with a given number of sides. Method Mystery
determines the shape of its Shape and returns the name of the shape. Method Mystery takes a Shape object as an argument. The complete code reads:
// Shape.cs
using System;
namespace Shapes
{
///
/// Summary description for Shape.
///
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
}
Computer Science & Information Technology
You might also like to view...
________ tools gather information from sources such as e-mails, text messages, and tweets and make the information instantly and publicly available for use in emergencies
A) Affective computing B) Crowdsourcing C) Crisis-mapping D) Social networking
Computer Science & Information Technology
A document can be closed by clicking the Close icon in its Thumbnail on the taskbar
Indicate whether the statement is true or false
Computer Science & Information Technology