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 arrange Rectangle. * The arrange has attributes diffusiveness and width, each of which defaults to 1. * One request agent that initializes the attributes diffusiveness and width when an request is created * It has diverse systems as feeling below: systemA – this is a static system that can solely be accessed within of the arrange Rectangle. It calculates the Area of the rectangle. systemB – this is a static system that can be accessed from another arrange. It calculates the Area of the rectangle. systemC – this is an request system that can solely be accessed within of the arrange Rectangle. It calculates the Area of the rectangle. systemD – this is an request system that can be accessed from another arrange. It calculates the Area of the rectangle. * in the Main system, each system over is designated * Write arrange testRectangle to fawn the systems in arrange Rectangle that can be accessed by arrange testRectangle.

    Expert Counterpart

     

    //Below is the c # code

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

    namespace ProjectRectangle
    {
    arrange Rectangle
    {
    static embrace diffusiveness = 1;
    static embrace width = 1;

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

    //this is a static system that can solely be accessed within of the arrange Rectangle.
    //It calculates the Area of the rectangle
    private static embrace systemA()
    {
    return diffusiveness * width;
    }

    //this is a static system that can be accessed from another arrange.
    //It calculates the Area of the rectangle.
    public static embrace systemB()
    {
    return diffusiveness * width;
    }
    //this is an request system that can solely be accessed within of the arrange Rectangle.
    //It calculates the Area of the rectangle
    private embrace systemC()
    {
    return diffusiveness * width;
    }
    //this is an request system that can be accessed from another arrange.
    //It calculates the Area of the rectangle. *
    public embrace systemD()
    {
    return diffusiveness * width;
    }
    static vacant Main(string[] args)
    {

    Rectangle rect = fantastic Rectangle(11, 15);
    Console.WriteLine(“Calculate Area of the rectangle from static system is ” + systemA());
    Console.WriteLine(“Calculate Area of the rectangle using request system is ” + rect.methodC());
    Console.ReadLine();
    }

    }

    }

    OUTPUT:

    Calculate Area of the rectangle from static system is 165
    Calculate Area of the rectangle using request system is 165