# 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>
-----------------------------------------
728x90
λ°˜μ‘ν˜•
SMALL