OOP Lab Task 4
1- Write a C# program, that have a Circle class with one
private parameter:
o int radius
The class also has a public property for the private field
named Radius to get and set the radius, but before setting
the radius make sure that the radius greater than or
equal 0 then set the value to radius and invoke the
GetArea() method, otherwise set the radius to 1, the class
also contains parameterized constructor that takes radius
as parameter. The class also has a method named
GetArea() that return the area of the circle.
In the Main method, create two instances/objects of the
Circle class. The first instance, "c1", has valid radius
input greater than 0, and the second instance, "c2", has
an invalid radius input less than 0.
Eng. Amany Sherif | CS Dept.
2- Write a C# program, that have an Operation class with three
private parameters:
o int num1
o int num2
o string sign
The class has a 3 public properties named Num1, Num2, Sign to
get and set the three private parameters, but before setting value
to the sign parameter check if it is “+” then call Sum() method if
else it is “-“ call Sub() method and if else it is “*” call Mul()
method else call Div() method. Also a parameterized constructor
that takes num1, num2, and sign as parameters. The class has 4
public void method Sum(), Sub(), Mul() and Div().
In the Main method, create four instances/objects of the
Operation class. The first instance, "o1", has two numbers and
“+”,the second instance, "o2", has two numbers and “-”, the third
instance, "o3", has two numbers and “*” and the fourth instance,
"o4", has two numbers and “/“.
The Main() should look like this:
The Output should be like this:
Eng. Amany Sherif | CS Dept.