package school;
import java.util.Scanner;
public class School {
private int [] departments;
private int number_of_departments;
School(int max){
number_of_departments = max;
departments = new int[number_of_departments];
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
Staff [] f = new Staff[2];
System.out.println("Enter staffs details\n");
for(int i=0; i<2; i++){
System.out.println("Staff "+(i+1));
System.out.println("ID: \n");
int id=scan.nextInt();
System.out.println("Name: \n");
String name = scan.next();
f[i].setStaff(id, name);
}
System.out.println("Staff Details as follows: \n");
for(int i=0; i<2; i++){
System.out.println("Staff:\n "+(i+1));
System.out.printf("ID: %d\nName: %s\n ", f[i].getStaffID(), f[i].getName());
}
}
}
class Staff extends School{
private int staff_id;
private String name;
Staff(int max){
super(max);
}
void Staff(int id, String n){
staff_id = id;
name = n;
}
int getStaffID(){
return staff_id;
}
String getName(){
return name;
}
}
Comments
Leave a comment