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
}
You might also like to view...
The main advantage of ________ quality models resides in their ability to measure QoE values using information gathered at the periphery of a given media processing system.
A) Glass-box B) Gray-box C) Black-box D) Red-box
Your ________ allows you to access your files, settings, and online services from devices connected to the Internet
Fill in the blank(s) with correct word
In Access, an input mask can be used as a(n) ________ rule, which limits or controls what users can enter in a field
Fill in the blank(s) with correct word
An amortization table uses the PMT function to calculate each monthly payment
Indicate whether the statement is true or false.