How to create a class in java that contains get and set methods for the double variables x,y,height,width where x and y represent the center point of your rectangle and width and height epresent the width and height of your rectangle, a no argument constructor that sets x to 0, y to 0, width to 1, and height to 1 that output your name, a constructor that has x, y, width, and height input parameters, for example If the x or y input parameters are less than 0.0, set them to be 0.0 and If the width or height input parameters are less than 1.0, set them to be 1.0, a method called myTop that returns the y coordinate of the top of the rectangle (y + 0.5*height), a method called myBottom that returns the y coordinate of the bottom of the rectangle (y – 0.5*height), a method called myLeft that returns the x coordinate of the left side of the rectangle (x – 0.5*width), a method called myRight that returns the x coordinate of the left side of the rectangle (x + 0.5*width), a method getArea that returns the area of the rectangle (width * height), a method called getPerimeter that returns the perimeter of the rectangle (2 * width + 2 * height), and a method called contains(double inX, double inY) that returns true if the point (inX,inY) is inside the rectangle and false otherwise, then test the class by create a class with a main method that creates instances of your class and calling all the constructors and method? For example, assume a rectangle was created with x=2.0, y=1.0, width=1.0, and height=2.0 getX would return 2.0 getY would return 1.0 getWidth would return 1.0 getHeight would return 2.0 myTop would return 2.0 myBottom would return 0.0 myLeft would return 1.5 myRight would return 2.5 getArea would return 2.0 getPerimeter would return 6.0 contains(1.75,0.9) would return true contains(2.5,2.25) would return false

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

How to create a class in java that contains get and set methods for the double variables x,y,height,width where x and y represent the center point of your rectangle and width and height epresent the width and height of your rectangle, a no argument constructor that sets x to 0, y to 0, width to 1, and height to 1 that output your name, a constructor that has x, y, width, and height input parameters, for example If the x or y input parameters are less than 0.0, set them to be 0.0 and If the width or height input parameters are less than 1.0, set them to be 1.0, a method called myTop that returns the y coordinate of the top of the rectangle (y + 0.5*height), a method called myBottom that returns the y coordinate of the bottom of the rectangle (y – 0.5*height), a method called myLeft that returns the x coordinate of the left side of the rectangle (x – 0.5*width), a method called myRight that returns the x coordinate of the left side of the rectangle (x + 0.5*width), a method getArea that returns the area of the rectangle (width * height), a method called getPerimeter that returns the perimeter of the rectangle (2 * width + 2 * height), and a method called contains(double inX, double inY) that returns true if the point (inX,inY) is inside the rectangle and false otherwise, then test the class by create a class with a main method that creates instances of your class and calling all the constructors and method?

For example, assume a rectangle was created with x=2.0, y=1.0, width=1.0, and height=2.0

getX would return 2.0

getY would return 1.0

getWidth would return 1.0

getHeight would return 2.0

myTop would return 2.0

myBottom would return 0.0

myLeft would return 1.5

myRight would return 2.5

getArea would return 2.0

getPerimeter would return 6.0

contains(1.75,0.9) would return true

contains(2.5,2.25) would return false

 
 
 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 5 images

Blurred answer
Knowledge Booster
void method
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education