직업은 선물 트레이더

[과제]JAVA. 해쉬테이블 기반 은행업무 시뮬레이션

잊어버린 과거

항상 그렇지만 단어선택은 웅장하게.. 그러나 거짓말은 없게.. 어디서 배웠는진 몰라도 참 잘배웠다ㅋ

 

은행업무 시뮬레이션이라.. 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. 데이터를 입력하는 경우


 

은행업무 시뮬레이션 데이터 입력