티스토리 뷰
항상 그렇지만 단어선택은 웅장하게.. 그러나 거짓말은 없게.. 어디서 배웠는진 몰라도 참 잘배웠다ㅋ
은행업무 시뮬레이션이라.. Wow..
컴퓨터공학과 2010151035 장용하.
<class Main>
import java.util.*;
import java.io.*;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Client[] cl = new Client[50];
int clCnt = 12;
cl[0] = new Client("김장독", "입금", "1000");
cl[1] = new Client("장독김", "입금", "2000");
cl[2] = new Client("독김장", "입금", "3000");
cl[3] = new Client("갈매기", "출금", "4000");
cl[4] = new Client("매기갈", "출금", "5000");
cl[5] = new Client("기갈매", "출금", "6000");
cl[6] = new Client("항정살", "신규", "7000");
cl[7] = new Client("정살항", "신규", "8000");
cl[8] = new Client("살항정", "신규", "9000");
cl[9] = new Client("안심등심", "대출", "10000");
cl[10] = new Client("심등심안", "대출", "11000");
cl[11] = new Client("등심안심", "대출", "12000");
// ㄴ 총 10개 이상의 데이터 생성
String yn = null;
String str = null;
String name = null;
String work = null;
String money = null;
BufferedReader reader = new BufferedReader(new
InputStreamReader(System.in));
System.out.printf("기본외, 추가 데이터 입력 하시겠습니까?(y/n) : ");
try {
yn = reader.readLine();
if(yn.equals("y")) {
while(true){
System.out.printf("이름 : ");
name = reader.readLine();
System.out.printf("작업 : ");
work = reader.readLine();
System.out.printf("돈 : ");
money = reader.readLine();
cl[clCnt++] = new Client(name, work, money);
System.out.printf("추가 데이터 입력 하시겠습니까?(y/n) : ");
yn = reader.readLine();
if(yn.equals("n")) {
break;
}
}
} // ㄴ 데이터를 입력할 때, client 클래스에 데이터를 넣는 절차.
System.out.printf("찾을분 성함을 입력하세요 : ");
str = reader.readLine();
}
catch(IOException e) {
System.err.println("키보드 입력 에러");
}
// ㄴ 데이터를 입력받음
LinkedList<Client> newC = new LinkedList<Client>();
LinkedList<Client> inOut = new LinkedList<Client>();
LinkedList<Client> loarn = new LinkedList<Client>();
// ㄴ 총 3개의 큐 생성
for(int i=0; i<3; i++) {
inOut.offer(cl[i]);
inOut.offer(cl[i+3]);
newC.offer(cl[i+6]);
loarn.offer(cl[i+9]);
}
// ㄴ 기본 데이터를 큐에 저장 완료.
for(int i=12; i<clCnt; i++) {
if(cl[i].getWork() == "신규") {
newC.offer(cl[i]);
}
else if(cl[i].getWork() == "대출") {
loarn.offer(cl[i]);
}
else {
inOut.offer(cl[i]);
}
}
// ㄴ 입력한 데이터가 있다면 또한 큐에 저장.
HashMap<String, HashData> hashtable =
new HashMap<String, HashData>();
Client temp;
while(!inOut.isEmpty()) {
temp = inOut.poll();
hashtable.put(temp.getName(),
new HashData(temp.getWork(), temp.getMoney()));
}
while(!newC.isEmpty()) {
temp = newC.poll();
hashtable.put(temp.getName(),
new HashData(temp.getWork(), temp.getMoney()));
}
while(!loarn.isEmpty()) {
temp = loarn.poll();
hashtable.put(temp.getName(),
new HashData(temp.getWork(), temp.getMoney()));
}
// ㄴ 큐에서 꺼내어 해쉬테이블에 저장
HashData data = hashtable.get(str);
System.out.println("작업 | 금액");
System.out.println(data);
// ㄴ 데이터를 찾아옴
}
}
<class Client>
public class Client {
private String name;
private String work;
private String money;
Client(String name, String work, String money) {
this.name = name;
this.work = work;
this.money = money;
}
public String toString() {
String str = new String(name);
return str;
}
public String getName(){
return name;
}
public String getWork(){
return work;
}
public String getMoney(){
return money;
}
}
<class HashData>
public class HashData {
private String work;
private String money;
HashData(String work, String money) {
this.work = work;
this.money = money;
}
public String toString() {
String str = new String(work + " | " + money);
return str;
}
}
<실행화면>
1. 검색만을 하는 경우
2. 데이터를 입력하는 경우
'잊어버린 과거' 카테고리의 다른 글
[과제]웹프로그래밍. JSP 웹 사이트 어플리케이션(제안서발표, 중간발표) (0) | 2013.12.26 |
---|---|
[과제]웹프로그래밍. JSP기반 BMI 측정 소프트웨어 (0) | 2013.12.26 |
[과제]웹프로그래밍. BMI 측정 소프트웨어 (0) | 2013.12.26 |
[과제]컴퓨터활용. 자유주제 프레젠테이션 (1) | 2013.12.26 |
[과제]JAVA. 은행 계좌관리 소프트웨어 (0) | 2013.12.26 |
[과제]JAVA. 미디어 대여 시뮬레이션 (0) | 2013.12.26 |
[과제]윈도우프로그래밍. MFC 프로그래밍 교육용 소스코드 (0) | 2013.12.24 |
[과제]윈도우프로그래밍. 해양 구조물 부식방지 시스템(제안서3, 최종결과) (0) | 2013.12.24 |
[과제]윈도우프로그래밍. 해양 구조물 부식방지 시스템(제안서 2) (0) | 2013.12.24 |
[과제]윈도우프로그래밍. 해양 구조물 부식방지 시스템(제안서 1) (0) | 2013.12.24 |