Week8_Assignment - set method that accepts four sets of...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Assignment for Chapter 8 Create a class Rectangle . The class has attributes length and width , each of which defaults to 1. It has methods that calculate the perimeter and the area of the rectangle. It has set and get methods for both length and width . The set methods should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0. Write a “driver” program to test the rectangle class. It should instantiate the rectangle, and allows the user to set and get attributes about the Rectangle . Extra Credit: Extend the rectangle class adding additional functionality. Call your extended class NewRectangle . This class stores only the Cartesian coordinates of the four corners of the rectangle. The constructor calls a
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: set method that accepts four sets of coordinates and verifies that each of these is in the first quadrant with no single x-or y-coordinate larger than 20.0. The set method also verifies that the supplied coordinates do, in fact, specify a rectangle. Provide methods to calculate the length , width , perimeter , and area . The length is the larger of the two dimensions. Include a predicate method isSquare which determines whether the rectangle is a square. Write a program to test class NewRectangle . Remember, for extra credit, you are on your own. Don’t expect help from the tutors. Also, if you are able to complete only portions of this extra credit, I will give you a proportion of extra credit points....
View Full Document

This note was uploaded on 10/12/2009 for the course CS 120 taught by Professor Robertdependahl during the Fall '09 term at Santa Barbara City.

Ask a homework question - tutors are online