You are on page 1of 3

Workshop 2

Part 1.
1. Write a class called Point is designed as shown in the following class
diagram. It contains:
• Two private instance variables: x (of the type float) and y (of the type
double), with default 0.0 and 0.0, respectively.
• Two overloaded constructors: a default constructor with no argument, and
a constructor that takes 2 float arguments for x coordinate and y coordinate.
• Two public methods: getX() and getY(), which return the x coordinate and
the y coordinate of this instance, respectively.

Implement Point class based on the definition.


2. Write a class TestPoint contains content to test methods in Point
Part 2.
1. Implement the Triangle class is defined as the following figure.

2. Write a class TestTriAngle contains content to test methods in Point

Xưởng 2
Phần 1.
1. Viết một lớp có tên là Point được thiết kế như sơ đồ lớp sau. Nó chứa:
• Hai biến thể hiện riêng: x (kiểu float) và y (kiểu double), với giá trị mặc
định lần lượt là 0.0 và 0.0.
• Hai hàm tạo quá tải: một hàm tạo mặc định không có đối số và một hàm
tạo nhận 2 đối số float cho tọa độ x và tọa độ y.
• Hai phương thức công khai: getX() và getY(), lần lượt trả về tọa độ x và
tọa độ y của trường hợp này.
Thực hiện lớp Point dựa trên định nghĩa.
2. Viết class TestPoint chứa nội dung test các phương thức trong Point
Phần 2.
1. Thực hiện lớp Triangle được định nghĩa như hình sau.
2. Viết class TestTriAngle chứa nội dung test các phương thức trong Point

You might also like