카페에서 심심해서 즉석으로 만든 프로그램이다.

하루동안 김대리가 제일 많이 하는 것 같다고 추정되는 문장을 샘플링 하여 시뮬레이팅 해 보았다.

자바와 스레드를 응용하였다.

다섯의 샘플 엽이가 랜덤 시간으로 랜덤 문장을 열심히 지껄이는 것을 그저 멍하니 바라보는 프로그램이다.


출력 예시


소스(이모티콘이 포함되어 있어 깨지는 것이 존재함)

import java.util.ArrayList;

public class Main {

    public static void main( String args[] )
    {
        ArrayList< Yeobi > m_alYeobi = new ArrayList();
        System.out.println( "나는 엽이다" );


        m_alYeobi.add( new Yeobi() );
        m_alYeobi.add( new Yeobi() );

        m_alYeobi.add( new Yeobi() );
        m_alYeobi.add( new Yeobi() );
        m_alYeobi.add( new Yeobi() );

        for( Yeobi y : m_alYeobi )

        {
            y.start();

        }
    }

}


import java.util.ArrayList;
import java.util.Random;

public class Yeobi extends Thread
{
    ArrayList< String > m_alComment = new ArrayList<String>();
    Random m_random = new Random();

    public Yeobi()
    {
        m_alComment.add( 
            "⊂_? \n" +
            "  \\ Λ_Λ \n" +
            "   \( ‘ㅅ' ) 두둠칫 \n" +
            "    > ⌒? \n" +
            "   /   へ\ \n" +
            "   /  / \\ \n" +
            "   ? ノ   ?_つ \n" +
            "  / /두둠칫 \n" +
            "  / /| \n" +
            " ( (? \n" +
            " | |、\ \n" +
            " | ? \ ⌒) \n" +
            " | |  ) / \n" +
            "\"`ノ )  L? \n"
        );
    m_alComment.add( "♥?( `Д' ?)" );
    m_alComment.add( "工エエェ(?ロ?)ェエエ工" );
    m_alComment.add( "우리 옥상가자!!(?▽?*)" );
    m_alComment.add( "우리 휴게실 가자!!(?▽?*)" );
    m_alComment.add( "얼음 홍차 마시러가자!!(?▽?*)" );
    m_alComment.add( "우리 먹을거 사러가자!!(?▽?*)" );
    m_alComment.add( "빵집 문 열었나?(?▽?*)" );
    m_alComment.add( "어이구 우리 쪼유~(?▽?*)" );
    m_alComment.add( "갈 수록 이뻐지는거같애!(?▽?*)" );
}

    public void run() {
        while( true )
        {
            System.out.println( m_alComment.get( m_random.nextInt( m_alComment.size() ) ) );
            try {
                sleep( m_random.nextInt( 10000 ) );
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}


'잉여 연구' 카테고리의 다른 글

[C]주사위 던지기  (0) 2013.03.29
C 숫자 퀴즈 예제  (0) 2013.03.13

+ Recent posts