Upload
dangtram
View
222
Download
0
Embed Size (px)
Citation preview
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
Department of Computer Science Engineering
Object Oriented Programming
course code: 15CS 2002
Academic Year 2016-17
Lab Manual for Lab based Projects
II B Tech – I Semester
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
Notes on lab based projects
Software projects in java are basically interconnection of various small classes inturn each class is collection of variables and methods. Every method contribute some useful output and every class purpose is separately defined. In this way by planning 3 to 4 classes and combining them through inheritance or any other means makes a lab based project. The expected behaviour from the project is called requirement, so that all the requirements are handled in the project and they are all tested for quality purpose. The requirements are two types as explained below.
1. Functional requirements: These includes how the input is accepted by the project, intermediate results, final computed outputs. All the results produced by the project.Eg. They are project sensitive
2. Non-functional requirements: These includes how you store data,
process data, what techniques are to be used to make the project. You
may consider other factors like quality, look and feel, security etc.
Eg. They are project insensitive, but basically technology specific , are
used across all the projects.
1. Use of data structures2. Using constructor overloading3. Use inheritance4. Use of final key word5. Use of abstract method6. Use of method overloading7. Use of method overriding8. Use of exception handling9. Use of encapsulation10. Use atleast one static variable and static method.11. Use of interfaces12. Use of call by reference
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
13. Abstract methods, classes14. Use of menu (look and feel)15. Use of password (security)16. Use of data validations (quality)
Project development life cycle :
Every project has to undergo four phases before it is
completed, namely
1. Requirements gathering : Collection of the data, procedures,
conditions, rules, expected outputs are gathered.
2. Design : Before starting the coding process necessary planning
is conducted like breaking the total projects into smaller
modules and the relations among the modules are well
planned.
3. Coding : The actual programming process begins here, each
individual modules (functions/programs) are developed
4. separately and all the programs (classes) are combined finally
to make the project.
5. Testing : Each program is tested for its validity i.e for its output
and finally the total project is also tested to confirm its outputs.
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
Project views:
A project can be viewed in three ways, namely
1. Data view : What data to be used, how the data to be used and
the relationships among data items are thoroughly
investigated.
2. Code view : This is pure programming, programs are developed
to work on the input data to produce the required output
according to business logic.
3. Behavioural view : This is screens designing (front end) step,
from which the data is entered into the project and the outputs
are displayed in the user friendly nature.
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
What a student supposed to do :
You have to choose one project from the list of projects given
in this lab manual. Each project is different by its nature, data,
behaviour. That is the data requirement ( what data is used for that
project), the conditions or constraints used to make judgements,
comparisons, intermediate computations/results and the final
outputs that produced for specific combinations of inputs.
On successful selection of a project, one has to study the
domain knowledge of the project with the help of your guide, seniors
or by using internet. This step helps you in recognising the data
requirement and functional requirements for your project.
There may be individual projects or batch wise projects depends
on the department discretion. Whatever may be the case every
student suppose to implement.
1. Any four functional requirements of your choice
2. Any eight non functional requirements of your choice
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
Model Project:
To help you in understanding the concept of lab based project
the course team will give you a model project. You can code walk of
this project and understand what are the functional and non
functional requirements embedded in this project. This enables you
to get ready for your project that should be submitted at the end of
semester.
Note: The above model project source code is attached at the
end of the document.
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
---------------------------------------------------
List of Projects for the a.y 2016-17
----------------------------------------------------
Project 1: super market billing system
Project 2: tourism information system
Project 3: course selection for a +2 student system
Project 4: college selection for a +2 student system
Project 5: campus recruitment companies information system
Project 6: Indian states information system
Project 7: your city cinema theatre information system
Project 8: your city hospital information system
Project 9: facilities at KL University information system
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
Project 10: cities of AP information system
Project 11: real estate information system
Project 12: student Counselling System
Project 13: House Tax Billing System
Project 14: Alumni Information System
Project 15: Electricity Billing System
Project 16: Voting Information System
Project 17: Library Information Management System
Project 18: Hospital Management System
Project 19: Banking System
Project 20: Doctors information system
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
Project 21: Marriage Bureau management
Project 22: Hotel Management system
Project 23: Water Tax Billing System
Project 24: Vijayawada railway station train information system
Project 25: Student Information System
Project 26: Court case status management
Project 27: Police station complaints management system
Project 28: Godown (warehouse) stock management system
Project 29: Bank loan status management system
Project 30: Airport ATC system
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
Project 31: Vehicle parking management system
Project 32 : Convention centre(function hall) management system
Project 33 : Truck fleet management system
Project 34 : Hospital equipment management system
Project 35 : Telugu Movies information system
Project 36 : Municipality garbage management system
Project 37 : Insurance management system
Project 38 : Agriculture market information system
Project 39 : Annual maintenance contract (AMC) system
Project 40 : Travels agency management system
Project 41 : government scholarships management system
Project 42 : crop management system for a mandal.
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
The source code of the model project is given below.
/* This is a PBL (Project based Lab) modelproject, developed by
course team of "Object Oriented Programming" @ KL University
course coordinator: Dr.MSR PRASAD
Description (Domain knowledge): There are B.Tech and M.Tech students, Students will have name, phone number and city as common data.B.Tech students have 3 sujects with pass mark as 40, where as M.Tech students have 4 subjects with pass mark as 50. minimum and maximum marks are 0 and 100 respectively.
Functional requirements:
1. All students details must be avilable as personal data and academic
data(constraint-1).
2. If anybody failed in atleast one subject result is fail,
result is pass only all subjects gets pass marks (constraint-2).
3. Howmany are the total students ?
4. Howmany are passed?
5. Howmany of them are failed?
6. Who is the top scorer?
7. Howmany marks scored by the top scorer?
8. Failed student can not be top scorer (constraint-3).
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
Non functional requirements:
1. Used one data structure(Array)
2. Inheritance is implemented
3. Method overloading is used
4. Method overriding is used
5. static and final key words are used
6. interface is implemnted at appropriate place.
7. call by value is used
8. call by referece is used
9. Exception handling is implemented
10.Encapsulation( use of privatekey etc. word) is used
11.data validation is done
12.Menu kind of front end is used
13.proper comments are added
*/
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
import java.util.Scanner;
import javax.swing.JOptionPane;
import java.util.InputMismatchException;
/*---------------------------------
PersonalDetails - base class
---------------------------------*/
class PersonalDetails{
String name;
String phoneNo;
String city;
}
/*-------------------------------
AcademicDetails - interface
-------------------------------*/
interface AcademicDetails{
void registration();
}
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
/*----------------------------------------------------------
BtechStudent class - extends base class and interface
----------------------------------------------------------*/
class BtechStudent extends PersonalDetails implements AcademicDetails{
BtechStudent(){
// default constructor
}
int[] sub=new int[3];
private int res;
int sum=0;
/*----------------------------------------------------------
registration() - method of interface implemented
simple exception handling is implemented
data entry and validation is done
----------------------------------------------------------*/
public void registration(){
int i,j;
Scanner in = new Scanner(System.in);
try{
System.out.print("Enter name: ");
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
name=in.next();
System.out.print("Enter phone number: ");
phoneNo=in.next();
System.out.print("Enter city :");
city=in.next();
for(i=0; i<3; i++){
j=i+1;
while(true){
System.out.print("Enter course .." + j + " marks :");
sub[i] = in.nextInt();
if(sub[i]>=0 && sub[i]<=100)break;
else
System.out.println("Please enter b/w 0..100 range");
}
}
}catch(Exception e){
System.out.println(" error ="+e);
System.out.println(" problem in registration");
}
}
/*-------------------------------------------------------------------
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
passFail()- to decide pass/fail of the result for b.tech students
-------------------------------------------------------------------*/
int passFail(){
res=1;
if ((sub[0]<40)||(sub[1]<40)||(sub[2]<40))
res=0;
return res;
}
}
/*----------------------------------------------------------
MtechStudent class - multi level inheritance is used
final class - this can not be furthur extended
Exception handling - try with multi catch is used
----------------------------------------------------------*/
final class MtechStudent extends BtechStudent {
MtechStudent() {
// default constructor
}
int[] msub=new int[4];
private int res;
int msum=0;
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
/*----------------------------------------------------------
registration()- used for data entry for m.tech students
- overrided method from its base class
- validation for numeric data is done
----------------------------------------------------------*/
public void registration()
{
int i,j;
Scanner in = new Scanner(System.in);
try{
System.out.print("Enter name :");
name=in.next();
System.out.print("Enter phone number :");
phoneNo=in.next();
System.out.print("Enter city :");
city=in.next();
for(i=0; i<4; i++)
{
j=i+1;
while(true)
{
System.out.print("Enter course .." + j + " marks :");
msub[i] = in.nextInt();
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
if(msub[i]>=0 && msub[i]<=100)break;
else
System.out.println("Please enter b/w 0..100 range");
}
}
}catch(InputMismatchException ime)
{
System.out.println(" error ="+ime);
System.out.println("problem in registration");
}
catch(ArrayIndexOutOfBoundsException aiobe)
{
System.out.println("array index exception");
}
}
/*-------------------------------------------------------------------
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
passFail()- to decide pass/fail of the result for M.tech students
- an overrided method from its base class
-------------------------------------------------------------------*/
int passFail(){
res=1;
if ((msub[0]<50)||(msub[1]<50)||(msub[2]<50)|| (msub[3]<50))
res=0;
return res;
}
}
/**----------------------------------------------------------
ResultAnalysis class - Independent class for outputs
- object arrays are used to hold students data
----------------------------------------------------------*/
final class ResultAnalysis {
/**-------------------------------------------------------------------
constant declaration to fix number of students...
-------------------------------------------------------------------*/
final static int NO_OF_STUDENTS=2;
/**-------------------------------------------------------------------
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
a static block executes before invoking main() method
-------------------------------------------------------------------*/
static{
System.out.println(" ********************************");
System.out.println(" -- welcome to student project -- ");
System.out.println(" ********************************");
System.out.println(" ");
}
/**-------------------------------------------------------------------
two object arrays for B.tech and M.tech students data to hold
-------------------------------------------------------------------*/
BtechStudent st[] = new BtechStudent[NO_OF_STUDENTS];
MtechStudent mst[] = new MtechStudent[NO_OF_STUDENTS];
int count=0;
String topName;
int topMarks;
/**-------------------------------------------------------------------
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
void allRegistrations(int) - method for B.tech
-------------------------------------------------------------------*/
void allRegistrations(int bt){
count=0;
int i,j;
for (i=0;i<NO_OF_STUDENTS;i++)
{
st[i]=new BtechStudent();
count++;
j=i+1;
System.out.println(" ");
System.out.println("Enter "+ j +" B.Tech student DATA.");
st[i].registration();
System.out.println(" ");
}
}
/**-------------------------------------------------------------------
void allRegistrations(double) - overloaded method for M.tech
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
-------------------------------------------------------------------*/
void allRegistrations(double mt){
count=0;
int i,j;
for (i=0;i<NO_OF_STUDENTS;i++)
{
mst[i]=new MtechStudent();
count++;
j=i+1;
System.out.println(" ");
System.out.println("Enter "+ j +" M.Tech student DATA.");
mst[i].registration();
System.out.println(" ");
}
}
/**-------------------------------------------------------------------
void result_Analysis(int) - for B.tech - number passes/fails
-------------------------------------------------------------------*/
int result_Analysis(int bt){
int porf=0;
int cp=0;
int cf=0;
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
int bt_cp;
int i,j;
for (i=0;i<NO_OF_STUDENTS;i++)
{
porf=st[i].passFail();
if (porf==1)
cp=cp+1;
if (porf==0)
cf=cf+1;
}
System.out.println(" ");
System.out.println(" ");
System.out.println(" ------------------- ");
System.out.println(" output ");
System.out.println(" ------------------- ");
System.out.println(" no of passes = "+cp);
System.out.println(" no of failures = "+cf);
bt_cp=cp;
return bt_cp;
}
/**-------------------------------------------------------------------
void result_Analysis(double) - for M.tech - an overloaded method
-------------------------------------------------------------------*/
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
int result_Analysis(double mt){
int porf=0;
int cp=0;
int cf=0;
int mt_cp;
int i,j;
for (i=0;i<NO_OF_STUDENTS;i++)
{
porf=mst[i].passFail();
if (porf==1)
cp=cp+1;
if (porf==0)
cf=cf+1;
}
System.out.println(" ");
System.out.println(" ");
System.out.println(" ------------------- ");
System.out.println(" output ");
System.out.println(" ------------------- ");
System.out.println(" no of passes = "+cp);
System.out.println(" no of failures = "+cf);
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
mt_cp=cp;
return mt_cp;
}
/**-------------------------------------------------------------------
void topMarksName(int) - for B.tech - gives top marks and topper name?
-------------------------------------------------------------------*/
void topMarksName(int bt){
int big=-100;
int tr_no=0;
int i,j;
for (i=0;i<NO_OF_STUDENTS;i++)
{
st[i].sum=0;
for(j=0;j<3;j++)
{
if (st[i].sub[j]>=40)
st[i].sum=st[i].sum + st[i].sub[j];
else
{
st[i].sum=0;
break;
}
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
}
if (st[i].sum > big)
{
big=st[i].sum;
tr_no=i;
}
}
topMarks= st[tr_no].sum;
topName=st[tr_no].name;
}
/*-------------------------------------------------------------------
void topMarksName(double) - for M.tech - an overloaded method
-------------------------------------------------------------------*/
void topMarksName(double mt){
int big=-100;
int tr_no=0;
int i,j;
for (i=0;i<NO_OF_STUDENTS;i++)
{
mst[i].msum=0;
for(j=0;j<4;j++)
{
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
if (mst[i].msub[j]>=50)
mst[i].msum=mst[i].msum + mst[i].msub[j];
else
{
mst[i].sum=0;
break;
}
}
if (mst[i].msum > big)
{
big=mst[i].msum;
tr_no=i;
}
}
topMarks= mst[tr_no].msum;
topName = mst[tr_no].name;
}
}
/*-------------------------------------------------------------------
StudentProject class - A demo class which has main() method
-------------------------------------------------------------------*/
class StudentProject{
/*-------------------------------------------------------------------------------
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
go_run(ResultAnalysis ra) - a static method to pass object reference variable
- it uses call by reference
-------------------------------------------------------------------------------*/
static void go_run(ResultAnalysis ra){
Scanner s1= new Scanner(System.in);
int choice;
/*---------------------------
MENU - implementation
----------------------------*/
while(true){
System.out.println(" MENU");
System.out.println(" ");
System.out.println(" 1. for B.tech");
System.out.println(" 2. for M.tech");
System.out.println(" 3. Quit");
System.out.print(" Enter your choice:");
choice=s1.nextInt();
switch(choice){
case 1:
ra.allRegistrations(1);
int bt_cpp=ra.result_Analysis(1);
ra.topMarksName(1);
System.out.println(" no of students in B.tech = "+ra.count);
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
System.out.println(" ------------------- ");
if (bt_cpp==0){
System.out.println(" No topper, all failures");
}
else {
System.out.print(" topper is "+ra.topName);
System.out.println(" with "+ra.topMarks+" marks");
}
System.out.println(" ------------------------------ ");
System.out.println(" ");
break;
case 2:
ra.allRegistrations(1.1);
int mt_cpp=ra.result_Analysis(1.1);
ra.topMarksName(1.1);
System.out.println(" No of students in M.tech = "+ra.count);
System.out.println(" ------------------- ");
if (mt_cpp==0){
System.out.println(" No topper, all failures");
}
else {
System.out.print(" topper is "+ra.topName);
System.out.println(" with "+ra.topMarks+" marks");
Lab Manual for II/IV B.Tech Course: Object Oriented programming (15 CS 2002) for the a.c year 2016-17
}
System.out.println(" -------------------------------- ");
System.out.println(" ");
break;
case 3: System.exit(0);
//default: System.out.printf("Enter only 1 or 2\n");
default:JOptionPane.showMessageDialog(null,"Enter 1,2 or 3 only");
}
}
}
/*------------------------------------------------
main() method- Execution actually begins here
------------------------------------------------*/
public static void main(String args[]){
ResultAnalysis ra=new ResultAnalysis();
go_run(ra);
} }
// End of the project code