0% found this document useful (0 votes)
29 views3 pages

Oop Hands On 6

The document defines a CollegeList program that allows the user to input details about employees, faculty, or students of a college. It creates classes for Person, Employee, Student, and Faculty that store their common attributes and any additional attributes specific to each type. The main method prompts the user to select whether they want to input details for an employee, faculty or student, then calls the appropriate constructor and getter/setter methods to populate an object with the user's input details.

Uploaded by

Darius Legaspi
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)
29 views3 pages

Oop Hands On 6

The document defines a CollegeList program that allows the user to input details about employees, faculty, or students of a college. It creates classes for Person, Employee, Student, and Faculty that store their common attributes and any additional attributes specific to each type. The main method prompts the user to select whether they want to input details for an employee, faculty or student, then calls the appropriate constructor and getter/setter methods to populate an object with the user's input details.

Uploaded by

Darius Legaspi
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/ 3

package collegelist;

import java.util.Scanner;

public class CollegeList extends Person{


    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        System.out.print("Press E for Employee, F for Faculty, or S for Student: ");


        String userInput = sc.nextLine();

         if (userInput.equalsIgnoreCase("E")) {
            System.out.println("Type employee's name, contact number, salary and department.");
            System.out.println("Press Enter after every input.");
      
            Employee e = new Employee();

            e.setName(name);
            e.setContactNum(contactNum);
            e.setSalary(salary);
            e.setDepartment(dep);
        
        } else if (userInput.equalsIgnoreCase("F")) {
            System.out.println("Type faculty's name, contact number, salary, department.");
            System.out.println("Press Enter after every input.");

            Faculty f = new Faculty();


      
            System.out.println("Press [Y] if the faculty member is regular/tenured or [N] if not.");
            String select = sc.nextLine();
      
            f.setName(name);
            f.setContactNum(contactNum);
            f.setSalary(salary);
            f.setDepartment(dep);
      
            if (select.equalsIgnoreCase("Y")) {
                f.setStatus(true);
            } else if (select.equalsIgnoreCase("N")) {
                f.setStatus(false);
      }
        } else if (userInput.equalsIgnoreCase("S")) {
            System.out.println("Type student's name, contact number, program and year level.");
            System.out.println("Press Enter after every input.");
      

            s.setName(name);
            s.setContactNum(contactNum);
            s.setProgram(program);
            s.setYearLevel(yearLevel);
      
            System.out.println("------------------------------");
    }

  }
}
package collegelist;

class Person {
    private String name;
    private String contactNum;

    public void setName(String n){


        name = n;
  }

    public String getName(){


        return name;
  }

    public void setContactNum(String c){


        contactNum = c;
  }

    public String getContactNum(){


        return contactNum;
  }

package collegelist;

class Employee extends Person{

    private double salary;


    private String department;

    public void setSalary(double s){


        salary = s;
  }

    public double getSalary(){


        return salary;
  }

    public void setDepartment(String d){


        department = d;
  }

    public String getDepartment(){


        return department;
    } 

package collegelist;

class Student extends Person {


    private String program;
    private int yearLevel;
  
    public void setProgram(String p){
        program = p;
  }
    public String getProgram(){
        return program;
  }

    public void setYearLevel(int y){


        yearLevel = y;
  }

    public int getYearLevel(){


        return yearLevel;
  }

package collegelist;

class Faculty extends Employee{


    private boolean status;
  
    public boolean isRegular(){
        return status;
  }

    public void setStatus(boolean s){


        status = s;
  }
  
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy