You are on page 1of 15

OOP Assignment No.

6
Zaryab Ahmed Khan
20-CS-84
Submitted to: Ma’am Rabia Mahum

Activity # 1

package zaryab.khan.assignment;

public class ZaryabKhanAssignment {

public static void main(String[] args) {

System.out.println("Zaryab Ahmed Khan");

System.out.println("20-CS-84");

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

Employee E1 = new Employee("Zaryab Ahmed Khan", 34732094 , "Attock",


"ZaryabAhmed@gmail.com", "4-B", 80000, "31st Oct,2015");

E1.display();

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

Staff S1 = new Staff("Staff Class Called", "Ali Khattak", 348514555, "Taxila", "alihere89@gmail.com",
"8-C", 95000, "9th April,2013");

S1.display();
System.out.println("==============================================");

Class PERSON

package zaryab.khan.assignment;

public class Person {

protected String name;

protected int phone;

protected String address;

protected String email;

public Person(String name, int phone, String address, String email) {

this.name = name;

this.phone = phone;

this.address = address;

this.email = email;

}
Class Employee

package zaryab.khan.assignment;

public class Employee extends Person {

String Office;

int Salary;

String joining_date;

public Employee(String name, int phone, String address, String email,String Office, int Salary, String
joining_date) {

super(name, phone, address, email);

this.Office = Office;

this.Salary = Salary;

this.joining_date = joining_date;

public void display() {

System.out.println("Name :: "+name);

System.out.println("Phone Number :: "+phone);

System.out.println("Address :: "+address);

System.out.println("Email :: "+email);

System.out.println("Office :: "+Office);

System.out.println("Salary :: "+Salary);

System.out.println("Joining Date :: "+joining_date);

}
Class Student

package zaryab.khan.assignment;

public class Student extends Person {

String Status;

public Student(String Status, String name, int phone, String address, String email) {

super(name, phone, address, email);

this.Status = Status;

public void display() {

System.out.println("Name :: "+name);

System.out.println("Phone Number :: "+phone);

System.out.println("Address :: "+address);

System.out.println("Email :: "+email);

System.out.println("Status :: "+Status);

Class Staff

package zaryab.khan.assignment;

public class Staff extends Employee {

String Title;
public Staff(String Title, String name, int phone, String address, String email, String Office, int Salary,
String joining_date) {

super(name, phone, address, email, Office, Salary, joining_date);

this.Title = Title;

public void display() {

System.out.println("Name :: "+name);

System.out.println("Phone Number :: "+phone);

System.out.println("Address :: "+address);

System.out.println("Email :: "+email);

System.out.println("Office :: "+Office);

System.out.println("Joining Date :: "+joining_date);

System.out.println("Title :: "+Title);

Class Faculty

package zaryab.khan.assignment;

public class Faculty extends Employee{

String Office_hour;

int Rank;

public Faculty(String Office_hour, int Rank, String name, int phone, String address, String email, String
Office, int Salary, String joining_date) {

super(name, phone, address, email, Office, Salary, joining_date);

this.Office_hour = Office_hour;

this.Rank = Rank;

}
public void display() {

System.out.println("Name :: "+name);

System.out.println("Phone Number :: "+phone);

System.out.println("Address :: "+address);

System.out.println("Email :: "+email);

System.out.println("Office :: "+Office);

System.out.println("Salary :: "+Salary);

System.out.println("Joining Date :: "+joining_date);

System.out.println("Office Hours :: "+Office_hour);

System.out.println("Rank :: "+Rank);

OUTPUT:
Activity # 2

package lab.assignment.pkg2;

public class OOP_Assingment_6 {

public static void main(String[] args) {

System.out.println("Zaryab Ahmed Khan");

System.out.println("20-CS-84");

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

Books B1 = new Books("Journey to Center of the World", "520", 700);

B1.display_func();

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

Tape T1 = new Tape("Songs Playlist", "250", 40);

T1.display_func();

Class Books

package lab.assignment.pkg2;

public class Books extends Publication{

private int Page_number;

public Books(String Title,String Price ,int Page_number) {


super(Title, Price);

this.Page_number = Page_number;

public Books(){

public int getPage_number() {

return Page_number;

public void setPage_number(int Page_number) {

this.Page_number = Page_number;

public void display_func(){

System.out.println("Title :: "+getTitle());

System.out.println("Price :: "+getPrice()+" Rupees");

System.out.println("Total Number of Pages :: "+getPage_number());

Class Publication
package lab.assignment.pkg2;

public class Publication {

private String Title;

private String Price;

public Publication(String Title, String Price) {

this.Title = Title;

this.Price = Price;

public Publication() {

public String getTitle() {

return Title;

public void setTitle(String Title) {

this.Title = Title;

public String getPrice() {

return Price;

}
public void setPrice(String Price) {

this.Price = Price;

Class Tape

package lab.assignment.pkg2;

public class Tape extends Publication {

private int time_minutes;

public Tape(String Title , String Price , int time_minutes) {

super(Title, Price);

this.time_minutes = time_minutes;

public Tape(){

public int getTime_minutes() {

return time_minutes;

public void setTime_minutes(int time_minutes) {

this.time_minutes = time_minutes;
}

public void display_func(){

System.out.println("Title :: "+getTitle());

System.out.println("Price :: "+getPrice()+" Rupees");

System.out.println("It Can be Played for :: "+getTime_minutes()+" Minutes");

OUTPUT:
Activity # 3

package question.pkg3;

public class Question3 {

public static void main(String[] args) {

System.out.println("Zaryab Ahmed Khan");

System.out.println("20-CS-84");

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

Laptop L1 = new Laptop();

L1.display();

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

Laptop L2 = new Laptop(5, 18, 27, 20, 16, 64, 128, 144);

L2.display();

Class Computer

package question.pkg3;

public class Computer {


protected int Word_Size;

protected int Memory_Size;

protected int Storage_Size;

protected double Speed;

Computer(){

Word_Size=64;

Memory_Size=1;

Storage_Size=1024;

Speed=1.5;

public Computer(int Word_Size, int Memory_Size, int Storage_Size, double Speed) {

this.Word_Size = Word_Size;

this.Memory_Size = Memory_Size;

this.Storage_Size = Storage_Size;

this.Speed = Speed;

Class Laptop

package question.pkg3;

public class Laptop extends Computer{

int Length;

int Width;

int Height;
int Weight;

public Laptop() {

System.out.println("---> Default Constructor Called <---");

Length=8;

Height=8;

Width=16;

Weight=32;

public Laptop(int Length, int Width, int Height, int Weight, int Word_Size, int Memory_Size, int
Storage_Size, double Speed) {

super(Word_Size, Memory_Size, Storage_Size, Speed);

System.out.println("---> Parameterized Constructor Called <---");

this.Length = Length;

this.Width = Width;

this.Height = Height;

this.Weight = Weight;

public void display()

System.out.println("Memory Size :: "+Memory_Size+" MegaBytes");

System.out.println("Word Size :: "+Word_Size+" Bytes");

System.out.println("Storage Size :: "+Storage_Size+" MegaBytes");

System.out.println("Speed :: "+Speed+" MegeHertz");

System.out.println("Length :: "+Length+ " Inches");

System.out.println("Width :: "+Width+" Inches");


System.out.println("Height :: "+Height+" Inches");

System.out.println("Weight :: "+Weight+" Pounds");

OUTPUT:

You might also like