0% found this document useful (0 votes)
31 views1 page

Project - Lab

The document outlines a lab project assignment to design a geometric shapes program using Java. Students are instructed to create classes to represent points, triangles, rectangles, and pentagons. The point class should include methods to set and get x and y coordinates. Triangle and rectangle classes should store points in arrays and include methods to set points, get areas and perimeters. A test class with a main method should create objects and test the shape classes. UML diagrams must also be included.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views1 page

Project - Lab

The document outlines a lab project assignment to design a geometric shapes program using Java. Students are instructed to create classes to represent points, triangles, rectangles, and pentagons. The point class should include methods to set and get x and y coordinates. Triangle and rectangle classes should store points in arrays and include methods to set points, get areas and perimeters. A test class with a main method should create objects and test the shape classes. UML diagrams must also be included.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Java Programming

Lab Project: (only for Lab students)

The last time for submission is 20-6-2023

Design a small project using arrays and object-oriented techniques using Java. The project will be
used to represent the geometric shapes that can do the following tasks.

1- Create a class called “point” which includes two variables x and y and has the following methods:
-
a. A constructor to initialize x and y by 0.
b. A constructor to initialize x and y by two input parameters.
c. Setx to change the value of x.
d. Sety to change the value of y.
e. Print point, the output should be like this (1,3).
f. DistanceToPoint to measure the distance between this point and another point.
2- Create a class called “Triangle” that includes 3 points in an array. It should have the following
methods:
a. A constructor to initialize the triangle points.
b. SetPoints to change the three points of the triangle.
c. GetPoints to get the array that includes the points.
d. PrintPoints print the three points as (0,0) -> (1,4) -> (3,2)
e. GetArea to compute and return the triangle area.
f. GetPerimeter to compute and return the perimeter of the triangle.
3- Create a class called “Rectangle” that includes 4 points in an array. It should have the following
methods:
a. A constructor to initialize the Rectangle points.
b. SetPoints to change the four points of the triangle.
c. GetPoints to get the array that includes the points.
d. PrintPoints print the three points as (0,0) -> (1,0) -> (1,1) -> (0,1)
e. GetArea to compute and return the area.
f. GetPerimeter to compute and return the perimeter.
4- Create another class called pentagonal shape to represent a shape with five sides and choose by
yourself five different functions.
5- Create a set of static variables and methods to count the number of created objects from each
shape.
6- Use suitable modifiers for variables and methods based on what we studied in the course.
7- Create a new class that includes a main method to create some objects from each class and test
the methods and classes.
8- Try to handle all types of errors that may occur from the user.
9- You should use comments to explain every function.
10- Your program should be friendly and easy to use.
11- Draw the UML diagrams for the created classes using any online tool and attach them to the
project folder as images.

You might also like