Save 56% on Assignment Crafted by Human Writers

OFFER! Save 56% on Assignment Crafted by Human Writers

Search
Listening..

Concept Of Object Oriented Programming System Sample

University: The University of Manchester

  • Unit No: 5
  • Level: High school
  • Pages: 13 / Words 3229
  • Paper Type: Assignment
  • Course Code: N/A
  • Downloads: 3084

Introduction of computer programming language

A computer programming is a process that helps in developing and implementing various sets of commands to enable a computer to do definite task. It involves various tasks like analysis, understanding and solving the problems. In modern era, programming is considered as a crucial concept due to increase in corporate dependency over the computer (Armstrong, 2006).The groups of languages which are utilized to create such instruction sets are known as Programming Languages. Programming languages â€"¹Ã¢â‚¬"¹creates several programs that control the performance of the machine, to express algorithms accurately, or as any form of human communication are assigned. It helps in innovating a technology which is used to drive the World (Balagurusamy, 2007).

Understanding of Object Oriented Programming

Differences between Procedural and Object Oriented Programming

In Procedural Programming the code is organized into minute Procedures which are utilized in modification of data. Procedures are also recognized as functions. These functions normally receive various inputs to process some actions, and then consequently result in generating certain outcome. If at all possible functions would behave as "black boxes" where input data goes in and output data comes. o creates a step by step program that manages the application through a series of instructions. Each command is executed in a pre determined order while its focus is on development of application; tiny interest is shown to data which are combined through several functions (Bittencourt, 2000). On the other hand, Object-Oriented programming is flexible in nature. Each program is made up of many entities which are termed as objects (Derdour and et al., 2012). Objects become the basic component and constitute behavior or a precise function is associated with them. In such manner the data structure serves as kind of object which consists of data and methods (Farrell, 2008).

A+ Grades @Affordable Prices! We deliver all academic papers from dissertations & assignments to thesis, & case studies. 5000+ satisfied students, you could be next! Place Your Order Now! Order Now

Differences between the two are discussed below

Feature of Procedure Oriented Programming: - In it, any program created is divided in small portion called functions. Sequences are having more priority as compared to data in POP. Top down approach is followed. Access specifiers are not having any role in Procedural Oriented Programming. Freely movement of data from one function to another is not possible in it. Making amendments in program of POP is a very complex process. It is less secured as compared to OOP.  Examples: C, VB, FORTRAN, Pascal.

Feature of Object Oriented Programming: - In this, program is divided into parts termed as objects. Data is more significance than sequence as it deals with real entities. It follows bottom up approach. Public, Private and Protected are three kinds of access specifiers. Objects can move and communicate with each other through member functions. It provides a simpler means to add new data and functions. It is much more secure because data can hide. Examples: C++, JAVA, VB.NET, C#.NET.

A simple program in C language to swap the number given against the variable c and d.

#include
int main()
{
   int c, d, e;
   printf("Enter the value of c and d\n");
   scanf("%d%d", &c, &d);
   printf("Before Swapping\nc = %d\nd = %d\n",c,d);  
   e = c;
   c    = d;
   d    = e;
   printf("After Swapping\nc = %d\nd = %d\n",c,d);
   return 0;
}

Similarly a C++ program for basic IO are as follows

#include
using namespace std;
int main()
{
  float gallons, liters;
  cout << "Enter number of gallons: ";
  cin >> gallons; //  
  liters = gallons * 3.7854; //  
  cout << "Liters: " << liters << endl;  
  return 0;
}

Characteristics of Object Oriented Programming

There are basically 4 Main characteristics of Object Oriented Programming which are as follows

1. Inheritance: Inheritance is a kind of mechanism through which a newly formed class adapts all the properties of other class from which it is derived (Information on the C++ language, 2013). But using this, an object only has to define that quality which is unique to it only (Just What is OO Programming 2013).

Example of Inheritance in C++
#include  
using namespace std;
// Base class Shape
class Shape  
{
   public:
      void setHeight(int h)
      {
         height = h;
      }
      void setWidth(int wi)
      {
         width = wi;
      }
   protected:
      float height;
      float width;
};
// Base class CostingPaint
class CostingPaint  
{
   public:
      int getCost(int area)
      {
         return area * 70;
      }
};
// Derived class
class Rectangle: public Shape, public PaintCost
{
   public:
      int getArea()
      {  
         return (width * height);  
      }
};
float main(void)
{
   Square Sqr;
   float area1;
   sqr.setWidth(8);
   sqr.setHeight(8);
   area1 = sqr.getArea();    
   // Print the area of the object.
   cout << "Complete Area is  : " << Sqr.getArea() << endl;
   // The Complete Painting Cost is
   cout << "Total paint cost: $" << Sqr.getCost(area) << endl;
   return 0;
}

