Define a rectangle class with length, witdh, coor (x), coor (y). Then write the following methods: (Create a border named rectangle with variables length ,width, color (x), color (y) and do the following operations.) a) It stores four global variables for length, witdh, coorx and coory. (create four integer variables.) b) Two constructors: default and user defined (overloaded). (Create a class called rectangle with variables and do the following.)) c) move() method that moves rectangle in x and y directions.(Create a method named move() that takes parameters and move the rectangle in the x and y directions. Annotation: motion operation takes the parX and parY parameters given to the method, increasing or decreasing the coorx and coory variables will be) d) write two get methods which return perimeter and area. (calculate the area and perimeter of the rectangle Write two methods that return) e) write main method to test these two constructors by using array of rectangles which has two items. (Create two separate objects of the rectangle class in main(). The first object is the default constructor and the other will be created using the overloaded constructor.)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

(( C# object oriented programming ))

the question is in attach: I will sent the code for the question, I need another way, you can update this code:

Begin:***************

using System;

namespace Rectangle

{

    class Program

    {

        static void Main(string[] args)

        {

            Rectangle[] rectArray = new Rectangle[2];

 

            rectArray[0] = new Rectangle();

            rectArray[1] = new Rectangle(10, 20, 1, 2);

 

            for (int index = 0; index < rectArray.Length; index++)

            {

                Console.WriteLine("Rectangle " + (index + 1) + " details");

                Console.WriteLine("Area: " + rectArray[index].GetArea());

                Console.WriteLine("Perimeter: " + rectArray[index].GetPerimeter());

                Console.WriteLine();

            }

        }

            public class Rectangle

        {

            private int length;

            private int width;

            private int coorx;

            private int coory;

            public int Length

            {

                get { return length; }

                set { length = value; }

            }

            public int Width

            {

                get { return width; }

                set { width = value; }

            }

            public int Coorx

            {

                get { return coorx; }

                set { coorx = value; }

            }

            public int Coory

            {

                get { return coory; }

                set { coory = value; }

            }

            public Rectangle()

            {

                this.length = 0;

                this.width = 0;

                this.coorx = 0;

                this.coory = 0;

            }

            public Rectangle(int length, int width, int coorx, int coory)

            {

                this.length = length;

                this.width = width;

                this.coorx = coorx;

                this.coory = coory;

            }

            public void move(int parX, int parY)

            {

                this.coorx += parX;

                this.coory += parY;

            }

            public double GetPerimeter()

            {

                return 2 * (this.length + this.width);

            }

            public double GetArea()

            {

                return this.length * this.width;

            }

        }

    }

 

}

End******************

 

Define a rectangle class with length,
witdh, coor (x), coor (y). Then write the following methods: (Create a border named rectangle
with variables length ,width, color (x), color (y) and do the following operations.)
а)
It
stores four global variables for length, witdh,
coorx and coory. (create four integer variables.)
b)
Two
constructors: default and user defined (overloaded).
(Create a class called rectangle with variables and do the following.))
c)
move()
method that moves rectangle in x and y directions.(Create a method named move() that takes
parameters and move the rectangle in the x and y directions.
Annotation: motion operation takes the parX and parY parameters given to the method,
increasing or decreasing the coorx and coory variables
will be)
d)
write
two get methods which return perimeter and area. (calculate the area and perimeter of the
rectangle
Write two methods that return)
e)
write
main method to test these two constructors by using array of rectangles which
has two items. (Create two separate objects of the rectangle class in main(). The first object is
the default constructor and the other
will be created using the overloaded constructor.)
Transcribed Image Text:Define a rectangle class with length, witdh, coor (x), coor (y). Then write the following methods: (Create a border named rectangle with variables length ,width, color (x), color (y) and do the following operations.) а) It stores four global variables for length, witdh, coorx and coory. (create four integer variables.) b) Two constructors: default and user defined (overloaded). (Create a class called rectangle with variables and do the following.)) c) move() method that moves rectangle in x and y directions.(Create a method named move() that takes parameters and move the rectangle in the x and y directions. Annotation: motion operation takes the parX and parY parameters given to the method, increasing or decreasing the coorx and coory variables will be) d) write two get methods which return perimeter and area. (calculate the area and perimeter of the rectangle Write two methods that return) e) write main method to test these two constructors by using array of rectangles which has two items. (Create two separate objects of the rectangle class in main(). The first object is the default constructor and the other will be created using the overloaded constructor.)
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education