Skip to content

Commit

Permalink
1st upload
Browse files Browse the repository at this point in the history
original copy
  • Loading branch information
castello committed Feb 19, 2018
0 parents commit 4080cc1
Show file tree
Hide file tree
Showing 917 changed files with 26,456 additions and 0 deletions.
Binary file added flash/Array.exe
Binary file not shown.
Binary file added flash/Array.swf
Binary file not shown.
Binary file added flash/Initialization.exe
Binary file not shown.
Binary file added flash/Initialization.swf
Binary file not shown.
Binary file added flash/MemberVar.exe
Binary file not shown.
Binary file added flash/MemberVar.swf
Binary file not shown.
Binary file added flash/MultiDim.exe
Binary file not shown.
Binary file added flash/MultiDim.swf
Binary file not shown.
Binary file added flash/PrimitiveParam.exe
Binary file not shown.
Binary file added flash/PrimitiveParam.swf
Binary file not shown.
Binary file added flash/RecursiveCall.exe
Binary file not shown.
Binary file added flash/RecursiveCall.swf
Binary file not shown.
Binary file added flash/ReferenceParam.exe
Binary file not shown.
Binary file added flash/ReferenceParam.swf
Binary file not shown.
Binary file added flash/SerialNo.exe
Binary file not shown.
Binary file added flash/SerialNo.swf
Binary file not shown.
Binary file added flash/Super.exe
Binary file not shown.
Binary file added flash/Super.swf
Binary file not shown.
Binary file added flash/logo.swf
Binary file not shown.
Binary file added java_jungsuk3e_src_20170601.zip
Binary file not shown.
5 changes: 5 additions & 0 deletions source/ch1/Hello.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Hello {
public static void main(String[] args) {
System.out.println("Hello, world."); // È­¸é¿¡ ±ÛÀÚ¸¦ Ãâ·ÂÇÑ´Ù.
}
}
28 changes: 28 additions & 0 deletions source/ch10/CalendarEx1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import java.util.*;

class CalendarEx1 {
public static void main(String[] args)
{ // 기본적으로 현재날짜와 시간으로 설정된다.
Calendar today = Calendar.getInstance();
System.out.println("이 해의 년도 : " + today.get(Calendar.YEAR));
System.out.println("월(0~11, 0:1월): " + today.get(Calendar.MONTH));
System.out.println("이 해의 몇 째 주: " + today.get(Calendar.WEEK_OF_YEAR));
System.out.println("이 달의 몇 째 주: " + today.get(Calendar.WEEK_OF_MONTH));
// DATE와 DAY_OF_MONTH는 같다.
System.out.println("이 달의 몇 일: " + today.get(Calendar.DATE));
System.out.println("이 달의 몇 일: " + today.get(Calendar.DAY_OF_MONTH));
System.out.println("이 해의 몇 일: " + today.get(Calendar.DAY_OF_YEAR));
System.out.println("요일(1~7, 1:일요일): " + today.get(Calendar.DAY_OF_WEEK)); // 1:일요일, 2:월요일, ... 7:토요일
System.out.println("이 달의 몇 째 요일: " + today.get(Calendar.DAY_OF_WEEK_IN_MONTH));
System.out.println("오전_오후(0:오전, 1:오후): " + today.get(Calendar.AM_PM));
System.out.println("시간(0~11): " + today.get(Calendar.HOUR));
System.out.println("시간(0~23): " + today.get(Calendar.HOUR_OF_DAY));
System.out.println("분(0~59): " + today.get(Calendar.MINUTE));
System.out.println("초(0~59): " + today.get(Calendar.SECOND));
System.out.println("1000분의 1초(0~999): " + today.get(Calendar.MILLISECOND));

// 천분의 1초를 시간으로 표시하기 위해 3600000으로 나누었다.(1시간 = 60 * 60초)
System.out.println("TimeZone(-12~+12): " + (today.get(Calendar.ZONE_OFFSET)/(60*60*1000)));
System.out.println("이 달의 마지막 날: " + today.getActualMaximum(Calendar.DATE) ); // 이 달의 마지막 일을 찾는다.
}
}
26 changes: 26 additions & 0 deletions source/ch10/CalendarEx2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import java.util.*;

class CalendarEx2 {
public static void main(String[] args) {
// 요일은 1부터 시작하기 때문에, DAY_OF_WEEK[0]은 비워두었다.
final String[] DAY_OF_WEEK = {"", "일", "월", "화", "수", "목", "금", "토"};

Calendar date1 = Calendar.getInstance();
Calendar date2 = Calendar.getInstance();

// month의 경우 0부터 시작하기 때문에 8월인 경우, 7로 지정해야한다.
// date1.set(2015, Calendar.AUGUST, 15);와 같이 할 수도 있다.
date1.set(2015, 7, 15); // 2015년 8월 15일로 날짜를 설정한다.
System.out.println("date1은 "+ toString(date1) + DAY_OF_WEEK[date1.get(Calendar.DAY_OF_WEEK)]+"요일이고,");
System.out.println("오늘(date2)은 " + toString(date2) + DAY_OF_WEEK[date2.get(Calendar.DAY_OF_WEEK)]+"요일입니다.");

// 두 날짜간의 차이를 얻으려면, getTimeInMillis() 천분의 일초 단위로 변환해야한다.
long difference = (date2.getTimeInMillis() - date1.getTimeInMillis())/1000;
System.out.println("그 날(date1)부터 지금(date2)까지 " + difference +"초가 지났습니다.");
System.out.println("일(day)로 계산하면 " + difference/(24*60*60) +"일입니다."); // 1일 = 24 * 60 * 60
}

public static String toString(Calendar date) {
return date.get(Calendar.YEAR)+"년 "+ (date.get(Calendar.MONTH)+1) +"월 " + date.get(Calendar.DATE) + "일 ";
}
}
36 changes: 36 additions & 0 deletions source/ch10/CalendarEx3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import java.util.*;

class CalendarEx3 {
public static void main(String[] args) {
final int[] TIME_UNIT = {3600, 60, 1}; // 큰 단위를 앞에 놓는다.
final String[] TIME_UNIT_NAME = {"시간 ", "분 ", "초 "};

Calendar time1 = Calendar.getInstance();
Calendar time2 = Calendar.getInstance();

// time1의 시간을 10시 20분 30초로 설정한다.
time1.set(Calendar.HOUR_OF_DAY, 10);
time1.set(Calendar.MINUTE, 20);
time1.set(Calendar.SECOND, 30);

// time2의 시간을 20시 30분 10초로 설정한다.
time2.set(Calendar.HOUR_OF_DAY, 20);
time2.set(Calendar.MINUTE, 30);
time2.set(Calendar.SECOND, 10);

System.out.println("time1 :"+time1.get(Calendar.HOUR_OF_DAY)+"시 " + time1.get(Calendar.MINUTE) +"분 " + time1.get(Calendar.SECOND) + "초");
System.out.println("time2 :"+time2.get(Calendar.HOUR_OF_DAY)+"시 " + time2.get(Calendar.MINUTE) +"분 " + time2.get(Calendar.SECOND) + "초");

long difference = Math.abs(time2.getTimeInMillis() - time1.getTimeInMillis())/1000;
System.out.println("time1과 time2의 차이는 "+ difference +"초 입니다.");

String tmp = "";

for(int i=0; i < TIME_UNIT.length;i++) {
tmp += difference/TIME_UNIT[i]+ TIME_UNIT_NAME[i];
difference %= TIME_UNIT[i];
}

System.out.println("시분초로 변환하면 " + tmp + "입니다.");
}
}
30 changes: 30 additions & 0 deletions source/ch10/CalendarEx4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import java.util.*;

class CalendarEx4 {
public static void main(String[] args) {
Calendar date = Calendar.getInstance();

date.set(2005, 7, 31); // 2005년 8월 31일

System.out.println(toString(date));
System.out.println("= 1일 후 =");
date.add(Calendar.DATE, 1);
System.out.println(toString(date));

System.out.println("= 6달 전 =");
date.add(Calendar.MONTH, -6);
System.out.println(toString(date));

System.out.println("= 31일 후(roll) =");
date.roll(Calendar.DATE, 31);
System.out.println(toString(date));

System.out.println("= 31일 후(add) =");
date.add(Calendar.DATE, 31);
System.out.println(toString(date));
}

public static String toString(Calendar date) {
return date.get(Calendar.YEAR)+"년 "+ (date.get(Calendar.MONTH)+1) +"월 " + date.get(Calendar.DATE) + "일";
}
}
16 changes: 16 additions & 0 deletions source/ch10/CalendarEx5.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import java.util.*;

class CalendarEx5 {
public static void main(String[] args) {
Calendar date = Calendar.getInstance();

date.set(2015, 0, 31); // 2005³â 1¿ù 31ÀÏ
System.out.println(toString(date));
date.roll(Calendar.MONTH, 1);
System.out.println(toString(date));
}

public static String toString(Calendar date) {
return date.get(Calendar.YEAR)+"³â "+ (date.get(Calendar.MONTH)+1) +"¿ù " + date.get(Calendar.DATE) + "ÀÏ";
}
}
46 changes: 46 additions & 0 deletions source/ch10/CalendarEx6.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import java.util.*;

