U E D R , A S I H C RSS

데블스캠프2004/금요일

1.1. Java

1.1.1. 자바의 역사 및 특징

설마 이거 PT하셨나요? PT의 내용이 제 뒤통수를 때리는것 같군요.
자바 이름의 유래 및 개발 역사
에서는 유래가 없군요. C기반이 아니라, C++(문법), Smalltalk(vm) 의 철학을 반영합니다. Early History 는 마치 제임스 고슬링이 처음 만든것 처럼 되어 있군요. (SeeAlso Java Early history
개발 역사는 사장 직전의 Java를 구한 Servlet-JSP 기술이 빠졌고, 2001년 기준의 'JavaTM 2 Playtform 1.3,'는 현재 J2SE 로 이름을 바꾸었지요. 1.4는 1년도 전에 나오고, 1.5 가 8월에 발표됩니다. Java는 major upgrade 시 많은 부분이 변경됩니다
Java의 활용분야
는 더 슬퍼집니다. 보여주신 처음 예제가 거의다 ActiveX 구현물입니다.국내 Rich Client 분야는 전부 ActiveX에 주고 해외는 Flash에게 내주었습니다. 현재(2003) Java의 활용분야의 80% 이상은 applet이 아닌 서버 프레임웍의 J2EE와 모바일 프레임웍의 J2ME 입니다.

--NeoCoin
책을 보고 했는데 문제가 많았나 봅니다; 미숙한 발표여서 죄송합니다 (__) --iruril
저는 발표를 못봐서, 미숙한지 모릅니다. 그러나 PT가 그대로 진행되었다면, 사실과 다른 내용은 충격적이군요. 다음부터라도 반드시 타인에게 감수를 받거나, 자신에게 납득할수 있는 내용을 담으세요. --NeoCoin

1.1.2. 이클립스 사용법


1.1.2.1. 프로젝트 만들기
  • File -> New -> Project
    Java Project 선택


1.1.2.2. Class 만들기
  • File -> New -> Class

1.1.2.3. 컴파일 및 실행
  • Run -> Run As -> Java Application

1.1.2.4. 간단한 예제프로그램 작성 및 테스트
  • 테스트 프로그램(FirstJava.java)
    ~cpp           
    public class FirstJava {
      public static void main(String argv[]) {
        System.out.println("Hello world!");
      }
    }
    

1.1.3. 윈도우 프레임창 띄우기


  • JFrame의 show() 메소드 -> 프레임창을 보이게 한다.

  • JFrame의 setBounds(int x, int y, int weight, int height) 메소드
    -> int 전달인자가 순서대로 창을 띄우는 'x좌표', 'y좌표', '창넓이', '창높이' 를 가리킨다


  • ~cpp 
    import javax.swing.*;
    
    public class FirstJava extends JFrame{
    	public FirstJava()
    	{
    		
    	}
    	public static void main(String args[]) {
    		FirstJava helloWorld = new FirstJava();
    		helloWorld.setBounds(100,100,800,600);
    		helloWorld.show();
    		
    		
    	}
    }
    

  • BufferedReader - 캐릭터, 배열, 행을 버퍼링 하는 것에 의해, 캐릭터형 입력 스트림으로부터 텍스트를 읽어들인다


    ~cpp 
    package WindowFrame;
    
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    
    import javax.swing.JFrame;
    
    public class WindowFrame {
        static BufferedReader breader;
        
        public WindowFrame(String title, int width, int height) {
            JFrame f = new JFrame(title);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setSize(width, height);
            f.show();
        }
        
        public static int inputInt() throws IOException {
            breader
            	= new BufferedReader(new InputStreamReader(System.in));
            return Integer.parseInt(breader.readLine());
        }
        public static String inputString() throws IOException {
            return breader.readLine();        
        }
        
        public static void main(String[] args) {
            breader = new BufferedReader(new InputStreamReader(System.in));
            try {
    	        System.out.print("윈도우 이름 : ");
    	        String title = inputString();
    	        System.out.print("넓이 : ");
    	        int w = inputInt();
    	        System.out.print("높이 : ");
    	        int h = inputInt();
            
    	        new WindowFrame(title, w, h);
            } catch(IOException ex) {
                ex.printStackTrace();
            }
        }
    }
     
    Swing_JFrame.gif

1.1.4. 그림그리기


  • java.awt.Graphics 추가
  • public void paint(Graphics g) 메소드
    -> 윈도우 창에서 그리는 부분을 담당하는 함수이다.

  • g.drawString(String string, int s, int y) 메소드
    -> int 전달인자가 순서대로 문자열을 그리는 '왼쪽 위 점의 x좌표', '왼쪽 위 점의y좌표' 를 가리킨다

  • g.drawLine(int startX, int startY, int endX, int endY) 메소드
    -> int 전달인자가 순서대로 선을 리는 '처음점의 x좌표', '처음 점의y좌표', '끝점의 x좌표', '끝점의 y좌표' 를 가리킨다

  • g.drawOval(int x, int y, int weight, int height) 메소드
    -> int 전달인자가 순서대로 원 그리는 '왼쪽위 x좌표', '왼쪽위 y좌표', '원의 너비', '원의 높이' 를 가리킨다

  • g.fillOval(int x, int y, int weight, int height) 메소드
    -> int 전달인자가 순서대로 채워진 원을 그리는 '왼쪽위 x좌표', '왼쪽위 y좌표', '원의 너비', '원의 높이' 를 가리킨다


  • ~cpp 
    import java.awt.Graphics;
    import javax.swing.*;
    
    public class FirstJava extends JFrame{
    	public FirstJava()
    	{
    		
    	}
    	public static void main(String args[]) {
    		FirstJava helloWorld = new FirstJava();
    		helloWorld.setBounds(100,100,800,600);
    		helloWorld.show();
    		
    		
    	}
    	public void paint(Graphics g)
    	{
    		g.drawLine(100,100,300,300);
    		g.drawOval(200,200,400,400);
    		g.fillOval(500,500,100,100);
    	}
    }
    

1.1.5. 마우스 이벤트

  • addMouseListener 로 마우스 핸들러를 추가한다.
  • mouseClicked 메소드 -> 메우스를 클릭했을 경우 작동

    ~cpp 
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    
    import javax.swing.*;
    
    public class FirstJava extends JFrame{
    	public FirstJava()
    	{
            addMouseListener(new MouseAdapter() { 
                public void mouseClicked(MouseEvent e) {
                	int x = e.getX();
                	int y = e.getY();
                	
                	System.out.println("x 좌표 : " + x);
                	System.out.println("y 좌표 : " + y);
                }
    
            });
    	}
    	public static void main(String args[]) {
    		FirstJava helloWorld = new FirstJava();
    		helloWorld.setBounds(100,100,800,600);
    		helloWorld.show();
    		
    		
    	}
    }
    

1.1.6.1. 마우스를 클릭했을 경우 paint 함수를 호출

  • repaint() 메소드를 사용


~cpp 
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.*;

public class FirstJava extends JFrame{
	public FirstJava()
	{
        addMouseListener(new MouseAdapter() { 
            public void mouseClicked(MouseEvent e) {
            	int x = e.getX();
            	int y = e.getY();
            	
                  repaint();

            }

        });
	}
	public static void main(String args[]) {
		FirstJava helloWorld = new FirstJava();
		helloWorld.setBounds(100,100,800,600);
		helloWorld.show();
		
		
	}
         public void paint(Graphics g)
         {
                  System.out.print("Click!! ");
         }
}

2. 여는 이야기

Programmer's Toolkit

3. 실습 : Programming

~cpp 
6
0 0
222244451
999

Output

1 1 1 1 1 0
0 0 0 0 1 0    
0 0 0 0 1 0
0 0 0 0 2 0
0 0 0 1 0 0
0 0 0 0 0 0

5 
0 0 
22224444346 
999 

Output 
 
2 1 1 1 1  
1 0 0 0 2  
0 0 0 0 1  
0 0 0 0 1  
0 0 0 0 1  

3
0 0 
44220064 
999 

Output 
 
1 1 1  
1 1 1  
1 1 1  


4. Code Review - 어떤 생각을 하며 작성했나요?




5. 휴식

6. Structured Programming 소개

7. HIPO 예제

8. Paper Programming : HIPO 그리기

9. 자신이 HIPO 그린 것을 근거로 구현

10. 휴식

11. OOP 소개

12. 시연 : CRC Card

13. OOP Demo 1 : Message 를 날립시다~ (Python)



압축을 풀고, 해당 디렉토리에 들어간 뒤 c:\python23\python.exe 를 실행해주세요.
~cpp 
    from StarCraft import StarCraft 
    sc = StarCraft () 
    dir(sc)
    gateway = sc.createGateway () 
    dir(gateway)
    z1 = gateway.createZealot ()
    dir(z1)
    z1.move (160,160) 
    d1 = gateway.createDragoon () 
    dir(d1)
    d1.move (180,180) 
 
    z1.printHp() 
    z1.getPosition() 
    d1.printHp() 
    d1.getPosition() 
 
    z1.setAttackTarget(d1) 
    z1.printAttackTarget() 
    z1.getAttackTarget().printHp() 
    z1.getAttackTarget().getPosition() 
 
    z1.attack() 
    d1.printHp() 

14. OOP Demo 2 : Message 를 날립시다~ (Java & Eclipse)

15. 휴식

16. 자바 간단 설명

16.1. Eclipse 간단 설명

16.2. 자바 문법 간단 설명

16.2.1. Class 추가 방법

16.2.2. public static void main

16.2.3. 구현 : CRC 때 했었던 것

17. 휴식

18. interface 개념 추가 설명

19. 구현 : 다른 객체와의 대화 & 기능의 변화

20. 토론 & 발표

21. 마무리

22. 기타


1002
id : cvs_writer
pass: zeropager
를 만들어 두었으니, 시간 남는 사람들이 있다면 서로서로 소스 공유 해보는 경험도 좋을것 같다. 이렇게 공유된다 이런식 말이지
~cpp 
:pserver:cvs_writer@zeropage.org:/home/CVS
토요일까지만 개정 살려 둘께
--NeoCoin

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:57
Processing time 0.0420 sec