Thought Sharing

Tuesday, June 11, 2013

Containership Vs. Inheritance

Containership is the concept of having one or more objects of one or more classes as data members of another class. Containership is the capacity of a class to contain objects of different classes as member’s data. For example, the class A could contain an object of class B as a member. Here, all public functions defined in B can be used in the class A. The Class A becomes the container, while the class B becomes the contained class. In OOP, Containership represents one ‘has – a’ relation. It is important to note that, although the container has access to carry out all public methods of the contained class, it is not able to change or provide additional functionality.

Inheritance is the capacity for a class to inherit properties and behavior of a parental class by spreading it. Inheritance principally provides code reuse by allowing extending properties and behavior of an existing class by a newly defined class. If the class A is created from Class B, therefore the class B is parent class and the class A is called the child class (or derived class/sub class). The behavior of parent class can be overridden by derived class i.e. a derive class can modify the functions of parent class in it.

Difference between Containership and Inheritance:
If a class is extended, it inherits all public and protected properties/ behaviours and these behaviours can be overridden by the subclass. But if a class is contained in other one, the container does not get the capacity to change or add behavior to the contained class i.e. container. In Inheritance, the behavior of parent class can be overridden by derived class i.e. a derive class can modify the functions of parent class in it.

Inheritance represents ‘is -a ‘relationship in OOP, while Containership represents a’ has -a’ relationship.

Monday, June 10, 2013

Exceptions/ Exception Handling in C++

An exception is a problem that arises during the execution of a program. A C++ exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero or infinite loop etc.
Exceptions provide a way to transfer control from one part of a program to another. C++ exception handling is built upon three keywords: try, catch, and throw.

  •     throw: A program throws an exception when a problem shows up. This is done using a throw keyword.
  •      catch: A proram catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch keyword indicates the catching of an exception.
  •      try: A try block identifies a block of code for which particular exceptions will be activated. It's followed by one or more catch blocks.

Assuming a block will raise and exception, a method catches an exception using a combination of the try and catch keywords. A try/catch block is placed around the code that might generate an exception. Code within a try/catch block is referred to as protected code, and the syntax for using try/catch looks like the following:

ALGORITHM:

Step 1: Start the program.
Step 2: Declare the variables a,b,c.
Step 3: Read the values a,b,c,.
Step 4: Inside the try block check the condition.
            a. if(a-b!=0) then calculate the value of d and display.
            b. otherwise throw the exception.
Step 5: Catch the exception and display the appropriate message.
Step 6: Stop the program.

PROGRAM:

#include
#include
void main()
{
   int a,b,c;
   float  d;
   clrscr();
   cout<<"Enter the value of a:";
   cin>>a;
   cout<<"Enter the value of b:";
   cin>>b;
   cout<<"Enter the value of c:";
   cin>>c;
   
   try
   {
              If ((a-b) != 0)
              {
                 d=c/(a-b);
                 cout<<"Result is:"<
              }
              else
              {
                 throw(a-b);
              }
   }

   Catch (int i)
   {
              cout<<"Answer is infinite because a-b is:"<
   }
     getch();
}

Output:

              Enter the value for a: 20
              Enter the value for b: 20
              Enter the value for c: 40
             Answer is infinite because a-b is: 0

Thursday, April 4, 2013

C++ Program for Generating Fibonacci Series



#include<iostream.h>
#include<conio.h>
void main()
{
int x,y,i, n ,sum=0;
cout<<"enter number of elements for fibonacci series: ";
cin>>n;
cout<<"Fibonacci Series is : "<<"\n";
x=0;
y=1;
cout<<x;
cout<<y;
for(i=3;i<=n;i++)
{
sum=x+y;
cout<<sum<<"\n";
x=y;
y=sum;
}
getch();
}

Thursday, March 21, 2013

C++ Program to create a class and access member function of a class



#include
class part
{
private:
int partnumber;
int modelnumber;
float cost;
public:
void setpart(int m,int p,float c)
{
Modelnumber = m;
partnumber = p;
cost = c;
}
void showpart();
};

