Lab on C++ Classes

 

1.        For this project you will be building a new type lineType, as defined in Chapter 12, Programming Exercise # 12.  Program this with a header file, an implementation file and a .cpp file to test your lineType.

If you do not have the book available, the exercise can be found from google books by following this link (Right click the link and open in a new window):

http://books.google.com/books?id=jvBslGr-sxEC&pg=PA721&lpg=PA721&dq=line+in+standard+form+c%2B%2B+class+linetype&source=bl&ots=96we9qIWEi&sig=Tt5638eocsYi2dVuwzEMFYmNSNE&hl=en&ei=MleLTuqgFuLI0AG1_KjHBA&sa=X&oi=book_result&ct=result&resnum=1&ved=0CBoQ6AEwAA#v=onepage&q&f=false

Please note:  It will take  you some time to figure out how to program the intersection of two lines.  Do everything else in Exercise 12 first. You will want to figure it out by hand on two sample lines (say  a1x + b1y = c1, and a2x + b2y = c2) to get the formulas for the coordinates of the intersecting points.  You can use http://zonalandeducation.com/mmts/intersections/intersectionOfTwoLines1/intersectionOfTwoLines1.html

to help with the math. This site changes the line formula to the form y = mx + b where m is the slope and b is the y intercept to do the math, but you can do it either way.

 

2.        To illustrate information hiding and ADTs this part of the project should not be done until Part 1 is totally complete.  You will be given a data file with a few sets of four lines.  [click here for datafile] Each of those sets of lines (if graphed in a Cartesian plane) create a quadrilateral  [4 sided shape].  (To make this program easier, the first two lines in the set will be opposite each other in the quadrilateral, and the second two lines in the set will be opposite each other in the quadrilateral.) Write a program that uses your header file and class that was defined for Part 1 of this assignment to determine if each  quadrilateral in the data file is a parallelogram, trapezoid or rectangle (for EXTRA CREDIT:  rhombus or square!).

 

3.        MORE EXTRA CREDIT:   Something to think about:  Suppose you are given a set of four lines, but are not guaranteed that they would form a quadrilateral. (For example, all four lines might be parallel to each other!)  Can you write a program that takes any set of four lines, and specifies IF a quadrilateral is created, and what type of quadrilateral it is?!?