class CalendarEx6 {
public static void main(String[] args) {
if(args.length !=2) {
System.out.println("Usage : java CalendarEx6 2015 9");
return;
}
int year = Integer.parseInt(args[0]);
int month = Integer.parseInt(args[1]);

int START_DAY_OF_WEEK = 0;
int END_DAY = 0;

Calendar sDay = Calendar.getInstance(); // 시작일
Calendar eDay = Calendar.getInstance(); // 끝일

// 월의 경우 0 부터 11까지의 값을 가지므로 1을 빼주어야 한다.
// 예를 들어, 2004년 11월 1일은 sDay.set(2004, 10, 1);과 같이 해줘야 한다.
sDay.set(year, month-1, 1);
eDay.set(year, month, 1);

// 다음달의 첫날에서 하루를 빼면 현재달의 마지막 날이 된다.
// 12월 1일에서 하루를 빼면 11월 30일이 된다.
eDay.add(Calendar.DATE, -1);

// 첫 번째 요일이 무슨 요일인지 알아낸다.
START_DAY_OF_WEEK = sDay.get(Calendar.DAY_OF_WEEK);
// eDay에 지정된 날짜를 얻어온다.
END_DAY = eDay.get(Calendar.DATE);

System.out.println(" " + args[0] +"년 " + args[1] +"월");
System.out.println(" SU MO TU WE TH FR SA");

// 해당 월의 1일이 어느 요일인지에 따라서 공백을 출력한다.
// 만일 1일이 수요일이라면 공백을 세 번 찍는다.(일요일부터 시작)
for(int i=1; i < START_DAY_OF_WEEK; i++) {
System.out.print(" ");
}

for(int i=1, n=START_DAY_OF_WEEK ; i <= END_DAY; i++, n++) {
System.out.print((i < 10)? " "+i : " "+i );
if(n%7==0) System.out.println();
}
}
}
37 changes: 37 additions & 0 deletions source/ch10/CalendarEx7.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import java.util.*;

class CalendarEx7 {
public static void main(String[] args) {
if(args.length !=2) {
System.out.println("Usage : java CalendarEx7 2015 11");
return;
}

int year = Integer.parseInt(args[0]);
int month = Integer.parseInt(args[1]);

Calendar sDay = Calendar.getInstance(); // 시작일
Calendar eDay = Calendar.getInstance(); // 끝일

// 월의 경우 0 부터 11까지의 값을 가지므로 1을 빼줘야한다.
// 예를 들어, 2004년 11월 1일은 sDay.set(2004, 10, 1);과 같이 해줘야 한다.
sDay.set(year, month-1, 1); // 입력월의 1일로 설정한다.
// 입력월의 말일로 설정한다.
eDay.set(year, month-1, sDay.getActualMaximum(Calendar.DATE));
// 1일이 속한 주의 일요일로 날짜설정.
sDay.add(Calendar.DATE, -sDay.get(Calendar.DAY_OF_WEEK) + 1);
// 말일이 속한 주의 토요일로 날짜설정
eDay.add(Calendar.DATE, 7 - eDay.get(Calendar.DAY_OF_WEEK));

System.out.println(" " + year +"년 " + month +"월");
System.out.println(" SU MO TU WE TH FR SA");

//시작 일부터 마지막 일까지(sDay <= eDay) 1일씩 증가시키면서 일(Calendar.DATE)을 출력
for(int n=1; sDay.before(eDay) || sDay.equals(eDay); sDay.add(Calendar.DATE, 1)) {
int day = sDay.get(Calendar.DATE);
System.out.print((day < 10)? " "+day : " "+day );

if(n++%7==0) System.out.println(); // 7일치를 찍고 나서 줄을 바꾼다.
}
} // main
}
13 changes: 13 additions & 0 deletions source/ch10/CalendarEx8.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class CalendarEx8 {
public static void main(String[] args){
String date1 = "201508";
String date2 = "201405";

// 년과 월을 substring으로 잘라서 정수로 변환한다.
// 년에 12를 곱해서 월로 변환한 다음에 뺄셈을 하면 개월차를 구할 수 있다.
int month1 = Integer.parseInt(date1.substring(0,4))* 12 + Integer.parseInt(date1.substring(4));
int month2 = Integer.parseInt(date2.substring(0,4))* 12 + Integer.parseInt(date2.substring(4));

System.out.println(date1 +"과 " + date2 + "의 차이는 " + Math.abs(month1-month2) + "개월 입니다.");
}
}
84 changes: 84 additions & 0 deletions source/ch10/CalendarEx9.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
class CalendarEx9 {
public static void main(String[] args) {
System.out.println("2014. 5. 31 :" + getDayOfWeek(2014, 5, 31));
System.out.println("2012. 6. 1 :" + getDayOfWeek(2012, 6, 1));
System.out.println("2014. 5. 1 - 2014.4.28 :" + dayDiff(2014,5,1,2014,4,28));
System.out.println("2015. 6. 29 : "+convertDateToDay(2015, 6, 29));
System.out.println("735778 : "+convertDayToDate(735778));
}

// 각 달의 마지막일
public static int[] endOfMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

public static boolean isLeapYear(int year) {
return ((year%4==0)&&(year%100!=0)||(year%400==0));
}

public static int dayDiff(int y1, int m1, int d1, int y2, int m2, int d2) {
return convertDateToDay(y1, m1, d1) - convertDateToDay(y2, m2, d2);
}

public static int getDayOfWeek(int year, int month, int day) {
// 1~7의 값을 반환한다. 결과가 1이면 일요일이다.
return convertDateToDay(year, month, day)%7 + 1;
}

public static String convertDayToDate(int day) {
int year=1;
int month=0;
int numOfLeapYear =0; // 윤년의 수

while(true) {
int aYear = isLeapYear(year)? 366 :365;
if (day > aYear ) {
day-= aYear;
year++;
} else {
break;
}
}

while(true) {
int endDay = endOfMonth[month];
// 윤년이고 윤달이 포함되어 있으면, 1일을 더 뺀다.
if(isLeapYear(year) && month == 1) endDay++;

if(day > endDay) {
day -= endDay;
month++;
} else {
break;
}
}

return year+"-"+(month+1)+"-"+day;
}

public static int convertDateToDay(int year, int month, int day) {
int numOfLeapYear =0; // 윤년의 수

// 전년도까지의 윤년의 수를 구한다.
for(int i=1;i < year; i++) {
if(isLeapYear(i))
numOfLeapYear++;
}

// 전년도까지의 일 수를 구한다.
int toLastYearDaySum = (year-1) * 365 + numOfLeapYear;

// 올해의 현재 월까지의 일수 계산
int thisYearDaySum =0;

for(int i=0; i < month-1; i++) {
thisYearDaySum+=endOfMonth[i];
}

// 윤년이고, 2월이 포함되어 있으면 1일을 증가시킨다.
if (month > 2 && isLeapYear(year))
thisYearDaySum++;

thisYearDaySum+=day;

return toLastYearDaySum+thisYearDaySum;
}
}
18 changes: 18 additions & 0 deletions source/ch10/ChoiceFormatEx1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import java.util.*;
import java.text.*;