2. Encapsulation: It is a process of binding code and data together in manipulates in order to keep it safe from external world (Kathy and Bates, 2005). It describes data in the entire object which is enclosed and concealed in the object and right to access it is limited to element of that class.

Example for Encapsulation in C++
#include
float area1(float rec1_length, float rec1_breadth);
struct rectangle2{
float length;
float breadth;
};
struct pole1{
float length;
float depth;
};
float area1(float rec_length, float rec_breadth) //Rectangle Area
{
return rec_length * rec_breadth;
}
void main()
{
rectangle box, square;
pole flag_pole;
box.length = 15;
box.breadth = 11;
square.length = square.breadth = 6
flag_pole.length = 50;
flag_pole.beadth = 12
cout << "Box Area is " <<
area(box.length, box.breadth) << "\n";
cout << "Square Area is " <<
area(square.length, square.breadth) << "\n";
cout << "The intresting area is " <<
area(square.width, box.length) << "\n";
cout << "The horrific area is " <<
area(square.length, flag_pole.breadth) << "\n";
}

3. Polymorphism: Polymorphism is the ability to take more than one form. In this, a general interface is designed to a group of related activities (Kindler and  Krivy, 2011). It has a capability to route objects in a variable manner relying on their specific class or data type.

Example of Polymorphism in C++
// abstract base class
#include
using namespace std;
class CPolygon {
  protected:
    int width, height;
  public:
    void set_values (int a, int b)
      { width=a; height=b; }
    virtual int area (void) =0;
  };
class CRectangle: public CPolygon {
  public:
    int area (void)
      { return (width * height); }
  };
class CTriangle: public CPolygon {
  public:
    int area (void)
      { return (width * height / 2); }
  };
int main () {
  CRectangle rect;
  CTriangle trgl;
  CPolygon * ppoly1 = â-­
  CPolygon * ppoly2 = &trgl;
  ppoly1->set_values (4,5);
  ppoly2->set_values (4,5);
  cout << ppoly1->area() << endl;
  cout << ppoly2->area() << endl;
  return 0;
}

4. Abstraction: This denotes to the act of representing important features without indulging the background detail or explanations (Kjellman, 2006). As for an instance two functions carry out nearly the similar action and could be joined into a sole function.

Example of Abstraction in C++
class DrawableObject
{   
public:
virtual void Draw(GraphicalDrawingBoard&) const = 0; //draw to GraphicalDrawingBoard
};
class Rectangle : public DrawableObject
{
 public:
   void Draw(GraphicalDrawingBoard&) const; //draw a rectangle
};
class Circle : public DrawableObject
{
 public:
   void Draw(GraphicalDrawingBoard&) const; //draw a circle
};
class Triangle : public DrawableObject
{
 public:
   void Draw(GraphicalDrawingBoard&) const; //draw a triangle
};
 
typedef std::list<DrawableObject*> DrawableList_t;
 
 DrawableList_t drawableList;
 GraphicalDrawingBoard gdrawb;
drawableList.pushback(new Rectangle());
 drawableList.pushback(new Circle());
drawableList.pushback(new Triangle());
for(DrawableList_t::const_iterator iter = drawableList.begin(),  
    endIter = drawableList.end();
    iter != endIter;
    ++iter)
{  
   DrawableObject *object = *iter;
   object->Draw(gdrawb);
 
}

Aggregation and Composition Difference

Aggregation: It is a type of correlation aimed two classes which is best stated as a “has-a” and “whole/part” affiliation (Mitchell, 2002). It is a specific type of composition where there is no ownership between the complex object and sub objects is implied. Each class referenced is considered to be part-of the aggregate class .

Example:
include
 
class Employee
{
  public:
      Employee(char *name){
      cout<<"Employee::ctor\n";
      myName_p = new char(sizeof(strlen(name)));
      myName_p = name;
}
     
    char* disp(){return(myName_p);};
 
    ~Employee()
    {
      cout<<"Employee:dtor\n\n";
      delete (myName_p);
    }
 
  private:
    char *myName_p;
};
 
class Company
{
  public:
    Company(char * compName, Employee* emp){
      cout<<"Company::ctor\n";
      name = new char(sizeof(strlen(compName)));  
      name = compName;
      myEmp_p = emp;
    };
 
    ~Company()
    {
      cout<<"Company:dtor\n\n";
      myEmp_p = NULL;
    };
     
  private:
    char *name;
    Employee *myEmp_p;
};
 
 
int main()
{
  cout<<"\nExample of Aggregation Relationship \n";
  cout<<"********************\n\n";
     
 {
    cout<<"Here, an Employee-Payal has job in for Organization-PP \n";
    Employee emp("Payal");
   
 {
      Organization org("PP", &emp);
 } // here Company object will be deleted, whereas Employee object is yet there
 
    cout<<"At this point Company gets deleted...\n";
    cout<<"\nBut Employee-"<<emp.disp();
    cout<<" is still there\n";
     
} //here Employee object will be deleted
 
  return(0);
}.

