You are on page 1of 55

SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

Sir Syed University of Engineering & Technology


ANSWER SCRIPT

Date: 12-NOV-2020
Roll Number: 2019-CE-123
Section: C
Name: SHAHEER ZAEEM
Course Name: ADVANCED OBJECT ORIENTED PROGRAMMING
Degree Program: COMPUTER ENGINEERING BS
Total number of pages
being submitted:

Start writing from here …

QUESTION 1:
 PART_1

POTENTIAL CLASSES UNDER THE SCOPE OF THIS PROJECT:


Public class XYZ University();

Public class Department();

Public class HOD();

Public class staff();

Public class Course Module();

Public class Teacher();

Public class Academic Officer();

Public class Course Cordinator();

Public class Student();

Public class Registration();

Public class Academic Year();

REASON OF ASSUMPTION:
Reason for Justification to choose the above classes is to full fill the activity of student course
registration for a university using the attributes of each class and HOD assigns to Teachers,

Page 1 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

Teacher prepares Course Modules, Coordinator verifies courses for academic year, Academic
officer validate student options and students confirm registration process by resolve any
issues.

Scope of the Project is University offers course Registration for students at Department level
and Controlled by Academic officer and Course coordinator at university level

Purpose is to model data base and communication among the various objects(roles) to
perform course Registration for a university

 PART_2
1. XYZ University: Attributes are: Reg.ID, Name, Type, No of students, No of Teachers, No
of courses etc

Methods are: Add student(),Add Employee(),Appoint Academic Officer(),Remove student(),


add course() etc

2. Department: Attribute are: ID, Name, address, No of students, Labs ,No of Teachers,
Course modules, etc

Methods are: enroll course(),Assign course module(Teacher),Assess (Student),add


equipment(lab)

3. HOD: Employee Id, Name, Address, Age, Role, Performance

Methods are : Assign module(),Assess(student),monitor(staff),control(dept)

4.Staff: Emp ID, Name, Address, Phone no, age, Qualification, Designation, salary

Methods are: Appoint(),choose course(),Choose dept(),add address(),Remove person(),view


stafflist1()

5.Teacher: employee ID, Teacher ID, Name, Address, Phone no, email, Experience, DOB,
Publications, courses taught

Methods are: Prepare course outline(),Design course module(),Assess(student),lecture(course


ID)

6.Course Module: Course ID, Module no, semester, dept, duration, type ,teacher Id

Methods are: add module(),Add outline(),remove module(),modify outline, manage module()

7.Course Cordinator: Employee ID, cordinator ID, Role, Address, Phone, email, course
outline id, course module id

Methods are: update course outline(),Check course module(),conform Course Registration()

Page 2 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

8.Academic Officer: Emp ID, Ao ID, Name, Role, Student master list, course master list,
student Id, cordinator ID ,Course Id.

Methods are: prepare masterlist1 ,prepare masterlist2 ,verify student module selection(),send
registered student info (coordinator)

9.Registration: Course Reg ID, Student Id, Course ID, Academic Year, Sem, teacher ID, Dept
ID.

Methods are: get course modules(),get teacher(),choose(module),addition a Option(course),


register course list(student)

10 Student: Student ID, Name, dept Id, dob, course Id, address, email, phone, sem fee.

Methods are: add student(),choose course(),pay fee(),get grade()

11.Academic Year: Year ID, no of working days, No of holidays, no of workshops planned,


student enroll, no of courses.

Methods are: get AY(),get course list(AY),get Students enroll(AY),co-curricular activities


planned(AY),Extra curricular Planned(AY) etc

 PART_3

QUESTION 2:
 PART_1

Page 3 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

SOURCE CODE:

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package Question2_a;

/**

* @author Shaheer Zaeem

*/

import java.util.ArrayList;

import java.io.*;

import java.util.*;

class Queue extends Thread

private int size=10;

private ArrayList<String> queue=new ArrayList<String>(size);

public void add(String s)

if(size==queue.size())

Page 4 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

System.out.println("queue full waiting");

else

Date date=new Date();

System.out.println("String "+s+" added at time "+date.toString());

queue.add(s);

public String remove()

if(queue.isEmpty())

return "Queue empty waiting ";

else

return queue.remove(0).toString()+" removed ";

class Consumer extends Thread


Page 5 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

