Implement the class and write a test program that creates a

Assignment Help JAVA Programming
Reference no: EM131193373

Define the MyRectangle2D class that contains: 

  • Two double data fields named x and y that specify the center of the rectangle with get and set methods. (Assume that the rectangle sides are parallel to the x- or y-axes.) 
  • The data fields width and height with get and set methods. 
  • A no-arg constructor that creates a default rectangle with (0, 0) for (x, y) and 1 for both width and height. 
  • A constructor that creates a rectangle with specified x, y, width, and height. 
  • A method getArea() that returns the area of the rectangle. ? A method getPerimeter() that returns the perimeter of the rectangle. 
  • A method contains (double x, double y) that returns true if the specified point (x, y) is inside the rectangle. See Figure (a) 
  • A method contains (Rectangle2D r) that returns true if the specified rectangle is inside this rectangle. See Figure (b) 
  • A method overlaps (Rectangle2D r) that returns true if the specified rectangle overlaps with this rectangle. See Figure (c)

920_Untitled picture.png

Implement the class and write a test program that creates a Rectangle2D object r1 (new Rectangle2D (2, 2, 5.5, 4.9)), displays its area and perimeter, and displays the results of r1.contains (3, 3), r1.contains (new Rectangle2D (4, 5, 10.5, 3.2)), and r1.overlaps (new Rectangle2D (3, 5, 2.3, 5.4)).

Please note, your implementation will be tested with other test cases too.

Reference no: EM131193373

Questions Cloud

Suppose the transmitter technology changes : Suppose the transmitter technology changes, and it becomes economicalfor an individual household. The trading city will [grow, shrink, disappear]
Do you think teams in the hospitality industry are effective : The success of the hospitality industry is especially dependent on teamwork. In order to provide exceptional customer service, team members need to have the same focus and goals. Forming a team can be a tedious process. Identify the designations and ..
Determine the angle u corresponding to equilibrium : A uniform rod AB of length 2R rests inside a hemispherical bowl of radius R as shown. Neglecting friction, determine the angle u corresponding to equilibrium.
Prepare journal entries for each transaction : Prepare journal entries for each transaction and post each transaction to the appropriate ledger accounts (use T- account format) - Prepare trial balance dated March 31,2016
Implement the class and write a test program that creates a : Implement the class and write a test program that creates a Rectangle2D object r1 (new Rectangle2D (2, 2, 5.5, 4.9)), displays its area and perimeter, and displays the results of r1.contains (3, 3), r1.contains (new Rectangle2D (4, 5, 10.5, 3.2)), an..
Why should organization consider utilizing systems analysis : Why should an organization consider utilizing a systems analysis and design methodology when building a new system instead of building a system in any which way that seems to be fast and simple? What value is provided by using an engineering approach..
Fiscal austerity policy : Why did many EU government use fiscal austerity policy in 2010-2015? What was the impact of this policy on business in these countries.
What are the short and long term benefits : Do you are the U.S government continue with free trades program (NAFTA)? what is the benefit for Americans? What are the short and long term benefits?
Choices in industrial and organizational psychology : Based on outside resources (journals, websites, interviews, etc.) what are three possible career choices in Industrial and Organizational Psychology?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Complete the twins() method

Complete the twins() method, which takes an integer argument n and prints all the sets of twin primes that are less than n, one pair per line

  Reverses a three digit number producing a result

Hint.First write a static method that reverses a three digit number producing a result as described above, and test it directly from the main method. Your static method should have the following signature.

  Java program for input of numbers only

Edit Java program for input of numbers only. If the user inputs a letter the program must abort with a messegae like "Program aborted by user". Please explain the code.

  Solve computer science java validation problem

Computer Science, Operating Systems - Year 1Description:java validationProblem: Using NetBeans 7.2

  Write a method called add uneven arrays

Write a method called addUnevenArrays that takes two arrays, a and b, and returns a new array, c, with alength that is the maximum of the lengths of a and b. Each c[i] is the sum of the corresponding elementsof a and b if both elements exist.

  Write a method called makerow

Write a method called makeRow that is passed two arguments: an int and a String. It returns a String containing n copies of s, concatenated in a row. For instance, if we call the method with makeRow(5, "*"), the method returns *****.

  Write a java program that finds the temperature

Write a JAVA program that finds the temperature that is the same in both Celsius and Fahrenheit

  Implement a class quiz

Implement a class Quiz that implements the Measurable interface.

  Write an employee payroll program

Write an employee payroll program that uses polymorphism to calculate and print the weekly payroll for your company. There are three types of employees - hourly, salaried, and salaried plus commission. Each type of employee gets paid using a diffe..

  Encrypt and decrypt the message using caesar cipher

Encrypt and decrypt the message using Caesar cipher

  Compare swing java gui components to awt components

Compare Swing Java GUI components to AWT components. Explain at least one way the components are similar and at least one way they are different.

  Implement a shopping cart class with user interface

project will be to implement a shopping cart class with user interface (UI) that contains main() in Net Beans. The UI class will be used to perform user input/output and to invoke the appropriate methods of shopping cart class. When your program star..

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