void part :: showpart()
{
cout<<"model:"<
cout<<"\n"<<"part:"<
cout<<"\n"<<"cost:"<
}

void main()
{
part piston;      //object created
piston.setpart(101,207,210.50);
piston.showpart();
}

C++ Program to create a class and access member function of a class



#include
class part
{
private:
int partnumber;
int modelnumber;
float cost;
public:
void setpart(int m,int p,float c)
{
Modelnumber = m;
partnumber = p;
cost = c;
}
void showpart();
};

void part :: showpart()
{
cout<<"model:"<
cout<<"\n"<<"part:"<
cout<<"\n"<<"cost:"<
}

void main()
{
part piston;      //object created
piston.setpart(101,207,210.50);
piston.showpart();
}

Function overloading program in C++



#include< iostream.h>
#include< conio.h>

int area (int a);
int area (int a, int b);
float area (float r);

void main ()
{
clrscr ();
cout< < " Area Of Square: "< < area (4);
cout< < " Area Of Rectangle: "< < area (4,4);
cout< < " Area Of Circle: "< < area (3.2);
getch();
}

int area (int a)
{
return (a*a);
}

int area (int a,int b)
{
return (a*b);
}

float area (float r)
{
return (3.14 * r * r);
}

Friday, March 1, 2013

C++ program for sorting an array elements using bubble sort


#include
#include

void main()
{
int i,j,n,temp,a[100];
cout<<"enter size of array: ";
cin>>n;
cout<<"Enter elements of Array : ";
for(i=0;i{
cin>>a[i];
}
for(i=0;i{
for(j=i;j>=0;j--)
{
if(a[j]>a[j+1])
{
temp = a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
cout<<"sorted elements of array are : ";
for(i=0;i{
cout<}
getch();
}

Tuesday, February 12, 2013

To Calculate Factorial of a number in C++


#include
#include
void main()
{
int i, n, fact=1;
cout<<"Enter any number : ";
cin>>n;
for(i=1; i++ )
{
fact=fact * i;
}
cout<<"Factorial of "<t;
cout<<"\n";
}

Wednesday, December 5, 2012

Database Constraints


Database Constraints


Constraints are the rules which are applied to a table to filter out data during insert or update operations. Constraints can be added at the time of creating a table or altering a table. Constraints are the conditions which should be satisfied by insert or update query. There are 2 types of constraints:
1)      Input output (I/O) constraints:
a.       These are of following types:
                                                               i.      Primary Key
                                                             ii.      Foreign Key
                                                            iii.      Unique Key
2)      Check (Business Rules) constraints:
a.       These are defined at 2 levels
                                                               i.      Table Level
                                                             ii.      Column Level

List of SQL Queries


SQL Queries
Table Structure Related Queries:
1)      Create table
2)      Rename a table
3)      Creating a table from another table
4)      Deleting a table
5)      Adding a new column in an existing table
6)      Modifying a column in an existing table
7)      Deleting a column from an existing table
8)      Adding Primary Key during creating a table
9)      Adding Primary Key in an existing table
10)   Adding Foreign Key during creating a table
11)   Adding Foreign Key in an existing table
12)   Dropping a Primary Key from a table
13)   Dropping a Foreign Key from a table
14)   Defining Check constraint at Column Level while creating a table
15)   Defining Check constraint at Column Level using alter table
16)   Defining Check constraint at Table Level while creating a table
17)   Defining Check constraint at Table Level using alter table
18)   Dropping a Check constraint

Working with Table:
1)      Insert values in the table
2)      Update values in the table
3)      Delete values in the table
4)      Truncate Table (To empty a table- to delete all records)
5)      Selecting values from table
6)      Where Clause
7)      Desc (Description)
8)      Order BY Clause
9)      Group By Clause
10)   Having Clause
11)   Distinct Clause
12)   Searching Record using: Between, IN, NOT IN, Like
13)   Oracle Functions: AVG (), MIN (), MAX (), COUNT (), SUM (), SQRT (), EXP (), MOD (), TRUNC (), FLOOR (), CEIL (), LOWER (), UPPER (), ASCII ().