Composition: It is relationship of two classes which is based on the aggregation relationship (Pierce, 2002). Composition obtains the affiliation additionally by making sure that the including object is liable for the existence of the object it seizes (Fedosov, 2013).

Example:
Class Professor;
Class Department
{
 ...
 Private:
 // Aggregation
 Professor* members [5];
 ...
};
 
Class University
{
 ...
 Private:
 std::vector< Department > faculty;
 ...  
 create_dept ()
 {
 ...
 // Composition (must limit to 20)
 faculty.push_back (Department (...));
 faculty.push_back (Department (...));
 ...
 }
};Example:
include
 
class Employee
{
  public:
      Employee(char *name){
      cout<<"Employee::ctor\n";
      myName_p = new char(sizeof(strlen(name)));
      myName_p = name;
}
     
    char* disp(){return(myName_p);};
 
    ~Employee()
    {
      cout<<"Employee:dtor\n\n";
      delete (myName_p);
    }
 
  private:
    char *myName_p;
};
 
class Company
{
  public:
    Company(char * compName, Employee* emp){
      cout<<"Company::ctor\n";
      name = new char(sizeof(strlen(compName)));  
      name = compName;
      myEmp_p = emp;
    };
 
    ~Company()
    {
      cout<<"Company:dtor\n\n";
      myEmp_p = NULL;
    };
     
  private:
    char *name;
    Employee *myEmp_p;
};
 
 
int main()
{
  cout<<"\nExample of Aggregation Relationship \n";
  cout<<"********************\n\n";
     
 {
    cout<<"Here, an Employee-Payal has job in for Organization-PP \n";
    Employee emp("Payal");
   
 {
      Organization org("PP", &emp);
 } // here Company object will be deleted, whereas Employee object is yet there
 
    cout<<"At this point Company gets deleted...\n";
    cout<<"\nBut Employee-"<<emp.disp();
    cout<<" is still there\n";
     
} //here Employee object will be deleted
 
  return(0);
}.

Design a Object Oriented Programming Solution

Concept of Parent/Child Class in Object Oriented Model

Object oriented model is an archetype that assists the programmer to solve the complexity of a problem by taking into account the problem not as a set of functions that can be performed but mainly as asset of related, interacting Objects (Pierce, 2002).  A Class can be termed as list of data and the acts which can be carried out on that data. Inheritance establishes the relationship between “is-a”. Child classes inherit attributes and behavior from Parent classes which is termed as base classes, super classes or parent classes. Relationship of classes gives rise to hierarchy .

Object Oriented Solution on above design

# include
    # include
    #include
    abstract class Vehicle
    {
        public abstract char colour ();
        public abstract char get company ();
    }
    class Plane extends Vehicle
    {
        public char colour();
        public char company();
    }
    class Automobiles extends Vehicle
    {
        public char colour();
        public char company();
    }
    Class Train extends Vehicle
    {
        public char colour();
        public char company();
    }

Extending the solution
Now we need to extend the solution by creating the Car class. The presented solution is as below:-
#include
#include
#include
#include
using namespace std;
class Vehicle    {
char colour ();
char getcompany ()
};
 class car : public Vehicle{
private :
char *model;
int num;
int len;
public :
car ()
{    
// default Constructor        
}
car (char *a,  int b)
{      
len=strlen(a);  
model=new char[len+1];  
strcpy(model,a);   
num = b;
}
~car ()    {
cout<<"\n"<<"Destructor called";
}
void display();
};
void car::display()
{
cout<<"\n"<<"the car model is :" << model;
cout<<"\n"<<"the car number is:" << num;
}
int main()
{
car obj1 ("Camry", 1759);
obj1.display();
car obj2 ("Renault", 2501);
obj2.display();
//system ("pause");
return 0;
}

Testing Object Oriented programming

A.Critical Review and Testing

Critical Review defined as a scripting an act which allows a programmer to be precise and examine a group of source code (Kjellman, 2006).  In critical review, evaluation of the source code for different program is done along with analysis of parent class. After that testing is done in order to confirm whether the program is functioning in a pre-determined manner or not. Series of testing is done in order to check the functionality of the program (Fernández, 2000). This includes general testing, which refers to generic and statistical method for exercising the program, special input testing which includes random testing and domain testing, functional testing selects test cases to assess the needed functionality of a program. Different other types of testing includes realistic testing, stress testing, performance testing, execution testing, competency testing, active interface testing, structural testing and error-introduction testing.

