Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
//사원 관리 프로 그램
private Employee emp;
private Employee[] employee;
private int salary; //급여
public Main() {
emp = new Employee();
salary = 2000000; // 기본급여
}
//사원번호
public void setEmp(int emp)
{
this.emp.setCustNo(emp);
}
public int getEmp()
{
return emp.getCustNo();
}
//직급을 받자
public void setPosition(String str) {
this.emp.setPosition(str);
}
public String getPosition() {
return emp.getPosition();
}
public int Salary() { // 해당 입력값에 저장되있는 급여 값
if(emp.getPosition().equals("부장"))
{
this.salary=salary *5;
return this.salary;
}
else if(emp.getPosition().equals("차장"))
{
this.salary=salary *4;
return this.salary;
}
else if(emp.getPosition().equals("과장"))
{
this.salary=salary *3;
return this.salary;
}
else if(emp.getPosition().equals("대리"))
{
this.salary=salary *2;
return this.salary;
}
else if(emp.getPosition().equals("사원"))
{
this.salary=salary;
return this.salary;
}
return salary;
}
////////////getter
/*
public int getcustNo(int i) {
return employee[i].getCustNo();
}
public String getcustName(int i) {
return employee[i].getCustName();
}
public String getemploymentForm(int i) {
return employee[i].getEmploymentForm();
}
public String getdepartment(int i) {
return employee[i].getDepartment();
}
public int getSaly(int i) {
return employee[i].getSalary();
}
*/
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
Main ma = new Main();
String str = null; //프로그램 종료 및 초기 화면
String str1 = null; // 회원정보 검색
List<Employee> employeeList = new ArrayList<Employee>();
int people = 0;
do {
System.out.println("관리자모드 : 블라인드 , 사용자모드 : 1 선택");
int i =sc.nextInt();
if(i == 0) { //관리자 모드로
System.out.println("관리자로 접속했습니다.");
System.out.println("1.직원등록 2.직원조회 3.정보수정 4.회원삭제 5.첫 페이지(사원번호 입력으로)");
int num = sc.nextInt();
switch (num) {
case 1 :
System.out.println("사원수를 입력해주세요.");
people =sc.nextInt();
/*
System.out.println("직원을 등록해 주세요...");
System.out.print("사원 이름 :");
ma.emp.setCustName(sc.next());//
System.out.print("고용 형태 :");
ma.emp.setEmploymentForm(sc.next());
System.out.print("부 서 :");
ma.emp.setDepartment(sc.next());
System.out.print("직 급 :");
ma.emp.setPosition(sc.next());
System.out.println("사원 이름 고용 형태 부 서 직 급 급 여");
System.out.println(ma.emp.getCustName()+"\t"+ma.emp.getEmploymentForm()+"\t"+ma.emp.getDepartment()+
"\t"+ma.emp.getPosition()+"\t"+ ma.getSalary());
*/
employeeList.add(new Employee());
for(int arrayIndex = 0; arrayIndex < people; arrayIndex++)
{
System.out.print("사원 이름 :");
employeeList.get(arrayIndex).setCustName(sc.next());
System.out.print("고용 형태 :");
employeeList.get(arrayIndex).setEmploymentForm(sc.next());
System.out.print("부 서 :");
employeeList.get(arrayIndex).setDepartment(sc.next());
System.out.print("직 급 :");
ma.emp.setPosition(sc.next());
employeeList.get(arrayIndex).setPosition(ma.emp.getPosition());
System.out.print("급 여");
employeeList.get(arrayIndex).setSalary(ma.Salary());
System.out.println(employeeList.get(arrayIndex).getCustName()+"\t"+employeeList.get(arrayIndex).getEmploymentForm()+"\t"
+"\t"+employeeList.get(arrayIndex).getDepartment()+"\t"+employeeList.get(arrayIndex).getPosition()+"\t"
+employeeList.get(arrayIndex).getSalary());
}
/*
for(int j = 0 ; j < num2; i++)
{
employee1[j] = new Employee();
System.out.print("사원 이름 :");
employee1[j].setCustName(sc.next());
System.out.print("고용 형태 :");
employee1[j].setEmploymentForm(sc.next());
System.out.print("부 서 :");
employee1[j].setDepartment(sc.next());
System.out.print("직 급 :");
ma.emp.setPosition(sc.next());
employee1[j].setPosition(ma.emp.getPosition());
System.out.print("급 여");
employee1[j].setSalary(ma.Salary());
System.out.println(employee1[j].getCustName()+"\t"+employee1[j].getEmploymentForm()+"\t"+
employee1[j].getDepartment()+"\t"+employee1[j].getPosition()+"\t"+employee1[j].getSalary());
System.out.println("사원 이름 고용 형태 부 서 직 급 급 여");
}
*/
break;
case 2:
System.out.println("직원을 조회합니다.");
System.out.println("직원명을 적어주세요.");
str1 =sc.next();
for(int arrayIndex = 0; arrayIndex < employeeList.size(); arrayIndex++) {
if(str1.equals(employeeList.get(arrayIndex).getCustName())){
System.out.println(employeeList.get(arrayIndex).getCustName()+"\t"+employeeList.get(arrayIndex).getEmploymentForm()+"\t"
+"\t"+employeeList.get(arrayIndex).getDepartment()+"\t"+employeeList.get(arrayIndex).getPosition()+"\t"
+employeeList.get(arrayIndex).getSalary());
}
}
break;
case 3:
System.out.println("정보 수정합니다");
System.out.println("수정할 이름을 적어주세요");
String str2;
str2 = sc.next();
for(int arrayIndex = 0; arrayIndex < employeeList.size(); arrayIndex++) {
if(str2.equals(employeeList.get(arrayIndex).getCustName())) {
System.out.print("고용 형태 수정 :"); //정규직 비정규직
employeeList.get(arrayIndex).setEmploymentForm(sc.next());
System.out.print("직 급 수 정 :");
ma.emp.setPosition(sc.next());
employeeList.get(arrayIndex).setPosition(ma.emp.getPosition());
}
}
break;
case 4:
System.out.println("정보 삭제합니다");
System.out.println("삭제 할 이름을 적어주세요.");
String str3;
for(int arrayIndex = 0; arrayIndex < employeeList.size(); arrayIndex++) {
str3 = sc.next();
if(str3 == employeeList.get(arrayIndex).getCustName()){
employeeList.remove(arrayIndex);
arrayIndex--;
System.out.println("삭제되었습니다.");
}
}
break;
default:
System.out.println("번호를 잘못 입력하셨습니다.");
break;
}
}else if(i == 1) { //사용자 모드
int arrayIndex;
System.out.println("사용자 모드입니다.");
System.out.println("사원 검색만 가능합니다. 이름을 검색해주세요");
String str4;
str4 = sc.next();
for( arrayIndex = 0; arrayIndex < employeeList.size(); i++) {
if(str4.equals(employeeList.get(arrayIndex).getCustName()) ) {
System.out.println("회원이름 : " + employeeList.get(arrayIndex).getCustName()+"\t"+
"고용 형태: " + employeeList.get(arrayIndex).getEmploymentForm()+"\t"+
"부 서 :" + employeeList.get(arrayIndex).getDepartment()+"\t"
+"직 급 :" + employeeList.get(arrayIndex).getPosition()+"\t"+
"급 여" + employeeList.get(arrayIndex).getSalary());
break;
}
else if(str4 != employeeList.get(arrayIndex).getCustName()) {
System.out.println("검색한값이없습니다");
break;
}
}
}
System.out.println("처음화면으로 가시겠습니까? ' y ' 프로그램 종료 하시겠습니까? '아무거나 입력해주세요.' ");
str =sc.next();
} while(str.equals("y"));
}
}
getter /setter
public class Employee { //회원
private int custNo; //사원번호
private String custName; //이름
private String employmentForm; //고용형태
private String department; // 부서
private String position; //직급
private int salary; //급여
public int getCustNo() {
return custNo;
}
public void setCustNo(int custNo) {
this.custNo = custNo;
}
public String getCustName() {
return custName;
}
public void setCustName(String custName) {
this.custName = custName;
}
public String getEmploymentForm() {
return employmentForm;
}
public void setEmploymentForm(String employmentForm) {
this.employmentForm = employmentForm;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
}
출력 됬을때
관리자모드
직원등록
처음화면으로 가자
직원을 조회하자
직원 정보를 수정하자
정보를 삭제하자
사용자모드 - 이름으로 검색
'java' 카테고리의 다른 글
java - HashSet 이용한 성적관리 프로그램 (0) | 2020.08.15 |
---|---|
java - 스택 큐 (pop , push) 상속 ,추상 클래스 (0) | 2020.08.15 |
java - 성적 입력 class 사용(has a) (0) | 2020.08.08 |
java -성적 입출력 배열 담기 (0) | 2020.08.06 |
java -for문을 이용한 배열 출력하기 (0) | 2020.08.06 |