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
'# PRIVATE' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
11์ 27์ผ ์์์ผ (0) | 2010.11.28 |
---|---|
WEB 11์ 24์ผ ๋ณด๊ฐ (0) | 2010.11.24 |
WEB 11์ 11์ผ (0) | 2010.11.11 |
template<typename TYPE> (0) | 2010.11.01 |
WEB (0) | 2010.10.29 |