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

Reference no: EM13165010

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

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  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 a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

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

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd