package employee;
import java.util.Scanner;
public class Employee {
private String name;
Employee(){
}
Employee(String n){
name = n;
}
public String toString(){
return name;
}
void setName(String n){
name = n;
}
String getName(){
return name+" "+getSalary()+" "+getHours()+" "+getLeaveDays() ;
}
double getSalary(){
double salary = 50000;
return salary;
}
double getHours(){
double hours= 37.5;
return hours;
}
int getLeaveDays(){
System.out.println("Enter leave days\n");
Scanner scan = new Scanner(System.in);
int days = scan.nextInt();
return days;
}
void leaveApplication(){
System.out.println("18 workdays leaves \n");
System.out.println("Enter the number of days\n");
Scanner scan = new Scanner(System.in);
int day= getLeaveDays();
System.out.printf("You have successfully applied for: %d\n",day);
}
void work(){
System.out.println("Employees should work 37.5 hours per week. \n");
}
public static void main(String[] args) {
System.out.println("Select an option.\n1. Employee\n2. Manager\nSecretary \n");
Scanner scan = new Scanner(System.in);
int choice = scan.nextInt();
if(choice==1){
System.out.println("Enter employee name\n");
String name = scan.next();
Employee emp = new Employee(name);
System.out.println("Details as follows:\n"+emp.toString());
}
else if(choice==2){
System.out.println("Enter Manager's Name\n");
String name = scan.next();
Manager emp = new Manager(name);
System.out.println("Details as follows:\n"+emp.toString());
}
else if(choice == 3){
System.out.println("Enter Secretary's Name\n");
String name = scan.next();
Secretary emp = new Secretary(name);
System.out.println("Details as follows:\n"+emp.toString());
}
}
}
class Manager extends Employee{
Manager(){
}
Manager(String name){
super(name);
}
@Override
int getLeaveDays(){
System.out.println("Enter leave days\n");
Scanner scan = new Scanner(System.in);
int days = scan.nextInt();
return days;
}
@Override
double getSalary(){
double salary = 20000 + 50000;
return salary;
}
@Override
void leaveApplication(){
System.out.println("18 workdays leaves \n");
System.out.println("Enter the number of days\n");
Scanner scan = new Scanner(System.in);
int day= getLeaveDays();
System.out.printf("You have successfully applied for: %d\n",day);
}
@Override
void work(){
System.out.println("Enter the number of hours you have worked\n");
Scanner scan = new Scanner(System.in);
int workdays = scan.nextInt();
System.out.printf("You have worked for %d\n",workdays);
}
}
class Secretary extends Employee{
Secretary(){
}
Secretary( String name){
super(name);
}
@Override
void work(){
System.out.println("You have worked for "+ getHours());
}
@Override
double getHours(){
double hours = 40;
return hours;
}
}
Comments
Leave a comment