Read Also: A/601/1740 The Developing Manager Unit 1 UK CBC College Level 4

B.Analysis of Actual Test Result against Expected

Actual test result is analyzed against expected in order to ensure that the testing executed to completion. In this process, outcome of test is analyzed to identify the differences between the actual result and expected result (Scott, 2006). In detection of deviation, corrective measure is taken to overcome the problem of defects.

C.Evaluation Independent Feedback of the Program

Evaluation provides manifest on the performance of the program and enables the program to gain independent feedback on the significance, usefulness, efficiency and consistency of the program (Sutter and Alexandrescu, 2004)

D.Creation of Onscreen Help

An onscreen help is usually available in the IDE in which the source code is developed so that if any time some problem is occur, then on screen help can be utilized (Kindler and  Krivy, 2011). It is very essential especially for online documentation due to necessity of stock of information and knowledge which must is very helpful. Apart from this, the programmer must also give hint about the process and methods in the source code so that anyone can easily recognize the functioning and meet up their necessities as preferred. Also, large amount of information can be included in on screen help without looking much bulky (Kanoglu and Arditi, 2001).

E.Create documentation to Support and Maintain your Computer Program

Documentation is necessary to overcome debugging problem, can facilitate changes according to needs and to figure out that how hackers/crackers take advantage of uncertainty. It is also important as it has whole information of the program or software and allows the end client to deal and use it with ease (Gunther, 2011).

CONCLUSION

In the concluded report emphasis has been types of languages used for programming and their major differences. Characteristics of OOP Language are discussed in a wider spectrum as well as OOP concepts are being initialized to devise a project as per the stated requirement. Moreover the utility of testing, debugging and user assistance and documentation of source code has been elaborated in a wider area. This report assists in generating a knowledge segment for OOP Concepts and also the procedure of implementation of programming in it.

Related Service: Programming assignment help

Quality academic Writing Services in UK

  • To Standard
  • 100% Original
  • On Time Delivery

REFERENCES

  • Armstrong, D. J., 2006. The Quarks of Object-Oriented Development. Communications of the ACM.  
  • Balagurusamy., 2007. Object Oriented Program-Msbte. Tata McGraw-Hill Education.
  • Bittencourt, M. L., 2000. Using C++ templates to implement finite element classes. Engineering Computations. 
  • Derdour, M. and et al., 2012.An adaptation platform for multimedia applications CSC (component, service, connector). Journal of Systems and Information Technology. 
  • Farrell, J., 2008. Object Oriented Programming Using C++. Cengage learning.

You may also like to read: Prepare for success knowledge & creativity

Download Full Sample
Often times, students feel unable to work on assignments and think, “Who will do my assignment?” By providing "Sample" on various subjects, we are trying to help them understand all the intricacies of writing. We have the most qualified and skilled assignment writers who can provide the best assignment writing services, essay writing services, dissertation writing services, and more at the most affordable rates. Place your order now for surprising discounts.
Boost Grades & Leave Stress

Share Your Requirements Now for Customized Solutions.

Lowest Price
USD 7.13

    Delivered on-time or your money back

    100+ Qualified Writers

    For Best Education Assignment Help

    expert name
    250 - Completed Orders
    Rossana Maxwell View Profile MBA - Marketing Australia Hire Me
    expert name
    1149 - Completed Orders
    Albert Thompson View Profile Master's in Production & Industrial Management USA Hire Me
    expert name
    2344 - Completed Orders
    Sofia Macquire View Profile Master's in Journalism Studies USA Hire Me
    expert name
    645 - Completed Orders
    Alex Basheer View Profile Ph.D in Psychology Canada Hire Me
    View All Writers
    FREE Tools

    To Make Your Work Original

    • tools Paraphrasing Tool

      Easy to Use Paraphrasing Tool to Simplify Complex Academic Writing

      Check Paraphrasing
    • tools Plagiarism Checker

      Check your work against plagiarism & get a free Plagiarism report!

      Check Plagiarism
    • tools Reference Generator

      Get citations & references in your document in the desired style!

      Generate References
    • tools Grammar Checker Tool

      Make your content free of errors in just a few clicks for free!

      Grammar Checker
    • tools Essay Typer

      Generate plagiarism-free essays as per your topic's requirement!

      Essay Typer
    • Dissertation Outline Generator

      Get Structured Outline by Professionals for Your Dissertation

      Check Dissertation
    • Thesis Statement Generator

      Create the perfect thesis statement in just few minutes!

      Generate Thesis
    • AI Essay Writer

      Get a well-researched and quality essay effortlessly in a few seconds.

      AI Essay Writer
    GAH whatsapp

    Limited Time Offer

    Exclusive Library Membership + FREE Wallet Balance