0% found this document useful (0 votes)
51 views6 pages

Comsats University Islamabad Wah Campus Object Oriented Programming

1) The document defines classes for Student, Employee, Manager, StudentRecord, EmployeeRecord, and AssociationRunner. 2) The classes define attributes and methods to set and get student degree/year, employee ID/salary, and manager title/records. 3) The main method creates objects of the classes and calls methods to set attributes and display records.

Uploaded by

Nofil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views6 pages

Comsats University Islamabad Wah Campus Object Oriented Programming

1) The document defines classes for Student, Employee, Manager, StudentRecord, EmployeeRecord, and AssociationRunner. 2) The classes define attributes and methods to set and get student degree/year, employee ID/salary, and manager title/records. 3) The main method creates objects of the classes and calls methods to set attributes and display records.

Uploaded by

Nofil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Comsats University Islamabad

Wah Campus

Object Oriented Programming


Assignment # 05

Submitted to: Miss Samia Zafar

Submitted by:

Nofil Abbas FA21-BCS-046


Task 1 (b)
Abcd Student Employee Manager
package abcd; package abcd; package abcd; package abcd;

public class Abcd { public class public class Employee public class Manager {
Student { { private String title;
private String private String private Student stdRecord[];
public static void degree; EmployeeId; private Employee empRecord;
main(String[] args) { private int year; private int salary;
//Student s1=new public Manager(String title) {
Student("BCS",2018); public Student() public Employee() { this.title = title;
Employee e1=new { } }
Employee("FA21- }
001",95000); public public void setTitle(String title) {
Manager m1=new Employee(String this.title = title;
Manager("General public EmployeeId, int }
Manager"); Student(String salary) {
Student degree, int year) { this.EmployeeId public void setStdRecord(Student[]
stdRecord[]=new Student[3]; this.degree = = EmployeeId; stdRecord) {
degree; this.salary = this.stdRecord = stdRecord;
for (int i = 0; i < 3; i++) this.year = salary; }
{ year; }
stdRecord[i]=new }
Student("BCS",2018); public void setEmpRecord(Employee
public void empRecord) {
}
public void setEmployeeId(String this.empRecord = empRecord;
setDegree(String EmployeeId) { }
m1.setStdRecord(stdRecord)
degree) { this.EmployeeId
;
this.degree = = EmployeeId;
m1.setEmpRecord(e1);
degree; }
m1.display();
}
public String getTitle() {
} public void
return title;
public void setSalary(int salary) {
}
} setYear(int year) { this.salary =
this.year = salary;
year; } public Student[] getStdRecord() {
} return stdRecord;
}
public String
public String getEmployeeId() {
getDegree() { return public Employee getEmpRecord() {
return degree; EmployeeId; return empRecord;
} } }

public int public int public void display(){


getYear() { getSalary() { System.out.println("Title: "+title);
return year; return salary; System.out.println("Student Record: ");
} } for (int i = 0; i < 3; i++) {

System.out.println(stdRecord[i].getDegree());
} }
System.out.println(stdRecord[i].getYear());
}
System.out.println("Employee Record:
"+"\nEmployee ID:
"+empRecord.getEmployeeId()+"\nSalary:
"+empRecord.getSalary());
}
}

Task 1 (a)
AssociationRunner StudentRecord EmployeeRecord Manager

package association.runner; package package package association.runner;


association.runner; association.runner;

public class public class Manager {


AssociationRunner { public class public class private String title;
StudentRecord { EmployeeRecord { private StudentRecord stdRecord=new
private String private String StudentRecord();
public static void degree; employeeId; private EmployeeRecord
main(String[] args) { private int year; private int salary; empRecord=new EmployeeRecord();
StudentRecord s1=new
StudentRecord("BCS",2018) public public public Manager() {
; StudentRecord() { EmployeeRecord() { }
EmployeeRecord e1=new } }
EmployeeRecord("FA21- public public void setTitle(String title) {
001",95000); StudentRecord(Strin public this.title = title;
Manager m1=new g degree, int year) { EmployeeRecord(Strin }
Manager(); this.degree = g employeeId, int
m1.setTitle("General degree;
Manager"); this.year = year; salary) { public String getTitle() {
m1.setStdRecord(s1); } this.employeeId = return title;
m1.setEmpRecord(e1); employeeId; }
m1.display(); public void this.salary =
setDegree(String salary; public void
} degree) { } setStdRecord(StudentRecord stdRecord) {
this.degree = this.stdRecord = stdRecord;
} degree; public void }
} setEmployeeId(String
employeeId) { public void
public void this.employeeId = setEmpRecord(EmployeeRecord
setYear(int year) { employeeId; empRecord) {
this.year = year; } this.empRecord = empRecord;
} }
public void
public String setSalary(int salary) { public StudentRecord getStdRecord() {
getDegree() { this.salary = return stdRecord;
return degree; salary; }
} }
public EmployeeRecord
public int public String getEmpRecord() {
getYear() { getEmployeeId() { return empRecord;
return year; return employeeId; }
} } public void display(){
System.out.println("Title: "+title);
public int getSalary() System.out.println("\n***Student
} { Record***\nDegree:
return salary; "+stdRecord.getDegree()+"\nYear:
} "+stdRecord.getYear());
System.out.println("\n***Employee
@Override Record***\nEmployee ID:
public String "+empRecord.getEmployeeId()+"\
toString() { nSalary: "+empRecord.getSalary());
return }
"EmployeeRecord{" +
"employeeId=" + }
employeeId + ",
salary=" + salary + '}';
}

}
Task 2
Activity2 Employee Date

package activity.pkg2; package activity.pkg2; package activity.pkg2;

public class Employee { public class Date {


public class Activity2 { private String name;
private Date birthdate; private int day;
private Date joindate; private int month;
public static void main(String[]
private int year;
args) {
public Employee(){}
Employee e1=new
public Employee(String name){ public Date(){}
Employee("ABC");
this.name=name; public Date(int day,int month,int year){
e1.setBirthDate(26, 11, 2000);
} this.day=day;
e1.setJoinDate(20, 9, 2021);
public void setBirthDate(int day,int this.month=month;
e1.display();
month,int year){ this.year=year;
birthdate= new }
}
Date(day,month,year); public void checkdate(){
} if(this.month==4 || this.month==6 ||
}
public void setJoinDate(int day,int this.month==9 ||this.month==11){
month,int year){ this.month+=this.day/31;
joindate= new this.day=this.day%30;
Date(day,month,year); if(this.day==0){
} this.day=30;
}
public void display(){ }
System.out.println("Name : else if(this.month==2){
"+this.name); this.month+=this.day/29;
System.out.print("Birhtdate : this.day=this.day%28;
");birthdate.display(); if(this.day==0){
System.out.print("Joindate : "); this.day=28;
joindate.display(); }
} }
else{
this.month+=this.day/32;
} this.day=this.day%31;
if(this.day==0){
this.day=31;
}
}
}
public void checkmonth(){
if(this.month>12){

this.year+=this.month/12;

this.month=this.month%12;
}
if(this.month==0){
this.month=12;
}

public void display(){


this.checkdate();
this.checkmonth();

System.out.println(day+"/"+month+"/"+ye
ar);
}

You might also like