PRG455 XXXXXXXXXXTEST 1 Student Name: _______________________________________ XXXXXXXXXXDuration: 60 minutes Marks: 20 XXXXXXXXXXmarks) Write a complete definition of the C# class Circle which...

1 answer below »
Answer the questions


PRG455 TEST 1 Student Name: _______________________________________ Duration: 60 minutes Marks: 20 1. (6.5 marks) Write a complete definition of the C# class Circle which contains the following members: - a private non-static data field to store a circle’s radius - a constant PI (=3.141592) - a public read/write property that can be used to read/write radius - a public read-only property that is returning circle’s area (Note: PI*radius*radius) - a public constructor with a parameter that is used to initialize radius ANSWER: 2. (4 marks) Design a form’s Load event handler that will use the Circle class created in question 1 to execute the following tasks when the form is loaded: - Create an object of the Circle class. Note: make up your own initial radius value. - Use the property created in the Circle class to assign the radius which is entered into the txtRadius text box by the user. The previously created object should be used. - Use the message box and the property that returns circle’s area to show the area of the circle. Write a complete definition of the Form1_Load event handler to meet these requirements. ANSWER: 3. (2.5 marks) If given the following method of the class named MyClass: public static void Test(params string [ ] array) { //some code that defines this method is placed here } Write two different examples of this method calls statements, one inside its own class and the other one outside of its class and include all necessary declarations. ANSWER: A) //a method call inside its class B) //a method call outside of its class 4. (3 marks) Write a code segment to execute the following: - If given a class named FormTest create an object of this class. Note: the FormTest class was previously defined. - Show FormTest as a modal form. - Close the current form. ANSWER: 5. (4 marks) Given the following jagged array declaration: string[][] courses; Assume that the courses array has been created and initialized, i.e. the array contains the lists of courses taken by a given number of students. Write a code segment that uses a nested foreach loop to display the list of courses for each student individually as shown in the following example: Student 1 courses => PRG455, NET455, MTH355, GEN455, MCO455 Student 2 courses => PRG455, Student 3 courses => PRG455, NET455, MCO455, ……………………………… You should use the format of the output shown above and include all necessary declarations. You can use a control of your choice to display the output (e.g. a list box, a multiline text box, etc.). ANSWER: 2
Answered Same DayJun 22, 2021

Answer To: PRG455 XXXXXXXXXXTEST 1 Student Name: _______________________________________ XXXXXXXXXXDuration: 60...

Aditya answered on Jun 22 2021
157 Votes
PRG455 TEST 1
Student Name: _______________________________________ Duration: 60 minutes
Marks: 20
1.
(6.5 marks) Write a complete definition of the C# class Circle which contains the following members:
- a private non-static data field to store a circle’s radius
- a constant PI (=3.141592)
- a public read/write property that can be used to read/write radius
- a public read-only property that is returning circle’s area (Note: PI*radius*radius)
- a public constructor with a parameter that is used to initialize radius
ANSWER:
using System;
using System.Collections.Generic;
using System.Text;

namespace Test1
{
class Circle
{
private double radius;
private const double PI = 3.141592;
public Circle(double radius)
{
this.radius = radius;
}

public double getArea()
{
return PI * radius * radius;
}

public void setRadius(double radius)
{
this.radius = radius;
}

public double getRadius()
{
return radius;
}
}
}
2. (4 marks) Design a form’s Load event handler that will use the Circle class created in question 1 to execute the following tasks when the form is loaded:
- Create an object of the Circle class. Note: make up your own initial radius value.
- Use the property created in the Circle class to assign the radius which is entered into the
txtRadius text box by the user. The previously created object should be used.
- Use the message box and the property that returns circle’s area to show the area of the
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here