class n {
public static void main(String[] args) {
double[] limits = {60, 70, 80, 90}; // 낮은 값부터 큰 값의 순서로 적어야한다.
// limits, grades간의 순서와 개수를 맞추어야 한다.
String[] grades = {"D", "C", "B", "A"};

int[] scores = { 100, 95, 88, 70, 52, 60, 70};

ChoiceFormat form = new ChoiceFormat(limits, grades);

for(int i=0;i<scores.length;i++) {
System.out.println(scores[i]+":"+form.format(scores[i]));
}
} // main
}
15 changes: 15 additions & 0 deletions source/ch10/ChoiceFormatEx2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import java.util.*;
import java.text.*;

class ChoiceFormatEx2 {
public static void main(String[] args) {
String pattern = "60#D|70#C|80<B|90#A";
int[] scores = { 91, 90, 80, 88, 70, 52, 60};

ChoiceFormat form = new ChoiceFormat(pattern);

for(int i=0;i<scores.length;i++) {
System.out.println(scores[i]+":"+form.format(scores[i]));
}
} // main
}
33 changes: 33 additions & 0 deletions source/ch10/DateFormatEx1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import java.util.*;
import java.text.*;

class DateFormatEx1 {
public static void main(String[] args) {
Date today = new Date();

SimpleDateFormat sdf1, sdf2, sdf3, sdf4;
SimpleDateFormat sdf5, sdf6, sdf7, sdf8, sdf9;

sdf1 = new SimpleDateFormat("yyyy-MM-dd");
sdf2 = new SimpleDateFormat("''yy년 MMM dd일 E요일");
sdf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
sdf4 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");

sdf5 = new SimpleDateFormat("오늘은 올 해의 D번째 날입니다.");
sdf6 = new SimpleDateFormat("오늘은 이 달의 d번째 날입니다.");
sdf7 = new SimpleDateFormat("오늘은 올 해의 w번째 주입니다.");
sdf8 = new SimpleDateFormat("오늘은 이 달의 W번째 주입니다.");
sdf9 = new SimpleDateFormat("오늘은 이 달의 F번째 E요일입니다.");

System.out.println(sdf1.format(today)); // format(Date d)
System.out.println(sdf2.format(today));
System.out.println(sdf3.format(today));
System.out.println(sdf4.format(today));
System.out.println();
System.out.println(sdf5.format(today));
System.out.println(sdf6.format(today));
System.out.println(sdf7.format(today));
System.out.println(sdf8.format(today));
System.out.println(sdf9.format(today));
}
}
Loading

0 comments on commit 4080cc1

Please sign in to comment.