logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Aditya PanchalMathematics
(5/5)

769 Answers

Hire Me
expert
Sethh PowellHistory
(4/5)

576 Answers

Hire Me
expert
Jaydon KeySocial sciences
(5/5)

982 Answers

Hire Me
expert
Milton BlahaEconomics
(5/5)

787 Answers

Hire Me
Others
(5/5)

create a new class called Point. A point is typically described by its geometric coordinates.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Problem Description: 

PART A: Creating a Point class.

 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. 

PART B: Creating a Line class. 

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. 

PART C: Driver / Client program. 

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]

(5/5)
Attachments:

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. ThisΒ  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

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

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme