Java_Week_3

신태원·2020년 10월 2일
1

Java

목록 보기
3/7
post-thumbnail

제어문

Structured Programming

  • Sequence: s1; s2;
  • Selection: if-then, if-then-else, switch
  • Repetiton: while, for, do-while

Sequence

Selection

  • if 문들

Reptiton

  • 반복문들(While, for, do while 등등)

Algorithm

  • 알고리즘은 취해야할 액션을 순서에 맞게 정리해둔 것이다.
  • 보통 Psuedocode를 쓰는데, 이것은 language로 변환이 가능한 표현이고, 사람에게 가까운 표현이다.

Exponentiation in Java

  • 제곱을 할 때, Math.pow(x,y)
    => Math가 대문자로 시작하는 이유는 클래스이기 때문에

Switch 문

  • 성적 등급별로 분류하기
  • 학생들의 시험 점수를 입력받아서 A-F의 성적별 학생 수와 학급평균을 출력하라.

GUI and Graphics Case Study

import javax.swing.JFrame;

public class DrawPanelTest
{
   public static void main( String[] args )
   {
      DrawPanel panel = new DrawPanel90;
      
      JFrame application = new JFrame();
      
      application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
      
      application.add( panel );
      application.setSize( 250, 250 );
      application.setVisible( true );
   }
}

import java.awt.Graphics;
import javax.swing.JPanel;

public class DrawPanel extends JPanel
{
   public void paintComponent( Graphics g )
   {
      super.paintComponent( g );
      
      int width = getWidth();
      int height = getHeight();
      
      g.drawLine( 0, 0, width, height );
      
      g.drawLine( 0, height, width, 0 );
   }
}
profile
일단 배우는거만 정리해보자 차근차근,,

0개의 댓글