Find the error(s) in the following code. The following method should create a new Shape object with intNumberSides sides. Assume the Shape class

What will be an ideal response?


The complete corrected code should read:



// Manipulate.cs (Correct)



using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

using Shapes;



namespace Manipulate

{

///

/// Summary description for FrmManipulate.

///


public class FrmManipulate : System.Windows.Forms.Form

{

private System.Windows.Forms.Button btnChange;

private System.Windows.Forms.TextBox txtInput;

private System.Windows.Forms.Label lblChangeTo;

private System.Windows.Forms.Label lblSidesOut;

private System.Windows.Forms.Label lblSides;

///

/// Required designer variable.

///


private System.ComponentModel.Container components = null;



public FrmManipulate()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();



//

// TODO: Add any constructor code after InitializeComponent

// call

//

}



///

/// Clean up any resources being used.

///


protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}



// Windows Form Designer generated code



///

/// The main entry point for the application.

///


[STAThread]

static void Main()

{

Application.Run( new FrmManipulate() );

}



// updates the number of sides in the shape

private void btnChange_Click(

object sender, System.EventArgs e )

{

int intNewSides;

Shape objNewShape;



intNewSides = Int32.Parse( txtInput.Text );



objNewShape = ManipulateShape( intNewSides );



lblSidesOut.Text = Convert.ToString( objNewShape.Side );



} // end method btnChange_Click



// creates a new shape object with intNumberSides sides

private Shape ManipulateShape( int intNumberSides )

{

Shape objShape = new Shape( intNumberSides );

return objShape;



} // end method ManipulateShape



} // end class FrmManipulate

}



Computer Science & Information Technology

You might also like to view...

You have decided that you will design a title so that it looks good in any screen resolution from 640x480 to 1024x768. You want the heading to be dramatic, which you have decided means as big as possible without it breaking into two lines on a small screen. The title is “Typography is Fun!” Create a Web page with several versions of the title, each using a different typeface. Use at least different three different typefaces. For each version, specify the typeface and size for the font. Note: there is no unique “correct” answer. Restrict yourself to the typefaces described in this chapter.

The design specifications said that the title shouldn’t break into two lines when seen on a 640x480 monitor, so the first thing to do is to determine the minimum width. For the following example, the width is 540 pixels, but it’s okay if the width is a little wider. The main thrust is to create titles that all have the same width, and the point of the exercise is that fonts having different typefaces but identical point size will take up varying horizontal space due to the face that a point size specifies a vertical measure, not a horizontal one.

Computer Science & Information Technology

Macros allow more complex functionality than just using VBA

Indicate whether the statement is true or false

Computer Science & Information Technology

If you try to close a workbook that contains changes you haven't saved, ____.

A. a dialog box asks you whether or not you want to save the file B. the workbook closes and your changes are lost C. you receive an error message D. the workbook closes and your changes are saved anyway

Computer Science & Information Technology

What is the purpose of item D in the accompanying figure?

A. To provide playback controls B. To show the layers in outline form C. To lock the layers D. To show keyframes

Computer Science & Information Technology