Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

Object Oriented Paradigms Assignment

Assignment #: Total Questions: Total Marks: Passing Marks: Topics in this Assignment: Submission Date: Note: Assignment Detail 2 4 40 20 Classes, constructor, getter & setter methods 4th October 2011 (Tuesday) Code should be Proper commented. Code should be Proper indented otherwise you will loss 10 PAGE marks. Copied Assignments will be marked Zero. No Late Submissions will be entertained Oopf10@yahoo.com OOP ASSIGNMENT

Email: Subject:

Question 1: Create a Class point with two variables xpoint and ypoint. (10 points)
class Point{ int x_position; int y_position; public: point(); int getXpos(); int getYpos(); void setXpos(int); void setYpos(int); }

Question 2: Create a Class line. Write a function length of this line class to calculate the length of line. Show work in main method (10 points)
class Line{ int x_position1; int y_position1; int x_position2; int y_position2; public: Line(); Line(int, int,int,int); int getXpos1(); int getYpos1(); int getXpos2(); int getYpos2(); void setXpos1(int); void setYpos1(int); void setXpos2(int); void setYpos2(int); void setPoint1(int, int); void setPoint2(int,int); int getLength(); }

Question 3: Write a complete Class called Triangle, which represents a mathematical triangle. (10 points)
The structure has the following instance variables: 1. base double value representing the base of a triangle 2. height double value representing the height of the rectangle The structure has the following methods 1. Constructor - This constructor takes two formal parameters representing the base and height respectively. The parameters are PAGE used to initialize the corresponding instance variables. 2. getBase - This method returns the base value. 3. getHeight - This method returns the height value. 4. setBase - This method updates the base value with the single parameter. 5. setHeight - This method updates the height value with the single parameter. 6. Area - This is a static method that takes as formal parameter a Triangle reference and returns a double representing the area of the triangle.

Question 4: Answer the following Questions with at least two examples. (20 points)
1. What is Function Overloading? (5 points) 2. What is Default Argument Values? (5 points)

You might also like