Computers and Technology

Task-1: In Cartesian coordinate system, a linear equation represents a line passing through two discrete points, such as, (1, 1) and (4, 2), respectively. Hence, one can easily describe the “point” object with a C++ class as given below. class Point {
public:
Point(); //default constructor
Point(…); //parameterized constructor
Point(…); //copy constructor
~Point(); //destructor
… set_x(…); //some member functions
… set_y(…);
… get_x(…);
… get_y(…);
… print(); //prints the point object using some format, e. g., [1,2]
private:
int x, y; //data members
};
On the other hand, in order to create a “line” object, one can think of executing data composition technique where the line object is composed of two discrete point objects. Hence, one can write the following:
class Line {
public:
Line(); //default constructor
Line(…); //parameterized constructor
Line(…); //copy constructor
~Line(); //destructor
… set_point1(…); //some member functions
… set_point2(…);
… get_slope(); //calculates the slope value
… print(); //prints the line object using some format
//e. g., A line passing through [2,2] and [4,4] with slope = 1.0
private:
Point p1, p2; //data composition!
};
a. Write definitions of the member functions listed above.
b. Rewrite the program by separating the implementation file from the interface using a header file.
 Provide a driver program to test each implementation.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 22:40, Bgreene2377
In this lab, you complete a python program that calculates an employee's annual bonus. input is an employee's first name, last name, salary, and numeric performance rating. if the rating is 1, 2, or 3, the bonus rate used is .25, .15, or .1 respectively. if the rating is 4 or higher, the rate is 0. the employee bonus is calculated by multiplying the bonus rate by the annual salary.
Answers: 1
image
Computers and Technology, 23.06.2019 23:30, cam961
What are "open-loop" and "closed-loop" systems
Answers: 1
image
Computers and Technology, 24.06.2019 12:30, tragicteekaay
Nikki sent flyers in the mail to all houses within the city limits promoting her computer repair service what type of promotion is this and example of
Answers: 1
image
Computers and Technology, 24.06.2019 13:00, giulissaf
Append and make table queries are called queries. select complex simple action i think action
Answers: 1
Do you know the correct answer?
Task-1: In Cartesian coordinate system, a linear equation represents a line passing through two disc...

Questions in other subjects:

Konu
Mathematics, 18.11.2020 07:30