{ Queue q;

public Consumer(Queue q1)

q=q1;

public void run()

synchronized(q)

System.out.println(q.remove());

class Producer extends Thread

int i;

Queue q;

public Producer(int x,Queue q1)

i=x;

q=q1;

Page 6 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

public void run()

synchronized(q)

//i++;

String ss=Integer.toString(i);

ss="string "+ss;

q.add(ss);

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package Question2_a;

/**

* @author Shaheer Zaeem

*/

public class Test extends Queue{

Page 7 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

public static void main(String []args){

Queue q=new Queue();

for(int i=1;i<=10;i++)

Producer p=new Producer(i,q);

Consumer c=new Consumer(q);

p.start();

c.start();

}}}

 PART_2

SOURCE CODE:

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package Question2b;

import java.io.PrintStream;

import java.net.DatagramPacket;

import java.net.DatagramSocket;

Page 8 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

import java.net.InetAddress;

import java.net.Socket;

import java.util.Scanner;

/**

* @author Shaheer Zaeem

*/

public class Client {

public static void main(String[] args) {

// TODO code application logic here

try{

Scanner sc= new Scanner(System.in);

DatagramSocket ds = new DatagramSocket();

System.out.println("Enter a name:");

String name=sc.nextLine();

byte[] b = name.getBytes();

InetAddress ip = InetAddress.getLocalHost();

DatagramPacket dp = new DatagramPacket(b,b.length,ip,9999);

ds.send(dp);

InetAddress address1 =InetAddress.getByName("www.ssuet.edu.pk");

System.out.println(address1.getHostAddress());

Page 9 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

catch(Exception e)

{System.out.println(e);}

QUESTION 3:
 PART_1

SOURCE CODE:

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package Question3;

import java.awt.Font;

import java.time.LocalDateTime;

import java.time.format.DateTimeFormatter;

import java.sql.*;

import javax.swing.JOptionPane;

/**

Page 10 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

* @author Shaheer Zaeem

*/

public class SecurityKeypad extends javax.swing.JFrame {

/**

* Creates new form SecurityKeypad

*/

ResultSet rs;

public SecurityKeypad() {

initComponents();

Font f=new Font("Times New Roman",Font.BOLD,14);

Font f1=new Font("Times New Roman",Font.BOLD,20);

pass_display.setFont(f1);

/**

* This method is called from within the constructor to initialize the form.

* WARNING: Do NOT modify this code. The content of this method is


always

* regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

Page 11 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

pass_display = new javax.swing.JPasswordField();

btn_1 = new javax.swing.JButton();

btn_2 = new javax.swing.JButton();

btn_3 = new javax.swing.JButton();

btn_5 = new javax.swing.JButton();

btn_6 = new javax.swing.JButton();

btn_4 = new javax.swing.JButton();

btn_7 = new javax.swing.JButton();

btn_9 = new javax.swing.JButton();

btn_8 = new javax.swing.JButton();

btn_enter = new javax.swing.JButton();

btn_0 = new javax.swing.JButton();

btn_clr = new javax.swing.JButton();

jScrollPane1 = new javax.swing.JScrollPane();

txt_lstLog = new javax.swing.JTextArea();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

pass_display.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

pass_displayActionPerformed(evt);

});

Page 12 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

btn_1.setText("1");

btn_1.setPreferredSize(new java.awt.Dimension(80, 30));

btn_1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btn_1ActionPerformed(evt);

});

btn_2.setText("2");

btn_2.setPreferredSize(new java.awt.Dimension(80, 30));

btn_2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btn_2ActionPerformed(evt);

});

btn_3.setText("3");

btn_3.setPreferredSize(new java.awt.Dimension(80, 30));

btn_3.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btn_3ActionPerformed(evt);

});

Page 13 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

btn_5.setText("5");

btn_5.setPreferredSize(new java.awt.Dimension(80, 30));

btn_5.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btn_5ActionPerformed(evt);

});

btn_6.setText("6");

btn_6.setPreferredSize(new java.awt.Dimension(80, 30));

btn_6.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btn_6ActionPerformed(evt);

});

btn_4.setText("4");

btn_4.setPreferredSize(new java.awt.Dimension(80, 30));

btn_4.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btn_4ActionPerformed(evt);

});

Page 14 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

btn_7.setText("7");

btn_7.setPreferredSize(new java.awt.Dimension(80, 30));

btn_7.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btn_7ActionPerformed(evt);

});

btn_9.setText("9");

btn_9.setPreferredSize(new java.awt.Dimension(80, 30));

btn_9.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btn_9ActionPerformed(evt);

});

btn_8.setText("8");

btn_8.setPreferredSize(new java.awt.Dimension(80, 30));

btn_8.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btn_8ActionPerformed(evt);

});

Page 15 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

btn_enter.setText("Enter");

btn_enter.setPreferredSize(new java.awt.Dimension(80, 30));

btn_enter.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btn_enterActionPerformed(evt);

});

btn_0.setText("0");

btn_0.setPreferredSize(new java.awt.Dimension(80, 30));

btn_0.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btn_0ActionPerformed(evt);

});

btn_clr.setText("Clear");

btn_clr.setPreferredSize(new java.awt.Dimension(80, 30));

btn_clr.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btn_clrActionPerformed(evt);

});

Page 16 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

txt_lstLog.setColumns(20);

txt_lstLog.setRows(5);

jScrollPane1.setViewportView(txt_lstLog);

javax.swing.GroupLayout layout = new


javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alig
nment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout
.Alignment.LEADING)

.addComponent(pass_display)

.addComponent(jScrollPane1)))

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout
.Alignment.TRAILING)

.addGroup(layout.createSequentialGroup()

.addContainerGap(javax.swing.GroupLayout.DEFAULT_S
IZE, Short.MAX_VALUE)

.addGroup(layout.createParallelGroup(javax.swing.GroupL
ayout.Alignment.TRAILING)

Page 17 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

.addGroup(layout.createSequentialGroup()

.addComponent(btn_clr,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(btn_0,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.Componen
tPlacement.UNRELATED)

.addComponent(btn_enter,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(javax.swing.GroupLayout.Alignment.LEADI
NG, layout.createSequentialGroup()

.addComponent(btn_7,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(btn_8,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.Componen
tPlacement.UNRELATED)

.addComponent(btn_9,
javax.swing.GroupLayout.PREFERRED_SIZE,

Page 18 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))))

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addGroup(layout.createParallelGroup(javax.swing.GroupL
ayout.Alignment.TRAILING)

.addGroup(layout.createSequentialGroup()

.addComponent(btn_1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.Componen
tPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)

.addComponent(btn_2,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.Componen
tPlacement.UNRELATED)

.addComponent(btn_3,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(layout.createSequentialGroup()

.addGap(0, 5, Short.MAX_VALUE)

.addComponent(btn_4,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

Page 19 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

.addGap(18, 18, 18)

.addComponent(btn_5,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.Componen
tPlacement.UNRELATED)

.addComponent(btn_6,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))))

.addGap(0, 18, Short.MAX_VALUE)))

.addContainerGap())

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(pass_display,
javax.swing.GroupLayout.PREFERRED_SIZE, 46,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alig
nment.BASELINE)

.addComponent(btn_1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

Page 20 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

.addComponent(btn_2,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(btn_3,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alig
nment.BASELINE)

.addComponent(btn_6,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(btn_5,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(btn_4,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alig
nment.BASELINE)

.addComponent(btn_7,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(btn_9,
javax.swing.GroupLayout.PREFERRED_SIZE,

Page 21 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(btn_8,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alig
nment.BASELINE)

.addComponent(btn_enter,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(btn_0,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(btn_clr,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(30, 30, 30)

.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 114,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(25, Short.MAX_VALUE))

);

pack();

}// </editor-fold>

Page 22 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

private void pass_displayActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

pass_display.setEchoChar('*');

private void btn_1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

pass_display.setText(pass_display.getText()+"1");

private void btn_2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

pass_display.setText(pass_display.getText()+"2");

private void btn_3ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

pass_display.setText(pass_display.getText()+"3");

private void btn_4ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:


Page 23 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

pass_display.setText(pass_display.getText()+"4");

private void btn_5ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

pass_display.setText(pass_display.getText()+"5");

private void btn_6ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

pass_display.setText(pass_display.getText()+"6");

private void btn_7ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

pass_display.setText(pass_display.getText()+"7");

private void btn_8ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

Page 24 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

pass_display.setText(pass_display.getText()+"8");

private void btn_9ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

pass_display.setText(pass_display.getText()+"9");

private void btn_0ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

pass_display.setText(pass_display.getText()+"0");

private void btn_clrActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

pass_display.setText("");

txt_lstLog.setText("");

private void btn_enterActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd


HH:mm:ss");

Page 25 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

LocalDateTime now = LocalDateTime.now();

System.out.println(dtf.format(now));

try{

Class.forName("org.apache.derby.jdbc.ClientDriver");

System.out.println("Driver Loaded");

Connection
con=DriverManager.getConnection("jdbc:derby://localhost:1527/Keypad","Sha
heer", "123");

System.out.println("Connected");

Statement
st=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.C
ONCUR_UPDATABLE);

int pass=Integer.parseInt(pass_display.getText());

String Query="Select * From Shaheer.SecurityKeypad where


Password="+pass;

rs=st.executeQuery(Query);

if(!rs.first()){

txt_lstLog.append(dtf.format(now));

txt_lstLog.append("\tAcces denied");

rs.close();

else{

int password=rs.getInt(2);

System.out.println(""+password);

System.out.println(""+pass);

Page 26 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

if(pass==password){

txt_lstLog.append(dtf.format(now));

txt_lstLog.append("\tAcces granted");

JOptionPane.showMessageDialog(rootPane, "Welcome
"+rs.getString(1));

rs.close();

catch(Exception e){

e.printStackTrace();

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

/* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code


(optional) ">

Page 27 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

/* If Nimbus (introduced in Java SE 6) is not available, stay with the


default look and feel.

* For details see


http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

*/

try {

for (javax.swing.UIManager.LookAndFeelInfo info :


javax.swing.UIManager.getInstalledLookAndFeels()) {

if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName());

break;

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(SecurityKeypad.class.getName()).log(java.u
til.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(SecurityKeypad.class.getName()).log(java.u
til.logging.Level.SEVERE, null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(SecurityKeypad.class.getName()).log(java.u
til.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(SecurityKeypad.class.getName()).log(java.u
til.logging.Level.SEVERE, null, ex);
Page 28 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

//</editor-fold>

/* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new SecurityKeypad().setVisible(true);

});

// Variables declaration - do not modify

private javax.swing.JButton btn_0;

private javax.swing.JButton btn_1;

private javax.swing.JButton btn_2;

private javax.swing.JButton btn_3;

private javax.swing.JButton btn_4;

private javax.swing.JButton btn_5;

private javax.swing.JButton btn_6;

private javax.swing.JButton btn_7;

private javax.swing.JButton btn_8;

private javax.swing.JButton btn_9;

private javax.swing.JButton btn_clr;

private javax.swing.JButton btn_enter;

Page 29 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

private javax.swing.JScrollPane jScrollPane1;

private javax.swing.JPasswordField pass_display;

private javax.swing.JTextArea txt_lstLog;

// End of variables declaration

 PART_2

QUESTION 4:
 PART_1

SOURCE CODE:

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

Page 30 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

* and open the template in the editor.

*/

package Question4a;

import java.util.ArrayList;

import java.util.List;

import java.util.Scanner;

/**

* @author Shaheer Zaeem

*/

public class Ban {

private int BankIDName;

private String Name;

private List<Account> accounts;

public Ban(int BankIDName, String Name, List<Account> accounts) {

this.BankIDName = BankIDName;

this.Name = Name;

this.accounts = accounts;

public Ban() { }
Page 31 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

public List<Account> getAccounts()

return accounts;

public static void main(String[] args) {

Account acc=new Account();

List<Account> Acc = new ArrayList<Account>();

Scanner sc=new Scanner(System.in);

System.out.println("Enter Bank Name:");

String bankname=sc.nextLine();

System.out.println("Enter Bank ID:");

int bankid=sc.nextInt();

Ban ban= new Ban(444, "Silk Bank", Acc);

List<Account> bank = ban.getAccounts();

System.out.println("Enter Account Id:");

int accid=sc.nextInt();

System.out.println("Enter Customer Id:");

int cusid=sc.nextInt();

// System.out.println("Enter the amount you want to withdraw:");

// double amount=sc.nextDouble();

//Account acc=new Account();

Account a1= new Account(accid,cusid);

//a1.setAmount(amount);

//Account a2= new Account(12,6426,23000.00);


Page 32 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

//Account a3= new Account(13,7325,25800.00);

//Account a4= new Account(14,2353,22400.00);

//Account a5= new Account(15,4653,50000.00);

//List<Account> Acc = new ArrayList<Account>();

Acc.add(a1);

for(Account b : bank){

System.out.println("Account ID : " + b.AccountID + " and " +" Customer ID : "


+ b.CustomerID);}

System.out.println("Enter the type of your account:");

System.out.println("1.Savings Account");

System.out.println("2.Mortage Account");

System.out.println("3.Checking Account");

int choice=sc.nextInt();

switch(choice){

case 1:

SavingsAccount sa=new SavingsAccount();

sa.Withdraw();

break;

case 2:

MortageAccount ma=new MortageAccount();

Page 33 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

ma.Withdraw();

break;

case 3:

CheckingAccount ca=new CheckingAccount();

ca.Withdraw();

}/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package Question4a;

/**

* @author Shaheer Zaeem

*/

import java.util.Scanner;

public class Account {

int AccountID;

int CustomerID;
Page 34 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

double Amount;

double balance=10000;

private Customer customer;

public Customer getCustomer() {

return customer;

public void setCustomer(Customer customer) {

this.customer = customer;

public Account(){}

public Account(int AccountID, int CustomerID) {

this.AccountID = AccountID;

this.CustomerID = CustomerID;

// this.Amount = Amount;

// this.setAmount(Amount);

public int getAccountID() {

Page 35 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

return AccountID;

public void setAccountID(int AccountID) {

this.AccountID = AccountID;

public int getCustomerID() {

return CustomerID;

public void setCustomerID(int CustomerID) {

this.CustomerID = CustomerID;

public double getAmount() {

return Amount;

public void setAmount(double Amount) {

this.Amount = Amount;

Page 36 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

void Deposit(){

Amount=Amount+Amount;

void Withdraw(){

Scanner sc=new Scanner(System.in);

System.out.println("Enter the amount you want to withdraw:");

double amnt=sc.nextInt();

this.setAmount(amnt);

Amount=balance-this.getAmount();

System.out.println("Balance:"+Amount);

};

double GetBalance(){

return Amount;};

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

Page 37 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

* and open the template in the editor.

*/

package Question4a;

/**

* @author Shaheer Zaeem

*/

public class CheckingAccount extends Account {

@Override

void Withdraw() {

super.Withdraw(); //To change body of generated methods, choose Tools |


Templates.

}/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package Question4a;

/**

Page 38 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

* @author Shaheer Zaeem

*/

public class Customer {

private String Name;

private int CustomerID;

private Account account;

public Account getAccount() {

return account;

public void setAccount(Account account) {

this.account = account;

public String getName() {

return Name;

public void setName(String Name) {

this.Name = Name;

public int getCustomerID() {


Page 39 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

return CustomerID;

public void setCustomerID(int CustomerID) {

this.CustomerID = CustomerID;

public Customer(String Name, int CustomerID) {

this.Name = Name;

this.CustomerID = CustomerID;

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package Question4a;

/**

* @author Shaheer Zaeem

*/
Page 40 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

public class MortageAccount extends Account{

@Override

void Withdraw() {

super.Withdraw(); //To change body of generated methods, choose Tools |


Templates.

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package Question4a;

/**

* @author Shaheer Zaeem

*/

public class SavingsAccount extends Account{

@Override

void Withdraw() {

Page 41 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

super.Withdraw(); //To change body of generated methods, choose Tools |


Templates.

 PART_2

SOURCE CODE:

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package Question4_b;

/**

* @author Shaheer Zaeem

*/

import java.util.Scanner;

public class Customer {

String name;

String address;

Scanner sc=new Scanner(System.in);

public String getName() {

return name;

Page 42 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

public void setName(String name) {

this.name = name;

public String getAddress() {

return address;

public void setAddress(String address) {

this.address = address;

void Name(){

System.out.println("Enter your Name:");

String name=sc.nextLine();

this.setName(name);

void address(){

System.out.println("Enter your address:");

String address=sc.nextLine();

this.setAddress(address);

Order o= new Order();

Page 43 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

}/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package Question4_b;

import java.util.Date;

/**

* @author Shaheer Zaeem

*/

public class Order extends Customer{

Date date;

String Status;

public Date getDate() {

return date;

public void setDate(Date date) {

this.date = date;
Page 44 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

public String getStatus() {

return Status;

public void setStatus(String Status) {

this.Status = Status;

void SubTotal(float amount){

System.out.println("Total Bill:"+amount);

void calcTax(float amount){

System.out.println(""+amount);

float Tax=(amount)*(10/100);

System.out.println("Tax="+Tax);

float taxs=Tax+amount;

System.out.println("Amount after paying tax:"+taxs);

void calcTotal(){

Page 45 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

void calcTotalWeight(){

}/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package Question4_b;

import java.util.Scanner;

/**

* @author Shaheer Zaeem

*/

public class OrderDetail extends Order{

int quantity;

String TaxStatus;

Scanner sc=new Scanner(System.in);

public int getQuantity() {

return quantity;

}
Page 46 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

public void setQuantity(int quantity) {

this.quantity = quantity;

public String getTaxStatus() {

return TaxStatus;

public void setTaxStatus(String TaxStatus) {

this.TaxStatus = TaxStatus;

void Quantity(){

System.out.println("Enter Quantity of your item");

int quan=sc.nextInt();

this.setQuantity(quan);

void TaxStatus(){

System.out.println("What is the tax status?");

String status=sc.next();

this.setTaxStatus(status);

}/*
Page 47 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package Question4_b;

/**

* @author Shaheer Zaeem

*/

import java.util.Scanner;

public class Payment extends Order {

Scanner sc=new Scanner(System.in);

Payment(float amount) {

Order o=new Order();

o.SubTotal(amount);

o.calcTax(amount);

}/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.


Page 48 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

*/

package Question4_b;

/**

* @author Shaheer Zaeem

*/

import java.util.Scanner;

public class Credit {

Scanner sc=new Scanner(System.in);

void authorize(){

System.out.println("Enter your name");

String name=sc.nextLine();

System.out.println("Enter type of credit card (Visa/Master Card):");

String type=sc.nextLine();

System.out.println("Enter Expiry Date(MM/YY)");

String date=sc.nextLine();

System.out.println("Authorized!");

System.out.println("Enter the cash amount:");

float amount=sc.nextFloat();

Payment p=new Payment(amount);

}/*

* To change this license header, choose License Headers in Project Properties.

Page 49 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package Question4_b;

import java.util.Scanner;

/**

* @author Shaheer Zaeem

*/

public class Check {

Scanner sc=new Scanner(System.in);

void Authorize(){

System.out.println("Enter your name");

String name=sc.nextLine();

System.out.println("Enter bank id:");

int id=sc.nextInt();

System.out.println("Authorized!");

System.out.println("Enter the cash amount:");

float amount=sc.nextFloat();

Payment p=new Payment(amount);

Page 50 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package Question4_b;

/**

* @author Shaheer Zaeem

*/

import java.util.Scanner;

public class Cash {

Scanner sc=new Scanner(System.in);

void Cash(){

System.out.println("Enter the cash amount:");

float amount=sc.nextFloat();

System.out.println(amount);

Payment p=new Payment(amount);

}/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

Page 51 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

*/

package Question4_b;

/**

* @author Shaheer Zaeem

*/

import java.util.Scanner;

public class Item extends OrderDetail{

String item;

String description;

Scanner sc=new Scanner(System.in);

public String getItem() {

return item;

public void setItem(String item) {

this.item = item;

public String getDescription() {

return description;

Page 52 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

public void setDescription(String description) {

this.description = description;

void ItemName(){

System.out.println("Enter Item Name:");

String itemname=sc.nextLine();

this.setItem(itemname);

void Itemdescription(){

System.out.println("Enter Item Description:");

String itemdes=sc.nextLine();

this.setItem(itemdes);

}/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package Question4_b;

/**

* @author Shaheer Zaeem

Page 53 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

*/

import java.util.Scanner;

public class Test {

public static void main(String[] args) {

Scanner sc=new Scanner(System.in);

Customer c=new Customer();

c.Name();

c.address();

Item i=new Item();

i.ItemName();

i.Itemdescription();

Order o =new Order();

System.out.println("Enter The mode of Payment:");

System.out.println("1.Cash");

System.out.println("2.Cheque");

System.out.println("3.Credit");

int choice=sc.nextInt();

switch(choice){

case 1:

OrderDetail od= new OrderDetail();

od.Quantity();

Cash cs=new Cash();

cs.Cash();

break;
Page 54 of 55
SHAHEER ZAEEM CE-206 ROLL NUM:2019-CE-144

case 2:

OrderDetail odd= new OrderDetail();

odd.Quantity();

Check ck=new Check();

ck.Authorize();

break;

case 3:

OrderDetail oddd= new OrderDetail();

oddd.Quantity();

Credit cd=new Credit();

cd.authorize();

Page 55 of 55

You might also like