import sun.jvm.hotspot.utilities.KlassArray;
//
//import java.util.*;
//
//class Day {
// private String work;
//
// void set(String work) {
// this.work = work;
// }
//
// String get() {
// return work;
// }
//
// void show() {
// if (work == null)
// System.out.println("없습니다.");
// else
// System.out.println(work + "입니다");
// }
//
//}
//
//class MonthSchedule {
//
// int days;
//
// Scanner sc = new Scanner(System.in);
//
// Day d[] = new Day[31];
//
// public MonthSchedule(int days) {
//
// this.days = days;
//
// for (int i = 0; i < days; i++) {
//
// d[i] = new Day();
//
// }
//
// }
//
// void run() {
//
// System.out.println("이번달 스케쥴 관리 프로그램.");
//
// while (true)
//
// {
//
// System.out.print("할일(입력:1, 보기:2, 끝내기:3 >>");
//
// int num = sc.nextInt();
//
// if (num == 1)
// input();
//
// else if (num == 2)
// view();
//
// else if (num == 3) {
//
// System.out.println("프로그램을 종료합니다.");
// break;
// }
//
// }
//
// }
//
// void input() {
//
// System.out.print("날짜(1~30)?");
//
// int innum = sc.nextInt();
//
// System.out.print("할일(빈칸없이입력)?");
//
// String inwork = sc.next();
//
// d[innum-1].set(inwork);
//
// }
//
// void view() {
//
// System.out.print("날짜(1~30)?");
//
// int vinum = sc.nextInt();
// System.out.print(vinum+"일의 할일은");
// d[vinum-1].show();
//
//
// }
//
//}
//
//class Main {
//
// public static void main(String[] args) {
//
// MonthSchedule april = new MonthSchedule(30);
//
// april.run();
//
// }
//
//}
//
//import java.util.*;
//
//class Phone {
// String name;
// String tel;
// void set(String name, String tel) {
// this.name=name;
// this.tel=tel;
// }
//}
//
//class Main {
//
// public static void main(String[] args) {
//
// Scanner sc = new Scanner(System.in);
//
// System.out.print("인원수>>");
//
// int num = sc.nextInt();
// int i=0;
// Phone[] p = new Phone[num];
// for(i=0;i<p.length;i++)
// {
// p[i]= new Phone();
// }
//
// for (i = 0; i < num; i++)
// {
// System.out.print("이름과 전화번호(이름과 번호는 빈 칸없이 입력)>>");
//
// String name = sc.next();
// String tel = sc.next();
//
// p[i].set(name, tel);
//
// }
//
// System.out.println("저장되었습니다...");
//
// while (true) {
// int asd=0;
// System.out.print("검색할 이름>>");
//
// String name = sc.next();
//
// if (name.equals("그만")) {
//
// break;
//
// }
//
// for(i=0;i<p.length;i++)
// {
// if((p[i].name).equals(name))
// {
// System.out.println(name+"의 번호는"+p[i].tel+"입니다.");
// break;
// }
// else {
// asd++;
// }
//
// }
// if(asd==p.length)
// System.out.println(name+"이 없습니다.");
//
//
// }
//
//
// }
//}
//
//import java.util.*;
//
//class ArrayUtil{
// static int [] concat(int[] a, int[] b) {
// int [] ab=new int[a.length+b.length];
// for(int i=0;i<a.length;i++)
// {
// ab[i]=a[i];
//
// }
//
// for(int i=0;i<b.length;i++)
// {
// ab[i+a.length]=b[i];
// }
//
//
// return ab ; //배열 a와 b를 연결한 새로운 배열 리턴
// }
// static void print(int[] a) { System.out.print("[ ");for(int i=0;i<a.length;i++) System.out.print(a[i]+" ");
// System.out.println("]");
// /*배열 a출력*/ }
//
//}
//
//class Main{
// public static void main(String[] args) {
// int [] array1= {1,5,7,9};
// int [] array2= {3,6,-1,100,77};
// int [] array3=ArrayUtil.concat(array1, array2);
// ArrayUtil.print(array3);
// }
//}
//import java.util.*;
//
//class Dictionary{
// private static String [] kor = {"자바","1","2","3","4","5"};
// private static String [] eng = {"java","o","t","th","f","fi"};
// static String kor2Eng(String word) {
// int asd=-1;
// for(int i=0;i<kor.length;i++)
// {
// if((word).equals(kor[i]))
// {
// asd=i;
// break;
//
// }
//
// }
// if(asd==-1)
// {
// return "없습니다";
// }
// else {
// return eng[asd];
// }
//
// } /*검색 코드작성*/
//}
//
//class Main{
// public static void main(String[] args) {
// Scanner sc=new Scanner(System.in);
//
// System.out.println("한영 단어 검색 프로그램입니다.");
// while(true)
// {
// System.out.print("한글 단어?");
// String word=sc.next();
// if(word.equals("그만"))
// {
// break;
// }
//
// System.out.println(word+"은/는 "+Dictionary.kor2Eng(word));
//
//
//
//
//
// }
//
// }
//}
/*
//public > protected > private
import java.util.*;
class Calc{
protected int a; //자신을 상속받은 서브클래스만 접근 가능
int b;
void setValue(int a,int b) {
this.a=a;
this.b=b;
}
int calculate(int a,int b) {
return a+b;
}
}
class Add extends Calc{
int calculate() { //overriding 덮어쓰기 (메소드 재정의)
return a+b;
}
}
class Sub extends Calc{
int calculate() {
return a-b;
}
}
class Mul extends Calc{
int calculate() {
return a*b;
}
}
class Div extends Calc{
int calculate() {
return a/b;
}
}
class Main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("두 정수와 연산자를 입력하시오>>");
int a=sc.nextInt();
int b=sc.nextInt();
String cal=sc.next();
Calc c;
if(cal.equals("+"))
{
c=new Add();
}
else if(cal.equals("-"))
{
c=new Sub();
}
else if(cal.equals("*"))
{
c=new Mul();
}
else if(cal.equals("/"))
{
c=new Div();
}
System.out.println(c.calculate());
}
}
*/
/*
import java.util.*;
class Player {
String name;
String word;
void set(String name)
{
this.name = name;
}
String Getname() {
return name;
}
}
class Game {
Scanner sc = new Scanner(System.in);
void run(int num) {
Player[] p = new Player[num];
for (int i = 0; i < p.length; i++)
{
p[i] = new Player();
}
for (int i = 0; i < num; i++)
{
System.out.println("참가자의 이름 입력>>");
String name = sc.next();
p[i].set(name);
}
System.out.println("시작 단어는 아버지 입니다.");
int k=0;
String before="아버지";
while (true) {
for(int i=0;i<num;i++)
{
System.out.println(p[i].Getname() + ">>");
String after = sc.next();
if(before.charAt(before.length()-1)!=after.charAt(0)) {
System.out.println(p[i].Getname()+"의 패배");
return ;
}
before=after;
}
}
}
}
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("끝말잇기 게임을 시작합니다...");
System.out.println("게임에 참가하는 인원은 몇명입니까?>>");
int num = sc.nextInt();
Game g = new Game();
g.run(num);
}
}
*/
/*
import java.util.*;
class Point{
private int x,y;
// public Point() {
// System.out.println("Point의 생성자가 실행되었습니다.");
// }
public Point(int x, int y) {
this.x=x;
this.y=y;
}
void set(int x, int y) {
this.x=x;
this.y=y;
}
void showPoint() {
System.out.println("("+x+","+y+")");
}
}
class ColorPoint extends Point{
private String color;
public ColorPoint(int x, int y) {
//super(x,y);
System.out.println("ColorPoint의 생성자 실행 ");
}
void setColor(String color) {
this.color=color;
}
void showColorPoint() {
System.out.print(color);
showPoint();
}
}
class Main{
public static void main(String[] args) {
ColorPoint cp=new ColorPoint(2,2);
cp.set(3, 4);
cp.setColor("red");
cp.showColorPoint();
}
}
*/
/*
import java.util.*;
class Point{
private int x,y;
public Point() {
this.x=this.y=0;
}
public Point(int x,int y)
{
this.x=x;
this.y=y;
}
public void showPoint() {
System.out.println("("+x+","+y+")");
}
}
class ColorPoint extends Point{
private String color;
public ColorPoint(int x,int y ,String color) {
super(x,y);
this.color=color;
}
public void showColorPoint() {
System.out.print(color);
showPoint();
}
}
public class Main{
public static void main(String[] args) {
ColorPoint cp= new ColorPoint(5,6,"blue");
cp.showColorPoint();
}
}
*/
/*
import java.util.*;
class Shape{
public Shape next;
public Shape() {
next=null;
}
public void draw() {
System.out.println("Shape");
}
}
class Line extends Shape{
public void draw() {
System.out.println("Line");
}
}
class Rect extends Shape{
public void draw() {
System.out.println("Rect");
}
}
class Circle extends Shape{
public void draw() {
System.out.println("Circle");
}
}
public class Main{
static void paint(Shape p) {
p.draw();
}
public static void main(String[] args) {
Line line=new Line();
paint(line);
paint(new Shape());
paint(new Line());
paint(new Rect());
paint(new Circle());
}
}
*/
/*
import java.util.*;
class Weapon{
protected int fire() {
return 1;
}
}
class Cannon extends Weapon{
protected int fire()
{
return 10;
}
}
public class Main{
public static void main(String[] args) {
Weapon weapon;
weapon=new Weapon();
System.out.println("기본 무기의 살상 능력은 "+weapon.fire());
weapon=new Cannon();
System.out.println("대포의 살상 능력은 "+weapon.fire());
}
}
*/
/*
import java.util.*;
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);
}
public class Main 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;
}
public static void main(String[] args) {
Main c= new Main();
System.out.println(c.add(2, 3));
System.out.println(c.subtract(2, 3));
System.out.println(c.average(new int [] {2,3,4}));
}
}
오버로딩 vs 오버라이딩
같이 덮어쓰기(overwrite)
*/
/*
class Person{
void speak() {
System.out.println("im person....");
}
}
class Student extends Person{
void speak(int n) {
System.out.println(n+"iiii");
}
void speak() { //부모의 메소드 재정의
System.out.println("im student");
}
}
class Main{
public static void main(String[] args) {
Student s = new Student();
s.speak();
}
}
*/
/*
import java.util.*;
interface PhoneInterface{
final int TIMEOUT=10000;
void sendcall();
void receiveCall();
default void printLogo() {
System.out.println("** Phone **");
}
}
class SamsungPhone implements PhoneInterface{
@Override
public void sendcall() {
// TODO Auto-generated method stub
System.out.println("띠링");
}
@Override
public void receiveCall() {
// TODO Auto-generated method stub
System.out.println("전화");
}
public void flash() {
System.out.println("전화불");
}
}
public class Main{
public static void main(String[] args) {
SamsungPhone phone=new SamsungPhone();
phone.printLogo();
phone.sendcall();
phone.receiveCall();
phone.flash();
}
}
*/
/*
interface PhoneInterface{
final int TIMEOUT=10000;
void sendCall();
void receiveCall();
default void printLogo() {
System.out.println("** Phone **");
}
}
interface MobilePhoneInterface extends PhoneInterface{
void sendSMS();
void receiveSMS();
}
interface MP3Interface{
public void play();
public void stop();
}
class PDA{
public int calculate(int x, int y) {
return x+y;
}
}
class SmartPhone extends PDA implements MobilePhoneInterface, MP3Interface{
@Override
public void sendCall() {
// TODO Auto-generated method stub
System.out.println("따릉");
}
@Override
public void receiveCall() {
// TODO Auto-generated method stub
System.out.println("전화");
}
@Override
public void sendSMS() {
// TODO Auto-generated method stub
System.out.println("문자가");
}
@Override
public void receiveSMS() {
// TODO Auto-generated method stub
System.out.println("문자와");
}
@Override
public void play() {
// TODO Auto-generated method stub
System.out.println("음악연주");
}
@Override
public void stop() {
// TODO Auto-generated method stub
System.out.println("음악멈춤");
}
public void schedule() {
System.out.println("일정관리");
}
}
public class Main{
public static void main(String[] args) {
SmartPhone phone=new SmartPhone();
phone.printLogo();
phone.sendCall();
phone.play();
System.out.println("3과 5를 더하면"+phone.calculate(3, 5));
phone.schedule();
}
}
*/
//
//import java.util.*;
//class TV{
// private int size;
// public TV(int size) {this.size=size;}
// protected int getSize() {
// return size;
// }
//}
//
//class ColorTV extends TV{
//
// int color;
// ColorTV(int size,int color){
// super(size);
// this.color=color;
// }
//
// void printProperty() {
// System.out.println(getSize()+"인치"+color+"컬러");
// }
//}
//
//class Main{
// public static void main(String[] args) {
// ColorTV myTV=new ColorTV(32,1024);
// myTV.printProperty();
// }
//}
/*
import java.util.*;
class TV{
private int size;
public TV(int size) {this.size=size;}
protected int getSize() {
return size;
}
}
class ColorTV extends TV{
int color;
ColorTV(int size,int color){
super(size);
this.color=color;
}
void printProperty() {
System.out.println(getSize()+"인치"+color+"컬러");
}
}
class IPTV
class Main{
public static void main(String[] args) {
ColorTV myTV=new ColorTV(32,1024);
myTV.printProperty();
}
}
*/
/*
import java.util.*;
class TV {
private int size;
public TV(int size) {
this.size = size;
}
protected int getSize() {
return size;
}
}
class ColorTV extends TV {
int color;
ColorTV(int size, int color) {
super(size);
this.color = color;
}
}
class IPTV extends ColorTV{
String ad;
IPTV(String ad,int size,int color){
super(size,color);
this.ad=ad;
}
void printProperty() {
System.out.println("나의 IPTV는"+ad+"주소의"+getSize() + "인치" + color + "컬러");
}
}
class Main{
public static void main(String[] args) {
IPTV myTV=new IPTV("192.1.1.2",32,2048);
myTV.printProperty();
}
}
*/
/*
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 {
Won2Dollar(double ratio) {
this.ratio = ratio;
}
protected double convert(double src) {
return src / this.ratio;
}
protected String getSrcString() {
return "원";
}
protected String getDestString() {
return "달러";
}
}
class Main {
public static void main(String[] args) {
Won2Dollar toDollar = new Won2Dollar(1300);
toDollar.run();
}
}
*/
/*
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 Km2Mile extends Converter{
Km2Mile(double ratio){
this.ratio=ratio;
}
protected double convert(double src) {
return src/this.ratio;
}
protected String getSrcString() {
return "Km";
}
protected String getDestString() {
return "Mile";
}
}
class Main{
public static void main(String[] args) {
Km2Mile toMile = new Km2Mile(1.6);
toMile.run();
}
}
*/
/*
class Point{
private int x,y;
Point(int x,int y) {this.x=x; this.y=y;}
public int getX() {return x;}
public int getY() {return y;}
protected void move(int x,int y) {this.x=x;this.y=y;}
}
class ColorPoint extends Point{
String color;
ColorPoint(int x,int y,String color){
super(x,y);
this.color=color;
}
void setXY(int x,int y){
move(x,y);
}
void setColor(String color) {
this.color=color;
}
public String toString() {
return color+"색의 "+"("+getX()+","+getY()+")의 점";
}
}
class Main{
public static void main(String[] args) {
ColorPoint cp=new ColorPoint(5,5,"YELLOW");
cp.setXY(10,20);
cp.setColor("RED");
String str=cp.toString();
System.out.println(str+"입니다.");
}
}
*/
/*
class Point {
private int x, y;
Point(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
protected void move(int x, int y) {
this.x = x;
this.y = y;
}
}
class ColorPoint extends Point{
String color="black";
ColorPoint(int x,int y){
super(x,y);
}
public ColorPoint() {
super(0,0);
}
void setXY(int x, int y) {
move(x,y);
}
void setColor(String color) {
this.color=color;
}
public String toString(){
return color+"색의 "+"("+getX()+","+getY()+")의 점";
}
}
class Main {
public static void main(String[] args) {
ColorPoint zeroPoint = new ColorPoint();
System.out.println(zeroPoint.toString()+"입니다.");
ColorPoint cp=new ColorPoint(10,10);
cp.setXY(5, 5);
cp.setColor("RED");
System.out.println(cp.toString()+"입니다.");
}
}
*/
/*
class Point {
private int x, y;
Point(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
protected void move(int x, int y) {
this.x = x;
this.y = y;
}
}
class Point3D extends Point{
int z;
Point3D(int x,int y,int z){
super(x,y);
this.z=z;
}
void moveUp() {
this.z=z+1;
}
void moveDown() {
this.z=z-1;
}
void move(int x,int y,int z) {
move(x,y);
this.z=z;
}
public String toString() {
return "("+getX()+","+getY()+","+z+")";
}
}
class Main{
public static void main(String[] args) {
Point3D p=new Point3D(1,2,3);
System.out.println(p.toString()+"입니다.");
p.moveUp();
System.out.println(p.toString()+"입니다.");
p.moveDown();
p.move(10,10);
System.out.println(p.toString()+"입니다.");
p.move(100,200,300);
System.out.println(p.toString()+"입니다.");
}
}
*/
/*
import java.util.*;
class Point {
private int x, y;
Point(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
protected void move(int x, int y) {
this.x = x;
this.y = y;
}
}
class PositivePoint extends Point{
PositivePoint(){
super(0,0);
}
PositivePoint(int x,int y){
super(x,y);
if(x<0||y<0) super.move(0,0);
}
protected void move(int x,int y) {
if(x>0&&y>0) {
super.move(x,y);
}
}
public String toString() {
return "("+getX()+","+getY()+")";
}
}
class Main{
public static void main(String[] args) {
PositivePoint p=new PositivePoint();
p.move(10,10);
System.out.println(p.toString()+"입니다.");
p.move(-5,5);
System.out.println(p.toString()+"입니다.");
PositivePoint p2=new PositivePoint(-10,-10);
System.out.println(p2.toString()+"입니다.");
}
}
*/
abstract class PairMap{
protected String keyArray [];
protected String valueArray [];
abstract String get(String key);
abstract void put(String key, String value);
abstract String delete(String key);
abstract int length();
}
class Dictionary extends PairMap{
int capacity;
int len;
Dictionary(int capacity){
this.capacity=capacity;
len=0;
keyArray =new String[capacity];
valueArray=new String[capacity];
}
String get(String key) {
for(int i=0;i<len;i++) {
if(key.equals(keyArray[i])) {
return valueArray[i];
}
}
return null;
}
void put(String key,String value) {
for(int i=0;i<len;i++) {
if(key.equals(keyArray[i])) {
valueArray[i]=value;
}
}
keyArray[len]=key;
valueArray[len]=value;
len++;
}
String delete(String key) {
return ;
}
int length(){
return keyArray.length;
}
}
class Main{
public static void main(String[] args) {
Dictionary dic=new Dictionary(10);
dic.put("황기태", "자바");
dic.put("이재문", "파이선");
dic.put("이재문", "C++");
System.out.println("이재문의 값은"+dic.get("이재문"));
System.out.println("황기태의 값은"+dic.get("황기태"));
dic.delete("황기태");
System.out.println("황기태의 값은"+dic.get("황기태"));
}
}