Sub Queries:
1)      Finding Duplicate Records from a Table
2)      Deleting Duplicate Records from a Table
3)      Finding Highest Salary from Employee Table
4)      Finding 2nd Highest Salary from Employee Table
5)      Finding 5th Highest Salary from Employee Table
6)      Finding Nth    Highest Salary from Employee Table

Database Objects:
1)      Creating View
2)      Deleting View
3)      Creating Join
4)      Create Index
6)      Delete Index

Tuesday, May 1, 2012

Scripting Languages

A scripting language is used to write the scripts on the web pages. These scripts are actually the programs embedded into HTML code and these web pages are run on the client computers. These scripts/programs are interpreted by the browsers. There are different types of these scripting languages that are commonly used today like JavaScript, vbscript, .net languages, Perl etc. The JavaScript is based on the main language java. Java script is an interpreted language. It is mostly used to add dynamic contents to a web page.

These dynamic contents may be scrolling text, menus, pop-up windows, animations etc. JavaScript is an open language developed by sun micro system. The vbscript is a scripting language that is based on a programming language visual basic. The vbscript also provides the same functionality as JavaScript. By default internet explorer supports vbscript and Netscape communicator supports java scripts. Perl refers to practical extraction and report language. It is also a powerful scripting language that is most commonly used. The most recently used technology in scripting language is .NET Platform. It is a creation of Microsoft. The main advantage of .NET Platform is that it provides the platform independence in internet environment. It develops the applications that support XML web services. The .NET applications can be used in any type of web browse or in any type of computer.

A scripting language is a form of programming language that is usually interpreted rather than compiled. Conventional programs are converted permanently into executable files before they are run. In contrast, programs in scripting language are interpreted one command at a time. Scripting languages are often written to facilitate enhanced features of Web sites. These features are processed on the server but the script in a specific page runs on the user's browser.

In most cases, it is easier to write the code in a scripting language than in a compiled language. However, scripting languages are slower because the instructions is not handled solely by the basic instruction processor. Scripting languages allow rapid development and can communicate easily with programs written in other languages.

Scripting languages can be used to create specialized GUIs (graphical user interfaces) and forms that enhance the convenience of search engines, Web-based e-mail and e-commerce. Many Web sites require that the user's browser be set to run scripts to take advantage of all the features of the site. In some cases, Web sites are practically useless unless the user's computer is set to run programs locally in a scripting language.

Monday, April 23, 2012

TABLE OF CONTENTS FOR SOFTWARE PROJECTS


Table of Contents
1.      Introduction……………………………………………………………….............….…....1
a.       Overview of Proposed System………………………………………….…2
b.      Need of Proposed System…………………………………………………………...3
c.       Scope of Work…………………………………………………………....4
2.      Objective of Proposed System…………………………………………………….............5
3.      Project Categories Tools and Environment……………………………………...............….6
a.       Front End
b.      Back End
c.       Hardware and Software Requirements
4.      Software Development Life Cycle
                       SDLC Model (Water Fall Model, Spiral Model or Prototype Model)
a.       Recognition of Need
b.      Feasibility Study
                                                              i.      Operational Feasibility
                                                            ii.      Economical Feasibility
                                                          iii.      Technical Feasibility
                                                          iv.      Legal Feasibility
c.       System Requirement Specifications (SRS)
d.      System Analysis and Design
                                                              i.      Entity Relationship Diagram
                                                            ii.      Data Flow Diagram and Use Case Diagram
                                                          iii.      Design Strategies
e.      Physical Design (Coding)
f.       System Integration and Testing
                                                              i.      Functional Testing
                                                            ii.      Structural Testing
                                                          iii.      Test Case
g.      Operation and Maintenance
5.      Conclusion and Future Work
6.      Bibliography