Professional Documents
Culture Documents
OOP
import java.util.Scanner;
/**
*
* @author Raffay
*/
public class Library {
public String Name;
public int id;
public int shelfno;
super.Name= name;
super.id= id;
super.shelfno= shelfno;
this.date_of_publication= date_of_publication;
} // end of journal
class book extends Library{
public int no_of_pages;
super.Name= name;
super.id= id;
super.shelfno= shelfno;
this.no_of_pages= no_of_pages;
} // end of book
MAIN CLASS
/*
* 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 library;
import java.util.Scanner;
/**
*
* @author Raffay
*/
}
}
}
else{ System.out.println("pasword Incorrect");
}
}
else if(x==2){
if(bookentered>0){
System.out.println("USER MODE\n 1 to search by id 2 to search by name");
int check = sc.nextInt();
if(check==1){
System.out.println("enter id to search for book");
int idsearch= sc.nextInt();
for(int i=0;i<b.length;i++){
if(idsearch==b[i].id){
System.out.println("Book found");
System.out.println(b[i].Name+b[i].id+b[i].no_of_pages+b[i].shelfno);
}
}
}
else if(check==2){
System.out.println("enter name to search for book");
String search= sc.next();
for(int i=0;i<b.length;i++){
if(search.equals(b[i].Name)){
System.out.println("Book found");
System.out.println(b[i].Name+b[i].id+b[i].no_of_pages+b[i].shelfno);
}
}
}}
else
System.out.println("book not entered");
}
}
}
}
Question 2
Main class
package com.company;
import com.fac.define.faculity;
import com.name.std.std;
faculity[] arr2;
arr2 = new faculity[3];
arr2[0] = new faculity("emp001", "Areej Bashir", 250000);
arr2[1] = new faculity("emp23", "Perviz", 2500000);
arr2[1] = new faculity("emp23", "Ali khan", 25000);
}
}
package faculity
package com.fac.define;
package Student
package com.name.std;