Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 스킨 스쿠버
- 베트남어
- php thumbnail
- Lift
- node.js web framework
- nodejs express
- ajax
- Cross
- scala
- 명사 추출기
- express for node.js
- 명사 뽑아내기
- 도커
- C/C++
- ejb
- Eclipse
- 나의 프로젝트
- iBatis
- 책이야기
- 명사 분석기
- docker
- rss
- ror실행
- flex3
- 나의 취미
- 메일왕창보내는법
- 주식이야기
- 디즈니씨
- php
- Node.js
Archives
- Today
- Total
nkdk의 세상
자바 Language 8일째 2번 본문
package inter;
public interface volume2 extends AdvanceVolume { // 인터페이스 끼리는 이와 같이 상속 받을 수 있다.
public String VOL="볼륨"; // final static 이다.
public void volumeUp(int level);
void volumeDown(int level);
// void aa() {}; // 이건 못 들어 온다.
}
package inter;
public interface Flyer {
int FAST=100;
public void fly();
public boolean isAnimal();
}
package inter;
public class ball extends FlayerAdpter{
public void fly() {
System.out.println("야구공이 관중석으로");
}
public static void main(String[] args) {
ball balls=new ball();
balls.fly();
}
}
package inter;
public interface AdvanceVolume {
public void volumeOff();
public void volumeResume();
}
package inter;
public class Speaker implements volume{
private int volLevel;
public Speaker() {
volLevel=0;
}
public void volumeUp(int level) {
volLevel += level;
System.out.println("스피커 볼륨 업: "+ volLevel);
}
public void volumeDown(int level) {
volLevel -= level;
if(volLevel<0) volLevel=0;
System.out.println("스피커 볼륨 다운: "+ volLevel);
}
}
package inter;
public class FlyerUtil {
public static void show(Flyer f) {
f.fly();
System.out.println(f.isAnimal());
}
}
package inter;
public class volTest {
public static void main(String[] args) {
Radio radio=new Radio();
tv Tv=new tv();
Speaker speaker=new Speaker();
radio.volumeUp(3);
Tv.volumeUp(5);
speaker.volumeUp(7);
volume vo_r=radio;
vo_r.volumeDown(1);
System.out.println("\n인터페이스를 이용한 호출");
volume vol[]=new volume[3]; // new는 안되지만 데이터 타입으로 사용 할 수는 있다.
vol[0]=radio;
vol[1]=Tv;
vol[2]=speaker;
for(int i=0;i<vol.length;i++) {
vol[i].volumeUp(2);
}
}
}
package inter;
public class FlyerMain {
public static void main(String[] args) {
Bird b=new Bird();
b.fly();
Airplane ap=new Airplane();
ap.fly();
FlyerUtil.show(b);
System.out.println("\n-------------------");
Flyer f=new Bird();
f.fly();
FlyerUtil.show(f);
Bird bf=(Bird)f;
FlyerUtil.show(bf);
}
}
// 창을 제어 하고 콘트롤 하는 프레임 메소드들을 부르는 방법에 대해서 하겠습니다.
package inter;
import java.awt.*;
import java.awt.event.*; // 두개는 서로 다르다.
public class FrameInter extends Frame implements WindowListener, MouseListener {
public FrameInter() {
setBounds(150,150,300,200);
setVisible(true);
// 이벤트 핸들러 연결을 하겠습니다.
this.addWindowListener(this);
this.addMouseListener(this);
// java.awt에 프레임에 있는 메소드이다.
}
public static void main(String[] args) {
new FrameInter();
}
public void windowActivated(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}
public void windowClosing(WindowEvent e) {
System.exit(0);
}
public void windowDeactivated(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
public void mouseClicked(MouseEvent e) {
//this.setBackground(new Color(255,0,0));
int r=(int)(Math.random()*255); // 난수를 만듬 그리고 캐스팅을 해준다.
int g=(int)(Math.random()*255);
int b=(int)(Math.random()*255);
this.setBackground(new Color(r,g,b));
this.setTitle(r+" "+g+" "+b);
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
}
package inter;
import java.awt.*;
import java.awt.event.*;
public class FrameAdapter extends WindowAdapter {
Frame f;
public FrameAdapter() {
f=new Frame("제목");
f.setBounds(100,100,300,200);
f.setVisible(true);
f.addWindowListener(this);
// f.addMouseListener(this);
}
public void windowClosing(WindowEvent e) {
System.exit(0);
}
public static void main(String[] args) {
new FrameAdapter();
}
}
package inter;
import java.awt.*;
import java.awt.event.*;
// 문제 창에 마우스를 클릭하면 좌위쪽으로 계속 이동하는 프로그램을 작성하시오.
public class FrameAda2 extends MouseAdapter {
Frame f;
int a=100,b=100,c=300,d=200;
public FrameAda2() {
f=new Frame("제목");
f.setBounds(a,b,c,d);
f.setVisible(true);
f.addMouseListener(this);
}
public void mouseClicked(MouseEvent e) {
f.setLocation(this.a - 5 , this.b -5);
this.a -= 5;
this.b -= 5;
if (this.a< 6) {this.a = 500;}
if (this.b< 6) {this.b = 500;}
int r=(int)(Math.random()*255); // 난수를 만듬 그리고 캐스팅을 해준다.
int g=(int)(Math.random()*255);
int b=(int)(Math.random()*255);
f.setBackground(new Color(r,g,b));
f.setTitle(r+" "+g+" "+b);
}
public static void main(String[] args) {
new FrameAda2();
}
}
// 이상입니다. 오츠까레 사마데시따..
public interface volume2 extends AdvanceVolume { // 인터페이스 끼리는 이와 같이 상속 받을 수 있다.
public String VOL="볼륨"; // final static 이다.
public void volumeUp(int level);
void volumeDown(int level);
// void aa() {}; // 이건 못 들어 온다.
}
package inter;
public interface Flyer {
int FAST=100;
public void fly();
public boolean isAnimal();
}
package inter;
public class ball extends FlayerAdpter{
public void fly() {
System.out.println("야구공이 관중석으로");
}
public static void main(String[] args) {
ball balls=new ball();
balls.fly();
}
}
package inter;
public interface AdvanceVolume {
public void volumeOff();
public void volumeResume();
}
package inter;
public class Speaker implements volume{
private int volLevel;
public Speaker() {
volLevel=0;
}
public void volumeUp(int level) {
volLevel += level;
System.out.println("스피커 볼륨 업: "+ volLevel);
}
public void volumeDown(int level) {
volLevel -= level;
if(volLevel<0) volLevel=0;
System.out.println("스피커 볼륨 다운: "+ volLevel);
}
}
package inter;
public class FlyerUtil {
public static void show(Flyer f) {
f.fly();
System.out.println(f.isAnimal());
}
}
package inter;
public class volTest {
public static void main(String[] args) {
Radio radio=new Radio();
tv Tv=new tv();
Speaker speaker=new Speaker();
radio.volumeUp(3);
Tv.volumeUp(5);
speaker.volumeUp(7);
volume vo_r=radio;
vo_r.volumeDown(1);
System.out.println("\n인터페이스를 이용한 호출");
volume vol[]=new volume[3]; // new는 안되지만 데이터 타입으로 사용 할 수는 있다.
vol[0]=radio;
vol[1]=Tv;
vol[2]=speaker;
for(int i=0;i<vol.length;i++) {
vol[i].volumeUp(2);
}
}
}
package inter;
public class FlyerMain {
public static void main(String[] args) {
Bird b=new Bird();
b.fly();
Airplane ap=new Airplane();
ap.fly();
FlyerUtil.show(b);
System.out.println("\n-------------------");
Flyer f=new Bird();
f.fly();
FlyerUtil.show(f);
Bird bf=(Bird)f;
FlyerUtil.show(bf);
}
}
// 창을 제어 하고 콘트롤 하는 프레임 메소드들을 부르는 방법에 대해서 하겠습니다.
package inter;
import java.awt.*;
import java.awt.event.*; // 두개는 서로 다르다.
public class FrameInter extends Frame implements WindowListener, MouseListener {
public FrameInter() {
setBounds(150,150,300,200);
setVisible(true);
// 이벤트 핸들러 연결을 하겠습니다.
this.addWindowListener(this);
this.addMouseListener(this);
// java.awt에 프레임에 있는 메소드이다.
}
public static void main(String[] args) {
new FrameInter();
}
public void windowActivated(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}
public void windowClosing(WindowEvent e) {
System.exit(0);
}
public void windowDeactivated(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
public void mouseClicked(MouseEvent e) {
//this.setBackground(new Color(255,0,0));
int r=(int)(Math.random()*255); // 난수를 만듬 그리고 캐스팅을 해준다.
int g=(int)(Math.random()*255);
int b=(int)(Math.random()*255);
this.setBackground(new Color(r,g,b));
this.setTitle(r+" "+g+" "+b);
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
}
package inter;
import java.awt.*;
import java.awt.event.*;
public class FrameAdapter extends WindowAdapter {
Frame f;
public FrameAdapter() {
f=new Frame("제목");
f.setBounds(100,100,300,200);
f.setVisible(true);
f.addWindowListener(this);
// f.addMouseListener(this);
}
public void windowClosing(WindowEvent e) {
System.exit(0);
}
public static void main(String[] args) {
new FrameAdapter();
}
}
package inter;
import java.awt.*;
import java.awt.event.*;
// 문제 창에 마우스를 클릭하면 좌위쪽으로 계속 이동하는 프로그램을 작성하시오.
public class FrameAda2 extends MouseAdapter {
Frame f;
int a=100,b=100,c=300,d=200;
public FrameAda2() {
f=new Frame("제목");
f.setBounds(a,b,c,d);
f.setVisible(true);
f.addMouseListener(this);
}
public void mouseClicked(MouseEvent e) {
f.setLocation(this.a - 5 , this.b -5);
this.a -= 5;
this.b -= 5;
if (this.a< 6) {this.a = 500;}
if (this.b< 6) {this.b = 500;}
int r=(int)(Math.random()*255); // 난수를 만듬 그리고 캐스팅을 해준다.
int g=(int)(Math.random()*255);
int b=(int)(Math.random()*255);
f.setBackground(new Color(r,g,b));
f.setTitle(r+" "+g+" "+b);
}
public static void main(String[] args) {
new FrameAda2();
}
}
// 이상입니다. 오츠까레 사마데시따..