7 thích 0 k thích
229 đã xem

Exercise 1

Using the file point.cpp (Click to download), add a member function print to the class Point so that it prints out coordinates as:

	(2, 3)

for a point with coordinates (2, 3). Test it in main().

Exercise 2

Write a definition of a class Rectangle using the Point class. A rectangle is specified by two corner points (bottom left and top right). The sides of the rectangle are parallel to the coordinate axes. The implementation of the class should be as follows: 

  • The private data members of the class include all 4 corner points of the rectangle.
  • There are two constructors: one takes two points as arguments and creates a rectangle with the first point as the bottom left corner and the second as the top right corner, the other (default) constructor creates a rectangle with the corners (0,0), (1,0), (0,1), (1,1). 
    Hint: use functions Set_X, Set_Y from the class Point to set the values of the corner points.
  • The print member function prints all 4 corners of the rectangle, using the member function print of the class Point.

Test the class Rectangle in main(), demonstrate that all member functions work as specified.

[Normal] Essay (Open question) - đã hỏi trong Introduction to Computer Programming I (C) bởi (12.1k điểm)
ID: 26000 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn

đã sửa bởi | 229 đã xem
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.134.51
©2016-2024

Những câu hỏi liên quan

0 thích 0 k thích
0 trả lời
[Normal] Coding (C++) - đã hỏi ngày 17 tháng 5 năm 2018 trong Introduction to Computer Programming II (C++)
ID: 52070 - Xem được từ: 2018-04-26 17:48 - Hiệu lực đến: Không giới hạn
| 121 đã xem
6 thích 0 k thích
0 trả lời
[Normal] Coding (C) - đã hỏi ngày 10 tháng 10 năm 2017 trong Introduction to Computer Programming I (C) bởi thopd (12.1k điểm)
ID: 25999 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 100 đã xem
12,783 câu hỏi
183,443 trả lời
172,219 bình luận
4,824 thành viên