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));
}
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
|