Beruflich Dokumente
Kultur Dokumente
1. Create a class Point. Objects of a point have an x and y coordinate. A point can be moved given a new x
and y coordinate. The default coordinate of a point is the origin (0,0).
2. Create a class Shape. Shapes are composed of different points*. Each shape also has a color (String)
and a shape ID (int). The following operations can be done on a shape:
TranslateX
- The shape will be moved +/- units along the X-axis
TranslateY
- The shape will be moved +/- units along the Y-axis
Scale
- The shape will increase/decrease in size by a given factor.
ex. scale by 2 means shape will increase its size by 2.
scale by 0.5 means shape will decrease its size by half.
scale by 1 means it will not change its size.
Rotate
- The shape will rotate by a certain number of degrees in clockwise or
counter-clockwise direction.
ex. rotate by +45 means shape will rotate 45deg clockwise.
rotate by -270 means shape will rotate 90deg counter-clockwise
computeArea
- This method returns the area of the shape.
Add necessary getter methods for a shape. Add a counter to be able to keep track of the number of shapes
created.
3. Create a class Triangle. A Triangle has 3 points and a counter that keeps track of the number of
triangles created.
4. Create a class Quadrilateral. A Quadrilateral has 4 points and a counter that keeps track of the
number of quadrilaterals created.
5. Create a class Circle. A circle only stores one point (the center). From the center, it will be able to
construct itself using its radius.
6. Create a class ShapeTest. This class contains the main method that allows the user to do the following:
a. Create a Shape
Allows the user to create either a triangle, square, or circle.
Once a shape is selected, it asks the user for the necessary data:
for a triangle: 3 points
for a quadrilateral: 4 points
for a circle: center + radius
Each shape is assigned a shape ID for reference. The shape ID is unique and is assigned
incrementally.
b. Delete a Shape
This allows the user to delete a specific shape (by entering the shape ID or all the shapes.
Deletion of shapes does not affect the next shape ID to be assigned to a newly created shape.
Total Shapes: 15
h. Display Shape Details
This feature displays the details of one shape or all shapes. If only one shape’s details will
be displayed, the user has to enter the shape ID.
The details of a shape should be displayed using the following format:
<Shape ID><TAB><Shape><TAB><List of point coordinates>
If the shape is a circle, follow the following format:
<Shape ID><TAB>CIRCLE<TAB> <Center coordinate><SPACE><radius>
1 CIRCLE (0,0) 3
2 TRIANGLE (1,1) (1,0) (0,1)
5 QUADRILATERAL (5,3) (7,1) (6,-4) (-2,0)
BONUS:
i. Rotate all Shapes
The user enters the number of degrees the shapes will be rotating. Note that a Circle does
not need to rotate.
Deadline: Oct. 18 (MW classes) and Oct. 19 (TH classes) first 5 minutes of the class.
Deliverables:
1. Documentation (printout) of the project will be placed in a properly-labeled (project name: MiniMP1_PointShape, full name
and section, term and AY) brown envelope. Documentation includes:
a. UML Class Diagram
b. Source codes
c. List of all files and corresponding directories in the CD (table with two columns: filename and directory
2. Source code (printout) must have internal documentations as well. You may use javadoc comments or usual comments for your
classes and methods. Describe each class and its method and their parameters. Follow prescribed software development standards. In
BlueJ, create a project with the name: MiniMP1_PointShape_<lastname>_<firstname>. Make sure you fill up the information
in README.TXT. Organize your files in packages as needed.
3. Burn your source codes (*.java), compiled classes (*.class), executable file (*.jar), javadoc (if there’s any; *.html), documentation
(*.doc), and other necessary files (graphics, output files, etc) on a properly-labeled (project name: MiniMP1_PointShape, full
name and section, term and AY) CD with case and place it in the same brown envelope.