subject

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.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:50
In this lab, you complete a prewritten c++ program for a carpenter who creates personalized house signs. the program is supposed to compute the price of any sign a customer orders, based on the following facts: the charge for all signs is a minimum of $35.00. the first five letters or numbers are included in the minimum charge; there is a $4 charge for each additional character. if the sign is made of oak, add $20.00. no charge is added for pine. black or white characters are included in the minimum charge; there is an additional $15 charge for gold-leaf lettering. instructions ensure the file named housesign.cppis open in the code editor. you need to declare variables for the following, and initialize them where specified: a variable for the cost of the sign initialized to 0.00 (charge). a variable for the number of characters initialized to 8 (numchars). a variable for the color of the characters initialized to "gold" (color). a variable for the wood type initialized to "oak" (woodtype). write the rest of the program using assignment statements and ifstatements as appropriate. the output statements are written for you. execute the program by clicking the run button. your output should be: the charge for this sign is $82. this is the code, // housesign.cpp - this program calculates prices for custom made signs. #include #include using namespace std; int main() { // this is the work done in the housekeeping() function // declare and initialize variables here // charge for this sign // color of characters in sign // number of characters in sign // type of wood // this is the work done in the detailloop() function // write assignment and if statements here // this is the work done in the endofjob() function // output charge for this sign cout < < "the charge for this sign is $" < < charge < < endl; return(0); }
Answers: 1
question
Computers and Technology, 22.06.2019 11:40
Pthreads programming: create and terminate a thread write a c++ program that creates a thread. the main will display a message “hello world from the main”. the main will create a thread that will display a message “hello world from the thread” and then terminates with a call to pthread_exit()
Answers: 3
question
Computers and Technology, 22.06.2019 13:00
Which part of the cpu accepts data?
Answers: 1
question
Computers and Technology, 23.06.2019 21:30
Write a fragment of code that reads in strings from standard input, until end-of-file and prints to standard output the largest value. you may assume there is at least one value. (cascading/streaming logic, basic string processing)
Answers: 3
You know the right answer?
Task-1: In Cartesian coordinate system, a linear equation represents a line passing through two disc...
Questions
question
History, 04.03.2021 23:10
question
Geography, 04.03.2021 23:10
question
Mathematics, 04.03.2021 23:10
question
Mathematics, 04.03.2021 23:10
Questions on the website: 13722359