Instruction
Fairly short java program using multiple simple classes and an interactive driver class. You will need to know how to write classes with constructors, setter and getters, toString methods and be familiar with concepts like inheritance and proper program syntax.
User_7084 added on 09/28/15 at 06:53 AM (PST):
Produce a set of classes to represent shapes.
Produce five classes:
PolyShape: This class represents polygons with an instance data variable int[] sideLengths. This class should have a method getPerimeter() that takes no parameters and returns an integer.
Quadrilateral: This class represents polygons with four sides.
Rectangle: This class should have a method getArea() that takes no parameters and retuns an int.
Square:
Triangle: This class represents polygons with three sides. This class should have methods isIsoceles and is Equilateral that returns a boolean if two or three (respectively) sides are of equal length.
In each class include: one or more constructors, setters and getters, a toString method that returns the number of sides, the side lengths and all possible names for a shape. For example, a square might print "I have four sides of length 3, 3, 3, and 3. I am a polygon. I am a rectangle. I am a square."
When designing your classes, consider the following: Think about what the parent-shild relationship should be between these classes. Think about what information should be sent as parameters and what information can be hard-coded (using constants) into a class. Move common code as high up in the hierarchy as possible. Use super whenever possible. Follow appropriate naming and style conventions. Follow good principals of object-oriented design and inheritance.
Write an interactive driver program: The program allows the user to repeatedly create a shape by entering its dimensions. Note: you do not need to handle negative or decimal values in the driver program. You can assume the user will enter positive integer input only. The program prints the object created and the perimeter, area(if applicable), and isIsoceles/isEquilateral(if applicable) methods. Your classes should work with your driver program but they should be designed to work with other drivers too(Think carefully about what kind of checks should go into the driver program and what kind of checks should go into the individual classes. Remember that the object-oriented design states that each object should be in charge of its own information.)
Bonus Functionality (only do this if you want to)
Print out a text based graphic of the shape created when the user creates a square or a rectangle. For example a 4x5 rectangle might print:
*****
* *
* *
*****
Comment major functions of code