/*
/*
import java.util.*; //#include stdio.h
// 자동완성 : ctrl + space
//compile : ctrl+ F11
public class Main {
public static void main(String[] args) {
//자료형
int a=5;
long a1; //long long int
float b;
double c;
char d='a';
String e="안녕"; //문자열
System.out.println("hello world");
System.out.println("a 변수의 값은 "+a+"입니다.");
System.out.println("그리고 e의 값은 "+e+"입니다.");
//syso + ctrl + space
/////////////////////////////////////
Scanner sc = new Scanner(System.in); //스캐너 생성
int x;
x = sc.nextInt();
int y = sc.nextInt();
float z = sc.nextFloat();
String str= sc.next(); // 한 단어
String str1 = sc.nextLine(); //한 줄
System.out.println(y);
//////////////////////////////////
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String e= sc.next();
System.out.println(e);
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a + " " + b);
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[]args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
System.out.println(a + " " + a + " " + a);
if(a==1){
int cnt=0;
}
else if(a==3)
{
}
for(int i=0;i<5;i++) {
System.out.println(i);
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[]args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
if(a<=10)
{
System.out.println("정상");
}
else if(a<=20)
{
System.out.println("과체중");
}
else if(a>20)
{
System.out.println("비만");
}
}
}
*/
/*
--------------------------------------------------------------------------------
import java.util.*;
public class Main {
public static void main(String[]args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
if(a>=11&&a<=20)
{
System.out.println(a + "th");
}
else if(a==1||(a-1)%10==0)
{
System.out.println(a + "st");
}
else if(a==2||(a-2)%10==0)
{
System.out.println(a + "nd");
}
else if(a==3||(a-3)%10==0)
{
System.out.println(a + "rd");
}
else
{
System.out.println(a + "th");
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[]args) {
Scanner sc = new Scanner(System.in);
int a= sc.nextInt();
int b= sc.nextInt();
int i ;
int y=1;
for(i=1; i<=100; i++)
{
if(a*i==b)
{
System.out.println(a + "*" + i + "=" + b);
y--;
}
else if(b*i==a)
{
System.out.println(b + "*" + i + "=" + a);
y--;
}
else if(i==100&&y==1)
{
System.out.println("none");
}
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[]args) {
Scanner sc = new Scanner(System.in);
int x=0;
int a = sc.nextInt();
x=a;
int b = sc.nextInt();
x=x+b;
int c = sc.nextInt();
x=x+c;
int d = sc.nextInt();
x=x+d;
if(x==1)
{
System.out.println("도");
}
else if(x==2)
{
System.out.println("개");
}
else if(x==3)
{
System.out.println("걸");
}
else if(x==4)
{
System.out.println("윷");
}
else if(x==0)
{
System.out.println("모");
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if (c < a + b) {
if (a == b && b == c)
System.out.println("정삼각형");
else if (a == b || b == c || c == a)
System.out.println("이등변삼각형");
else if (a * a + b * b == c * c)
System.out.println("직각삼각형");
else
System.out.println("삼각형");
} else
System.out.println("삼각형아님");
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
if(a==0)
{
System.out.println("0");
}
else if(a>0)
{
System.out.println("양수");
}
else
{
System.out.println("음수");
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int x=0;
x=a+b+c;
if(x>1000)
{
if((x/100-10)%2==1)
{
System.out.println("그럭저럭");
}
else
{
System.out.println("대박");
}
}
else
{
if((x/100)%2==1)
{
System.out.println("그럭저럭");
}
else
{
System.out.println("대박");
}
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int arr1[] = new int[n]; //int n개 배열 생성
//위 코드는 c에서 int arr1[n];과 같습니다!
int [] arr = new int[50];
//int arr[50]; (x)
int map[][] = new int[50][50]; //이차원배열도 마찬가지!
//////////////////////////////////////////////////////
int array[] = {5,1,4,8,7};
// 배열의 길이 알아내기 가능!!array.length
for(int i=0;i<array.length;i++)
{
System.out.println(array[i]);
}
for(int k:array)
{
System.out.println(k);
}
//문자열
//str[0] (x)-> str.charAt(0)
String str;
str=sc.next(); //한 단어
str=sc.nextLine(); // 한 줄 입력받기
System.out.println(str.charAt(0));
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String a= sc.next();
int i, x=0, y=0;
for(i=0; i<a.length(); i++)
{
if(a.charAt(i)=='(')
{
x++;
}
else if(a.charAt(i)==')')
{
y++;
}
}
System.out.println(x + " " + y);
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String a = sc.nextLine();
int i, x=0;
for(i=0; i<a.length();i++)
{
if(a.charAt(i)=='l'&&a.charAt(i+1)=='o'&&a.charAt(i+2)=='v'&a.charAt(i+3)=='e')
{
x++;
}
}
System.out.println(x);
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String a = sc.nextLine();
// if (a.charAt(0) == 'I' && a.charAt(1) == 'O' && a.charAt(2) == 'I') {
if (a.equals("IOI")) {
System.out.println("IOI is the International Olympiad in Informatics.");
} else
{
System.out.println("I don't care.");
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String a = sc.nextLine();
//System.out.println("welcome!" + " " + a);
System.out.printf("%c",a.charAt(0)+2);
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String a = sc.nextLine();
int i;
for(i=0; i<a.length(); i++)
{
System.out.printf("%c",a.charAt(i)+2);
}
System.out.println("\n");
for(i=0; i<a.length(); i++)
{
System.out.printf("%c",a.charAt(i)*7%80+48);
}
}
}*/
/*
import java.util.*;
class Grade{
int math;
int science;
int english;
Grade(int math, int science, int english ) //생성자
{
this.math = math;
this.science = science;
this.english = english;
}
int average() {
return (math + science + english)/ 3 ;
}
}
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("수학, 과학, 영어 순으로 3개의 점수 입력>>");
int math = scanner.nextInt();
int science = scanner.nextInt();
int english = scanner. nextInt();
Grade me = new Grade(math, science, english);
System.out.println("평균은 " + me.average());
scanner.close();
}
}*/
/*
import java.util.*;
class Song{
//필드
String title;
String artist;
int year;
String country;
Song() //기본생성자
{
}
Song(String title) //1번 생성자
{
this.title = title;
}
Song(String title, String artist) //2번 생성자
{
this(title); //자신의 다른 생성자를 호출할때는, 맨 위에 적어야합니당!!
this.artist = artist;
}
Song(String title, String artist, int year, String country) // 모든 필드를 초기화하는 생성자
{
this(title,artist); //2번 생성자를 이용
this.year = year;
this.country = country;
}
void show() { //모든 필드를 출력하는 메소드
System.out.println(year+ "년 " + country + "국적의 " + artist + "가 부른 " + title);
}
}
public class Main{
public static void main(String[] args) {
Song me = new Song("Dancing Queen","ABBA", 1978, "스웨덴"); //객체 생성
me.show();
Song you = new Song("Merry Christmas");
Song you2 = new Song("노래제목","가수");
}
}
*/
/*
import java.util.*;
class Book {
String title;
String author;
void show() {System.out.println(title + " " + author); }
public Book() { //생성자1
this("","");
}
public Book(String title) { //생성자2
this(title, "작자미상");
}
public Book(String title, String author) { //생성자3
this.title = title;
this.author = author;
}
}
public class Main{
public static void main(String[] args) {
Book littleprince = new Book("어린왕자", "생택쥐페리");
littleprince.show();
Book loveStory = new Book("춘향전");
loveStory.show();
Book emptyBook = new Book();
emptyBook.show();
}
}
*/
/*
import java.util.*;
class TV {
int size;
String manufacturer;
public TV()
{
this(32,"LG");
}
public TV(String manufacturer) { //생성자2
this(32,manufacturer);
}
public TV(int size, String manufacturer) { //생성자3
this.size = size;
this.manufacturer = manufacturer;
System.out.println(size + "인치" + manufacturer);
}
}
public class Main{
public static void main(String[] args) {
}
}
class TV {
private int size;
public TV(int size) { this.size = size; }
protected int getSize() { return size; }
}
class ColorTV extends TV{
private int color;
public ColorTV(int size, int color) {
super (size);
this.color = color;
}
void printProperty() {
System.out.println(getSize() + "인치 " + color + "컬러");
}
}
class IPTV extends ColorTV{
private String IP;
public IPTV(String IP, int size, int color) {
super (size, color);
this.IP = IP;
}
void printProperty() {
System.out.print("나의 IPTV는" + IP +" 주소의 ");
super.printProperty();
}
}
class Main{
public static void main(String[] args) {
IPTV iptv = new IPTV("192.1.1.2", 32, 2048);
iptv.printProperty();
}
}
*/
/*
abstract class Calculator {
public abstract int add(int a, int b);
public abstract int subtract(int a, int b);
public abstract double average(int[] a);
}
class GoodCalc extends Calculator {
public int add(int a, int b) {
return a + b;
}
public int subtract(int a, int b) {
return a - b;
}
public double average(int[] a) {
double sum =0;
for(int i = 0; i <a.length; i++) { sum += a[i]; }
return sum/a.length;
}
}
class Main{
public static void main(String [] args) {
GoodCalc c = new GoodCalc();
System.out.println(c.add(2,3));
System.out.println(c.subtract(2,3));
System.out.println(c.average(new int [] { 2,3,4 }));
}
}
*/
/*
import java.util.Scanner;
abstract class Converter {
abstract protected double convert(double src);
abstract protected String getSrcString();
abstract protected String getDestString();
protected double ratio;
public void run() {
Scanner scanner = new Scanner(System.in);
System.out.println(getSrcString() + "을 " + getDestString() + "로 바꿉니다.");
System.out.println(getSrcString() + "을 입력하세요>> ");
double val = scanner.nextDouble();
double res = convert(val);
System.out.println("변환결과: " + res + getDestString() + "입니다");
scanner.close();
}
}
class Won2Dollar extends Converter {
public Won2Dollar(double ratio) {
this.ratio = ratio;
}
protected double convert(double src){
return src/ratio;
}
protected String getSrcString() {
return "원";
}
protected String getDestString() {
return "달러";
}
}
class Main{
public static void main(String[] args) {
Won2Dollar toDollar = new Won2Dollar(1200);
toDollar.run();
}
}*/
/*
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Main extends JFrame {
private final int FLYING_UNIT = 10;
private JLabel la = new JLabel ("Hello");
public Main() {
setTitle("상 하 좌 우 키를 이용하여 텍스트를 움직이기");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300,300);
setVisible(true);
Container c = getContentPane();
c.setLayout(null);
c.addKeyListener(new MykeyListener());
la.setLocation(50,50);
la.setSize(100,20);
c.add(la);
//key리스너 사용시 꼭 써야하는 부분!!
c.setFocusable(true);
c.requestFocus();
}
class MykeyListener extends KeyAdapter{
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
int x = la.getX();
int y = la.getY();
if(keyCode==KeyEvent.VK_UP && y>10) {
la.setLocation(x, y-10);
}
else if(keyCode==KeyEvent.VK_DOWN && y<240) {
la.setLocation(x, y+10);
}
else if(keyCode==KeyEvent.VK_LEFT && x>10) {
la.setLocation(x-10, y);
}
else if(keyCode==KeyEvent.VK_RIGHT && x<250) {
la.setLocation(x+10, y);
}
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Main extends JFrame {
private JLabel la = new JLabel ("Hello");
public Main() {
setTitle("MouseListner와 MouseMotionListener 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300,300);
setVisible(true);
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.addMouseListener(new MyMouseListener());
c.addMouseMotionListener(new MyMouseListener());
c.add(la);
}
class MyMouseListener extends MouseAdapter implements MouseMotionListener{
public void mouseClicked(MouseEvent e) {
if(e.getClickCount()==2) {
la.setForeground(Color.green);
System.out.println("더블클릭됨!");
}
}
public void mouseDragged(MouseEvent e) {
la.setText("MouseDragged ("+e.getX()+","+e.getY()+")");
}
public void mouseMoved(MouseEvent e) {
la.setText("MouseMoved ("+e.getX()+","+e.getY()+")");
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Main extends JFrame {
private JLabel la = new JLabel ("Hello");
public Main() {
setTitle("MouseListner와 MouseMotionListener 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300,300);
setVisible(true);
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.addMouseListener(new MyMouseListener());
c.addMouseMotionListener(new MyMouseListener());
c.add(la);
}
class MyMouseListener extends MouseAdapter implements MouseMotionListener{
public void mouseClicked(MouseEvent e) {
if(e.getClickCount()==2) {
la.setForeground(Color.green);
System.out.println("더블클릭됨!");
}
}
public void mouseDragged(MouseEvent e) {
la.setText("MouseDragged ("+e.getX()+","+e.getY()+")");
}
public void mouseMoved(MouseEvent e) {
la.setText("MouseMoved ("+e.getX()+","+e.getY()+")");
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Main extends JFrame {
private JLabel la = new JLabel ("Love Java");
public Main() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300,300);
setVisible(true);
Container c = getContentPane();
c.setLayout(new FlowLayout());
la.addMouseListener(new MyMouseListener());
c.add(la);
}
class MyMouseListener extends MouseAdapter {
public void mouseEntered(MouseEvent e) {
la.setText("사랑해");
}
public void mouseExited(MouseEvent e) {
la.setText("Love Java");
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Main extends JFrame {
public Main() {
setTitle("드래깅동안 YELLOW 멈추면 GREEN으로 바꾸기");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300,300);
setVisible(true);
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.addMouseMotionListener(new MyMouseListener());
c.setBackground(Color.GREEN);
}
class MyMouseListener implements MouseMotionListener {
public void mouseDragged(MouseEvent e) {
Container c = getContentPane();
c.setBackground(Color.YELLOW);
}
public void mouseMoved(MouseEvent e) {
Container c = getContentPane();
c.setBackground(Color.GREEN);
}
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Main extends JFrame {
private final int FLYING_UNIT = 10;
private JLabel la = new JLabel ("Love Java");
public Main() {
setTitle("Left 키로 문자열 교체");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300,300);
setVisible(true);
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.addKeyListener(new MykeyListener());
la.setLocation(50,50);
la.setSize(100,20);
c.add(la);
c.setFocusable(true);
c.requestFocus();
}
class MykeyListener extends KeyAdapter{
int i;
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
if(keyCode==KeyEvent.VK_LEFT) {
i++;
}
if(i%2==0)
{
la.setText("Love Java");
}
else if(i%2==1)
{
la.setText("avaJ evoL");
}
}
}
public static void main(String[] args) {
new Main();
}
}*/
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Main extends JFrame {
private final int FLYING_UNIT = 10;
private JLabel la = new JLabel ("Love Java");
public Main() {
setTitle("Left 키로 문자열 교체");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300,300);
setVisible(true);
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.addKeyListener(new MykeyListener());
la.setLocation(50,50);
la.setSize(100,20);
c.add(la);
c.setFocusable(true);
c.requestFocus();
}
class MykeyListener extends KeyAdapter{
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
if(keyCode==KeyEvent.VK_LEFT) {
String original = la.getText();
String after = original.substring(1)+original.charAt(0);
la.setText(after);
}
}
}
public static void main(String[] args) {
new Main();
}
}