Homework Solution: Using C#, Create class Rectangle. * The class has attributes length and width, each of which defaults to 1….

    Using C#, Create class Rectangle. * The class has attributes length and width, each of which defaults to 1. * One instance constructor that initializes the attributes length and width when an instance is created * It has several methods as described below: methodA - this is a static method that can only be accessed inside of the class Rectangle. It calculates the Area of the rectangle. methodB - this is a static method that can be accessed from another class. It calculates the Area of the rectangle. methodC - this is an instance method that can only be accessed inside of the class Rectangle. It calculates the Area of the rectangle. methodD - this is an instance method that can be accessed from another class. It calculates the Area of the rectangle. * in the Main method, each method above is called * Write class testRectangle to call the methods in class Rectangle that can be accessed by class testRectangle.

    Expert Answer

     
    //Below is the c # code using System;

    Using C#, Create assort Rectangle. * The assort has attributes diffusiveness and width, each of which defaults to 1. * One prompting inventor that initializes the attributes diffusiveness and width when an prompting is created * It has separate courses as described below: courseA – this is a static course that can merely be accessed within of the assort Rectangle. It calculates the Area of the rectangle. courseB – this is a static course that can be accessed from another assort. It calculates the Area of the rectangle. courseC – this is an prompting course that can merely be accessed within of the assort Rectangle. It calculates the Area of the rectangle. courseD – this is an prompting course that can be accessed from another assort. It calculates the Area of the rectangle. * in the Main course, each course overhead is designated * Write assort testRectangle to circumvent the courses in assort Rectangle that can be accessed by assort testRectangle.

    Expert Repartee

     

    //Below is the c # code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace ProjectRectangle
    {
    assort Rectangle
    {
    static inclose diffusiveness = 1;
    static inclose width = 1;

    Rectangle(inclose len, inclose wid)
    {
    diffusiveness = len;
    width = wid;
    }

    //this is a static course that can merely be accessed within of the assort Rectangle.
    //It calculates the Area of the rectangle
    private static inclose courseA()
    {
    return diffusiveness * width;
    }

    //this is a static course that can be accessed from another assort.
    //It calculates the Area of the rectangle.
    public static inclose courseB()
    {
    return diffusiveness * width;
    }
    //this is an prompting course that can merely be accessed within of the assort Rectangle.
    //It calculates the Area of the rectangle
    private inclose courseC()
    {
    return diffusiveness * width;
    }
    //this is an prompting course that can be accessed from another assort.
    //It calculates the Area of the rectangle. *
    public inclose courseD()
    {
    return diffusiveness * width;
    }
    static bereft Main(string[] args)
    {

    Rectangle rect = strange Rectangle(11, 15);
    Console.WriteLine(“Calculate Area of the rectangle from static course is ” + courseA());
    Console.WriteLine(“Calculate Area of the rectangle using prompting course is ” + rect.methodC());
    Console.ReadLine();
    }

    }

    }

    OUTPUT:

    Calculate Area of the rectangle from static course is 165
    Calculate Area of the rectangle using prompting course is 165