# PRIVATE
WEB 11,18
ROHA__
2010. 11. 18. 12:00
p266 Data κ°μ²΄μ μμ±κ³Ό λ©μλ
prototype : Data κ°μ²΄μ μμ± λΆμ¬(μνλ filedλ₯Ό μΆκ°ν μ μλ€. ) = JAVAμμλ βμμ±βμΌλ‘ η¨
ex) Array.prototype.comment = null // μλ‘μ΄ prototype μμ±μ commentλ³μ μ΄κΈ°κ° null ν λΉ
cmment νμ μ μΆκ°νκ³ μΆμ΄μ, prototype.commentλ‘ ν΄μ, Arrayκ° κ°κ³ μλ λ§΄λ²λ³μμΈλ₯, μ¬μ©νλ€.
*get() κ³μ΄ : κ°μ κ°μ Έμ¨λ€.
getYear() : λ λ(2κ°μ μ«μλ‘ 1970λ μ΄νμ λ λλ₯Ό νμ)
getMonth() : μ(0=1μ, 1=2μ, 2=3μλ‘ νμ)
getData() : μΌ(1μμ 31μ μ μλ‘ νμ)
getDay() :
getTime() : 1970. 1.1μΌ 0μ μ΄νμ μκ°μ ms(1000λΆμ 1μ΄)λ‘ νμ.
* set() κ³μ΄ : κ°μ μ§μ΄λ£λλ€.
class A{
private int a; (class A{} μμμλ§ μ¬μ©κ°λ₯νλ€.)
void setA(int a);
this a = a +10; (κ°μ 10μ λν΄μ κ°μ 리ν΄)
int getA(){
return a;
A.a = new A();
a.a = 10;
(μ΄λ°μμΌλ‘ μ¬μ©νμ§ μλλ€- λ³μκ° λ ΈμΆλμ΄ μκΈ°λλ¬Έμ, λͺ¨λ νλ‘κ·Έλ¨μ΄ a.aλ₯Ό μ°Έμ‘°νκ³ μκΈ° λλ¬Έμ aλ₯Ό bλ‘ λ°κΏλ ν μκ° μλ€.
-> λ©μλλ₯Ό ν΅ν΄μ μ¬μ©νλ€. )
a.setA(10);
System.out.print(a.getA()); //κ°μ κ°μ Έμ¨λ€.
(λ³μκ° λ ΈμΆλμ§ μμμ ε₯½, κ°μ λ€μνκ³ μΆμ λλ μμ κ²λ§ λ°κΎΈλ©΄ λλκΉ, μ 체μ μΈ νλ‘κ·Έλ¨μ κ³ μ³μ§ νμκ° μλ€. μμ μλ νλ‘κ·Έλ¨μ μ¬μ©μκ° λ³Ό νμκ° μκ³ , getν¨μλ§ λΆλ¬μ€λ©΄ λ¨.)
** get, set λ§λ€ κ·μΉ
: λ³μλͺ μ΄ ζζ, set,getμ΄λΌλ μ λμ¬λ₯Ό λΆμ΄κ³ , λ³μλͺ μ 첫 κΈμλ λλ¬Έμλ₯Ό μ§μ΄λ£λλ€.
ex) String name ζ setName , getName
---------------------
<HTML><HEAD><TITLE>Date κ°μ²΄</TITLE></HEAD>
<BODY bgcolor="Goldenrod"><H3> Date κ°μ²΄ μμ </H3>
<SCRIPT LANGUAGE="JavaScript">
<!--
today = new Date();
today.setYear(1000);
today.setMonth(0);
today.setDate(1);
today.setHours(1);
today.setMinutes(3);
today.setSeconds(25);
document.write("λ³κ²½ λ μ§ : " + (today.getYear() + 1900) + " λ " +
(today.getMonth() + 1) + " μ" + today.getDate() +"<P>");
document.write("λ³κ²½ μκ° : " + today.getHours() + " μ" +
today.getMinutes() + " λΆ" + today.getSeconds() + "<P>");
//μλ°μ€ν¬λ¦½νΈ λ-->
</SCRIPT></BODY></HTML>
-------------------------------
p270 String κ°μ²΄
λ³μ = βλ¬Έμμ΄"; String a = βν";
βλ¬Έμμ΄".μμ±[λ©μλ()]; βν". [μ¬μ©κ°λ₯ν λ©μλ λμ΄]
String κ°μ²΄μ μμ±κ³Ό λ©μλ();
- split(βꡬλΆλ¬Έμ") : ꡬλΆλ¬Έμλ‘ λ¬Έμμ΄ λΆλ¦¬
ex) a,b,c, μ΄λΌλ©΄ -> split(β,β) : β,β λ¨μλ‘ κ°μ λμ΄μ λ°μμ¨λ€.
-------------------------------------
<HTML><HEAD><TITLE>String κ°μ²΄ μ°μ΅</TITLE></HEAD>
<BODY><h3> λ€μν κΈμ λͺ¨μ</h3>
<SCRIPT LANGUAGE="JavaScript">
<!--
document.write(" BIG ".big() + "<BR>")
document.write(" SMALL ".small() + "<BR>")
document.write(" BOLD ".bold() + "<BR>")
document.write(" FIX ".fixed() + "<BR>")
document.write(" ITALICS ".italics() + "<BR>")
document.write(" STRIKE ".strike() + "<BR>")
document.write(" SUB ".sub() + "<BR>")
document.write(" SUPER ".sup() + "<BR>")
document.write(" FONTCOLOR = yellow".fontcolor("yellow") + "<BR>")
document.write(" FONTCOLOR = BLUE ".fontcolor("blue") + "<BR>")
document.write(" FONTCOLOR = RED ".fontcolor("red") + "<BR>")
document.write(" FONT SIZE 5 ".fontsize(5) + "<BR>")
document.write(" FONT SIZE 10 ".fontsize(10) + "<BR>")
document.write("νλκ³ ν¬κ²".big().fontcolor("blue")+"<BR>") //μ¬λ¬κ°μ λ©λ΄λ₯Ό μ¬μ©νκΈ° (. μ°μ°μλ₯Ό μ΄μ©)
document.write("μ΄ν€λ¦μ²΄μ κ°μ‘°λ₯Ό λΉ¨κ°μμΌλ‘".italics().strike().fontcolor("red")+"<BR>")
document.write("ν¬κΈ°λ 5μ΄λ©΄μ λ³Όλ체λ‘".fontsize(5).bold()+"<BR>")
// μλ°μ€ν¬λ¦½νΈ λ -->
</SCRIPT></BODY></HTML>
-----------------------------------------
prototype : Data κ°μ²΄μ μμ± λΆμ¬(μνλ filedλ₯Ό μΆκ°ν μ μλ€. ) = JAVAμμλ βμμ±βμΌλ‘ η¨
ex) Array.prototype.comment = null // μλ‘μ΄ prototype μμ±μ commentλ³μ μ΄κΈ°κ° null ν λΉ
cmment νμ μ μΆκ°νκ³ μΆμ΄μ, prototype.commentλ‘ ν΄μ, Arrayκ° κ°κ³ μλ λ§΄λ²λ³μμΈλ₯, μ¬μ©νλ€.
*get() κ³μ΄ : κ°μ κ°μ Έμ¨λ€.
getYear() : λ λ(2κ°μ μ«μλ‘ 1970λ μ΄νμ λ λλ₯Ό νμ)
getMonth() : μ(0=1μ, 1=2μ, 2=3μλ‘ νμ)
getData() : μΌ(1μμ 31μ μ μλ‘ νμ)
getDay() :
getTime() : 1970. 1.1μΌ 0μ μ΄νμ μκ°μ ms(1000λΆμ 1μ΄)λ‘ νμ.
* set() κ³μ΄ : κ°μ μ§μ΄λ£λλ€.
class A{
private int a; (class A{} μμμλ§ μ¬μ©κ°λ₯νλ€.)
void setA(int a);
this a = a +10; (κ°μ 10μ λν΄μ κ°μ 리ν΄)
int getA(){
return a;
}
}A.a = new A();
a.a = 10;
(μ΄λ°μμΌλ‘ μ¬μ©νμ§ μλλ€- λ³μκ° λ ΈμΆλμ΄ μκΈ°λλ¬Έμ, λͺ¨λ νλ‘κ·Έλ¨μ΄ a.aλ₯Ό μ°Έμ‘°νκ³ μκΈ° λλ¬Έμ aλ₯Ό bλ‘ λ°κΏλ ν μκ° μλ€.
-> λ©μλλ₯Ό ν΅ν΄μ μ¬μ©νλ€. )
a.setA(10);
System.out.print(a.getA()); //κ°μ κ°μ Έμ¨λ€.
(λ³μκ° λ ΈμΆλμ§ μμμ ε₯½, κ°μ λ€μνκ³ μΆμ λλ μμ κ²λ§ λ°κΎΈλ©΄ λλκΉ, μ 체μ μΈ νλ‘κ·Έλ¨μ κ³ μ³μ§ νμκ° μλ€. μμ μλ νλ‘κ·Έλ¨μ μ¬μ©μκ° λ³Ό νμκ° μκ³ , getν¨μλ§ λΆλ¬μ€λ©΄ λ¨.)
** get, set λ§λ€ κ·μΉ
: λ³μλͺ μ΄ ζζ, set,getμ΄λΌλ μ λμ¬λ₯Ό λΆμ΄κ³ , λ³μλͺ μ 첫 κΈμλ λλ¬Έμλ₯Ό μ§μ΄λ£λλ€.
ex) String name ζ setName , getName
---------------------
<HTML><HEAD><TITLE>Date κ°μ²΄</TITLE></HEAD>
<BODY bgcolor="Goldenrod"><H3> Date κ°μ²΄ μμ </H3>
<SCRIPT LANGUAGE="JavaScript">
<!--
today = new Date();
today.setYear(1000);
today.setMonth(0);
today.setDate(1);
today.setHours(1);
today.setMinutes(3);
today.setSeconds(25);
document.write("λ³κ²½ λ μ§ : " + (today.getYear() + 1900) + " λ " +
(today.getMonth() + 1) + " μ" + today.getDate() +"<P>");
document.write("λ³κ²½ μκ° : " + today.getHours() + " μ" +
today.getMinutes() + " λΆ" + today.getSeconds() + "<P>");
//μλ°μ€ν¬λ¦½νΈ λ-->
</SCRIPT></BODY></HTML>
-------------------------------
p270 String κ°μ²΄
λ³μ = βλ¬Έμμ΄"; String a = βν";
βλ¬Έμμ΄".μμ±[λ©μλ()]; βν". [μ¬μ©κ°λ₯ν λ©μλ λμ΄]
String κ°μ²΄μ μμ±κ³Ό λ©μλ();
- split(βꡬλΆλ¬Έμ") : ꡬλΆλ¬Έμλ‘ λ¬Έμμ΄ λΆλ¦¬
ex) a,b,c, μ΄λΌλ©΄ -> split(β,β) : β,β λ¨μλ‘ κ°μ λμ΄μ λ°μμ¨λ€.
-------------------------------------
<HTML><HEAD><TITLE>String κ°μ²΄ μ°μ΅</TITLE></HEAD>
<BODY><h3> λ€μν κΈμ λͺ¨μ</h3>
<SCRIPT LANGUAGE="JavaScript">
<!--
document.write(" BIG ".big() + "<BR>")
document.write(" SMALL ".small() + "<BR>")
document.write(" BOLD ".bold() + "<BR>")
document.write(" FIX ".fixed() + "<BR>")
document.write(" ITALICS ".italics() + "<BR>")
document.write(" STRIKE ".strike() + "<BR>")
document.write(" SUB ".sub() + "<BR>")
document.write(" SUPER ".sup() + "<BR>")
document.write(" FONTCOLOR = yellow".fontcolor("yellow") + "<BR>")
document.write(" FONTCOLOR = BLUE ".fontcolor("blue") + "<BR>")
document.write(" FONTCOLOR = RED ".fontcolor("red") + "<BR>")
document.write(" FONT SIZE 5 ".fontsize(5) + "<BR>")
document.write(" FONT SIZE 10 ".fontsize(10) + "<BR>")
document.write("νλκ³ ν¬κ²".big().fontcolor("blue")+"<BR>") //μ¬λ¬κ°μ λ©λ΄λ₯Ό μ¬μ©νκΈ° (. μ°μ°μλ₯Ό μ΄μ©)
document.write("μ΄ν€λ¦μ²΄μ κ°μ‘°λ₯Ό λΉ¨κ°μμΌλ‘".italics().strike().fontcolor("red")+"<BR>")
document.write("ν¬κΈ°λ 5μ΄λ©΄μ λ³Όλ체λ‘".fontsize(5).bold()+"<BR>")
// μλ°μ€ν¬λ¦½νΈ λ -->
</SCRIPT></BODY></HTML>
-----------------------------------------
728x90
λ°μν
SMALL