Question 1) Define a class for Rectangle objects defined by two points, the top-left and bottom right corners of the rectangle. Include a constructor to copy a rectangle, a method to return a rectangle object that encloses the current object and the rectangle passed as an argument and the method to display the defining points of a rectangle. Test the class by creating four rectangles and combining these cumulatively to end up with a rectangle enclosing them all. Output the defining points of all the rectangles you create.


Question2) Define a class mcmLength, to represent a length measured in meters, centimeters, and millimeters and stored as integers. Include methods to add and subtract objects, to multiply and divide an object by an integer value, to calculate an area resulting from the product of two objects, and to compare objects. Include constructors that accept three arguments ( meter, centimeters and millimeters) one argument in millimeters; one double argument in cm; and no arguments, which creates an object with the length zero. Check the class by creating some objects and test the class operations.

We want you to learn, so we're not going to just do it for you. Give it a try, and post your code and any questions you have. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.