ted-devs / csharp-assignments-amad

This repository is for Amad to submit his assignments in.
0 stars 1 forks source link

Assignment 6: Classes and Objects #10

Open ted-devs opened 1 year ago

ted-devs commented 1 year ago

Assignment 6

Create a Rectangle class, which has the following members:

  1. Type this must store whether the rectangle is a square or not
  2. Length
  3. Width
  4. Area()
  5. Perimeter()

You need to overload the constructor so the user can create both a rectangle, and a square (i.e., you only enter one value, which is the same for both length and width).

You must also overload the Area() and Perimeter() methods, since they will have different definitions for square and rectangle.

Area of Rectangle: $L \times W$ Perimeter of Rectangle: $2 \times (L + W)$

Area of Square: $L^2$ (you can use Math.Pow() here) Perimeter of Rectangle: $4 \times L$

You must also create static methods that let you calculate the Perimeter and Area of any Length and Width values, without having to create an object first.

ted-devs commented 1 year ago

@Amadkazmi please review the assignment details and try to complete within next week.