### A constructor that constructs a rectangle2d

Assignment Help C/C++ Programming
##### Reference no: EM13165010

Write a class called Rectangle2D to represent a rectangle in the plane (2 dimensional space). The class
must contain:

• Four points p1, p2, p3 and p4 of type MyPoint.
• Getter methods for the four points.
• A method LinkedList<MyPoint> getVertices() that returns a list of the vertices of the

rectangle (so a list of the points).

• A constructor that constructs a Rectangle2D with specified points as coordinates.
• A no-argument constructor that creates the rectangle with points (0, 0), (5, 5) and (0, 5) and

(5,0) - this constructor must call your previous constructor.

• A non-static method double getPerimeterLength() that returns the length of the perimeter of a

rectangle.

Write a main class as follows:
Rectangle2D rect = new Rectangle2D();
double len = rect.getPerimeterLength();

Here is the code for the MyPoint class:

public class MyPoint
{
private double x;
private double y;

public MyPoint(double x, double y)
{
super();
this.x = x;
this.y = y;
}

public void setX(double x) {
this.x = x;
}

public void setY(double y) {
this.y = y;
}

public MyPoint()
{
this(0,0);

}
public double getX()
{
return x;
}

public double getY()
{
return y;
}

public double getDistance(MyPoint P)
{
return Math.sqrt(Math.pow(this.x-P.getX(), 2) + Math.pow(this.y-P.getY(), 2));
}

#### Questions Cloud

 How many grams na3po4 of will be needed : How many grams Na3PO4 of will be needed to produce 475 mL of a solution that has a concentration of Na+ ions of 0.900 M ? What mass of urea is produced per minute by this reaction : Ammonia gas at 223°C and 90. atm flows into a reactor at a rate of 550. L/min. Carbon dioxide at 223°C and 47 atm flows into the reactor at a rate of 600. L/min. What mass of urea is produced per minute by this reaction assuming 100% yield? The hydrogen atoms have been replaced by another substituent : Many common weak bases are derivatives of NH3, where one or more of the hydrogen atoms have been replaced by another substituent. According to social contract theory : According to social contract theory, the purpose of the state (or government) is to enforce essential rules of social living; however, social contract theorists make an exception for business because the greater good is best served when commercial tr.. A constructor that constructs a rectangle2d : A constructor that constructs a Rectangle2D with specified points as coordinates.A no-argument constructor that creates the rectangle with points (0, 0), (5, 5) and (0, 5) and Explain why triethylamine is a weaker base : Explain why triethylamine is a weaker base than dimethylamine or methylamine. Write a program to track hourly employee arrival departure : THE JAVA SOURCE CODEWILL AWARD AN ADDITIONAL 1,500 POINTS TO PERSON WITH THE BEST ANSWER (you will be directed to another one of my previous, unanswered questions.)A company hires you to write a program to track hourly employee arrival and departure .. What is the number of mole equivalents of h2 produced : what is the number of mole equivalents of H2 produced by the reaction of 1 mole equivalent of Mg (m) with H2SO4 (aq)? Moral to treat lawbreakers : According to your assigned reading, it is moral to treat lawbreakers who harm others and don't keep their agreements differently from citizens who abide by the law and social contract because

### Write a Review

#### Pros and cons of choosing two servers

Classify the two alternatives in terms of what type of application architecture they use. b. Outline the pros and cons of the two alternatives and make a recommendation to Fred about which is better.

#### Add the correct code to fill the matrix array with the value

Use the file below code and add the correct code to fill the matr2 array with the values that make it the matrix transpose of matr1. There are many examples on the Internet that show how to do this in C++ and what it should look like when it is corre..

#### Function odd_fill() that fills all integers between two poin

write a function odd_fill() that fills all integers between two pointers, first and last, with a sequence of odd integers: 1,3,5,7

#### Program to compute the total volume

Write a program to compute the total volume for a number of cylinders. A cylinder may have different values for height and radius.

#### Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

#### Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

#### Write song playlist class-object-oriented design principles

Write a song playlist class in C++ called "PlayList" using object-oriented design principles. The playlist should support the following ADT.The implementation should be based on an array of strings to store the song titles.

#### Write a program to crypt its input accordingly

Write a program to crypt its input according to a specified transformation scheme

#### Design a base class shape with virtual functions

Design a base class shape with virtual functions

#### We wish to process survey results

Suppose we wish to process survey results that are stored in a file. This exercise requires twoseparate programs. First, create a program that prompts the user for survey responses and outputseach response to a file

#### Brownian motion is a physical phenomenon

Brownian motion is a physical phenomenon which can be observed, for instance, when a small particle is immersed in a liquid.

#### Function declare that it can throw an ioexception

Every C++ function that performs file I/O will thus need to either declare that it can throw an IOException, or contain a try-catch-finally block to deal with it. Response?