In this first part of this problem, it is required to create a new class called Point. A point is typically described by its geometric coordinates. In this problem, a two-dimensional cartesian coordinate system is considered. Consequently, a point, say P, in such a system is defined by its abscissa x and ordinate y. Following the definition of a generic point’s coordinates, write accessor and mutator methods, namely, getX(), getY(), setX(), setY(), getXY(), setXY(). Note that the getXY() function will return both the abscissa and ordinate of a point. Also, the setXY() takes two parameters as inputs being the new abscissa and new ordinate of the point. This being done, write a function called distance() that takes a point object, say secondPoint, as a parameter and computes the cartesian distance between the current point and secondPoint. Finally, an str () method will print out the x and y coordinates of a point in an appropriate string.
Here, it is required to use the Point class in order to create a new Line class. Recall, a Line, say l, is described by the two points, say p1 and p2 that it goes through. It also has an equation of the form π¦ = π π₯ + ππ where π is the slope and ππ is the intercept. In addition, in this problem, a line will also have one additional property being the range [π₯π; π₯π’] over which it can be plotted where π₯π and π₯π’ are the lower and upper bounds delimiting this range. On the next page is an incomplete skeleton of the class Line which you are required to complete. The description is below:
1. The constructor function takes two input Point parameters p1 and p2 and constructs a new Line object l. Throughout the construction, given the two points, the constructor will resort to a Helper Function called computeEquation() whose description is below.
2. The helper function computeEquation() takes the newly constructed Line object l as a parameter and computes its equation which it returns as a string eq to be stored in the variable e of the Line object l. Throughout the computation of the equation, the computeEquation() function is given the authority to mutate the respective slope and intercept variables s and iof the object l and store in them their corresponding values which it computes using the coordinates of the points p1 and p2 above. Here, note that given two points π1(π₯1, π¦1) and π2(π₯2, π¦2), the slope and intercept of the line passing through them are: π¦2 − π¦1 π =π₯2− π₯1; ππ = π¦1 − π ⋅ π₯1
Following the computation of s and i above, special care is due when creating the string eq in a professional manner. That is if π = 0 and ππ ≠ 0 the string eq should contain ‘y= i’ (where i is replaced by its value). Alternatively, if π ≠ 0 and ππ = 0 then the string eq should only contain ‘y = sx’ (where s is replaced by its value). In addition, if π = 1, then eq should contain ‘y = x + i’ (where i is replaced by its value).
3. The function setRange() takes a newRange string of the form “xl:ss:xu” (where xl and xu are defined above and ss is the step) as a parameter and mutates the range of l accordingly.
4. A function plotLine() that is required to professionally plot and annotate the graph of the plotted line in such a way that the π¦-axis must be labelled with the exact line’s equation that was determined by the computeEquation() function defined above and the π₯-axis must carry the label ‘x’. The line’s width must be set to 2.0. For this reason, the matplotlib package of PYTHON must be imported together with the numpy package using the import command at the beginning of program’s file. Note that these packages need to be installed first if they are not. Then, appropriate research is required to determine how to generate the line plot using the following functions from these packages as follows:
a. linspace() from numpy
b. pyplot.plot(), pyplot.xlabel(), pyplot.ylabel(), pyplot.setp() from matplotlib.
5. The str () method which return a meaningful string containing all the information about the newly created line. A sample output of the str () method once called using an appropriate print()command from the client program is given on the next page as well.
In this part, it is required to create a client program to test the functionality of the above classes and plot the line.
Sample output for the str() and plotline() functions of the Line Class:
Point 1: (1, 2)
Point 2: (3, 4) Equation: y = x + 1 Range: [0; 10]
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme