Pages

Wednesday, December 21, 2011

Object Oriented Program

If you order your cheap custom essays from our custom writing service you will receive a perfectly written assignment on Object Oriented Program. What we need from you is to provide us with your detailed paper instructions for our experienced writers to follow all of your specific writing requirements. Specify your order details, state the exact number of pages required and our custom writing professionals will deliver the best quality Object Oriented Program paper right on time.

Out staff of freelance writers includes over 120 experts proficient in Object Oriented Program, therefore you can rest assured that your assignment will be handled by only top rated specialists. Order your Object Oriented Program paper at affordable prices with LivePaperHelp.com!



For a language to be classified as object-oriented it must also provide inheritance and polymorphism. Inheritance is the capability to derive one class from another. A derived class is a completely new data type that incorporates all of the data member and member functions of the original class with any new data and functions members unique to itself. The class used as the basis for the derived type is referred to as the base or parent class and the derived data type is referred to as the derived or child class.


A derived class has the same form as any other class in that it consists of both a declaration and an implementation. The only difference is in the first line of the declaration section. For a derived class this line is extended to include an access specification and a base class name has the form


class derived-class-name class-access base-class-name


To illustrate the concept of inheritance we will derive a Box class from a base class Rectangle. The following program listing is the implementation of the two classes.


Help with essay on Object Oriented Program

cheap essay writing service



#include iostream.h


#include math.h


const double PI = .0 asin(1.0);


class Circle


{ protected


double radius;


public


Circle(double = 1.0);


double area( );


};


CircleCircle(double r)


{ radius = r; }


double Circlearea( )


{ return (PIradiusradius); }


class Cylinder public Circle


{ protected


double length;


public


Cylinder (double r = 1.0, double l = 1.0);


double area ( );


};


CylinderCylinder(double r, double l )


{


radius = r;


length = l;


}


double Cylinderarea( )


{ return (lengthCirclearea()); }


int main ( )


{ Circle circle_1, circle_ ();


Cylinder cylinder_1(,4);


cout

The area of circle_1 is circle_1.area();


cout

The area of circle_ is circle_.area();


cout

The volume of cylinder_1 is


cylinder_1.area();


circle_1 = cylinder_1;


cout

The area of circle_1 is now


circle_1.area() endl endl;


return 0;


}


Run the above program and try to understand the concept behind it.


Q1. Create a base class named Point that consists of an x and y coordinates as data member. From this class derive a class named Circle having an additional data member named radius. For this derived class the x and y data members represent the center coordinates of a circle. The function members of the base class should consists of a constructor, an area function named area() that return zero, and a distance() function that returns the distance between a point and the origin. Also, the derived class should have a constructor and an override function named area() that returns the area of a circle. Include the class implementation in a working C++ program.


Q. Create a base class named Rectangle that contains length and width data members. From this class derive a class named Box having additional data members named depth. The function members of the base Rectangle class should consist of a constructor and an area function. The derived Box class should have a constructor, a volume function, and an override function named area that returns the surface area of the box. Include the class constructed above in a working C++ program.


Q. Create a class named Investment that holds data about initialAmount, currentValue, and profit. Investment class has member functions setData() to set the data for the initialAmount and currentValue. Profit is calculated and set as the difference of the above two variables and showData() to show the data of all the investment details.


Create another class called House that contains data members for the street address of a House(address), square feet of the house(squareFeet), and number of bed rooms(numBedrooms). This class also has member functions setData() to set the data for the data members and showData() to display the data of house information.


Derive a class named HouseAnInvestment from both Investment and House class. It has a constructor that takes the five arguments. In this constructor, address, squareFeet, and numBedrooms are passed to the House class setData() function and intialAmount, and currentValue are passed to the Investment class setData() function. Also, the derived class should have showHouse() function that employs its own specialized code and uses the existing, inherited showData() functions from the Investment and House classes. This function distinguishes between a good and bad investment by the presence of profit. Add a main() that declares objects of HouseAnInvestment class. One object is to show the investment is good and another is to show the investment is bad. Include the all the classes and functions in a C++ program.


Typical Output


Investment Data on House


Investment Current Value RM 15


Investment Initial Value RM 150000


Profit RM


The house at 4 BANDAR DAMANSARA has bedrooms and 000 square feet of living area.


This house was a good investment.


Investment Current Value RM 1500


Investment Initial Value RM 10000


Profit RM -500 (Loss)


The house at 4 Jalan Gombak has bedrooms and 100 square feet of living area.


This house was a bad investment.





Please note that this sample paper on Object Oriented Program is for your review only. In order to eliminate any of the plagiarism issues, it is highly recommended that you do not use it for you own writing purposes. In case you experience difficulties with writing a well structured and accurately composed paper on Object Oriented Program, we are here to assist you. Your cheap research papers on Object Oriented Program will be written from scratch, so you do not have to worry about its originality.

Order your authentic assignment from LivePaperHelp.com and you will be amazed at how easy it is to complete a quality custom paper within the shortest time possible!



0 comments:

Post a Comment