์์ ๋ณ์๋ฅผ ์์ ๋ ๋ฐฉ๋ฒ์ ์์๋ณด์.
statement ํจ์ ์ชผ๊ฐ๊ธฐ (๊ณ์)
play ๋ณ์ ์ ๊ฑฐํ๊ธฐ
amountFor
ํจ์์ ์ธ์๋ฅผ ๋ณด๋ ๋์ค, play
๊ฐ ํ์์๋ค๋ ๊ฒ์ ์๊ฒ ๋์๋ค.
- play๋
aPerformance
์์ ์ป์ ์ ์๋ค.
- ์ด๋ฐ ๊ฒฝ์ฐ ์์ ๋ณ์๋ฅผ ์ง์ ํจ์๋ก ๋ฐ๊พธ๊ธฐ๋ฅผ ์ฌ์ฉํ๋ค.
- ์ฆ, ์์๋ก ๋ณ์๋ก ํ ๋นํด ๋๋ ๊ฒฝ์ฐ, โํด๋น ๊ฐ์ ๊ฐ์ ธ์!โ ๋ผ๋ ์๋์ ํจ์๋ก ๋ณ๊ฒฝํด์ ์ฒ๋ฆฌํ๋ค๋ ๋ง์ด๋ค.
- ๋ค์ ๋ ์ปดํ์ผ - ํ
์คํธ - ์ปค๋ฐํ๋ค.
- ๊ทธ๋ฆฌ๊ณ โ๋ณ์ ์ธ๋ผ์ธ ํ๊ธฐโ๋ฅผ ์ ์ฉํ๋ค.
- ๊ตณ์ด ๋ณ์๋ก ๋นผ์ง ์๊ณ , ๋ฐ๋ก ํจ์ํธ์ถ์ ๊ฒฐ๊ณผ๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ
play
โ playFor(perf)
๋ก ๋ณ๊ฒฝํ๋ค.
- ๋ค์ ๋ ์ปดํ์ผ - ํ
์คํธ - ์ปค๋ฐํ๋ค.
- ์ผ๋จ ๋จ์ํ๊ฒ ํจ์๋ก ์ฃ๋ค ๋์ฒดํด๋ฒ๋ฆฐ๋ค.
- ์๊ฐํด๋ณด๋, ์์ ๋ณ์๋ฅผ ํจ์๋ก ๋์ฒดํจ์ผ๋ก์จ, ์ผ๋ฐํ๋๊ฒ ๋ค๋ฅธ ํจ์์์๋ ์ฌ์ฉํ ์ ์๊ฒ ๋ง๋ค์๋ค๋ ๊ฒ์ ์ ์ ์๋ค.
- ์ฒ์์๋ ์ ๊ตณ์ด? ๋ผ ์๊ฐํ์ผ๋, ์ด ํ์๊ฐ ๊ฒฐ๊ตญ ํจ์์์ ์์กด์ฑ์ ์ ๊ฑฐํ๋ ํ๋์ด๋ผ๋ ๊ฒ์ ์ ์ ์์๋ค.
- ์ด๋ ๊ฒ ๋๊ณ ๋ณด๋,
amountFor
ํจ์์ play
์ธ์๋ ๋ ์ด์ ํ์์๋ค๋ ๊ฒ์ ์ ์ ์๋ค.
- ์ด๋ฅผ ์ญ์ ํด์ฃผ์.
- ๋ค์ ๋ ์ปดํ์ผ - ํ
์คํธ - ์ปค๋ฐํ๋ค.
- ์, ์ด๋ ๊ฒ ๋๊ณ ์๊ฐํด๋ณด์. ๋๊ตฐ๊ฐ๋ ์ด๋ ๊ฒ ๋งํ ์ ์๋ค.
- โ์ด์ ์๋
statement
์์ play
๋ฅผ ์ป์ด์ amountFor
์๊ฒ ์ ๋ฌํ์๋๋ฐ, ์ด์ ๋ amountFor
๊ฐ play
๋ฅผ ์ป์ด์ ์ฌ์ฉํ๊ณ ์๋ค."
- "๊ทธ๋ฌ๋ฉด์ ์กฐํ ๋น๋๊ฐ 3๋ฐฐ๋ ๋์๋ค. ์ด๊ฑด ์ฑ๋ฅ์ ๋ฌธ์ ๊ฐ ์์ ์ ์๋ค.โ
- ํ์ง๋ง ์ด๋ ๊ฒ ๋ณ๊ฒฝํด๋ ์ฑ๋ฅ์ ํฐ ์ํฅ์ ์๋ค. ์ฌ๊ฐํ๊ฒ ๋๋ ค์ง๋๋ผ๋ ์ ๋๋ก ๋ฆฌํฉํฐ๋ง ๋์๋ค๋ฉด ์ฑ๋ฅ ๊ฐ์ ์ด ํจ์ฌ ์์ํ๋ค.
- ๊ทธ๋ผ์๋ ์ด๋ ๊ฒ ์ง์ญ ๋ณ์๋ถํฐ ์ ๊ฑฐํ๋ ๊ฒ์ ์ถ์ถํ๊ธฐ๊ฐ ๋งค์ฐ ์ฌ์์ง๋ค๋๋ฐ์ ์๋ค.
- ์ถ์ถ ์์
์ ์๋ ๊ฑฐ์ ํญ์ ์ง์ญ ๋ณ์๋ถํฐ ์ ๊ฑฐํ๋ค.
- ์ด์
amountFor
ํจ์์ ํ์ํ ์ธ์๋ฅผ ๋ชจ๋ ์ฒ๋ฆฌํ์ผ๋, ์ด๊ฑธ ํธ์ถํ๋ ์น๊ตฌ๋ฅผ ๋ณด์.
thisAmount = amountFor(perf);
์ด๋ ๊ฒ ์ฌ์ฉํ๊ณ ์๊ณ , ์ด๊ฑด ๋จ์ํ ๊ฐ์ ๋ํ๊ธฐ ์ํด ์ฌ์ฉ์ค์ด๋ค.
- ์ฆ, ์์๋ก ๋ณ์์ ํ ๋น ์ค์ด๋ค.
- ๊ทธ๋ผ ๋ญํด์ผ ํ๋ค? โ ๋ณ์ ์ธ๋ผ์ธ ํ๊ธฐ.
thisAmount
๋ณ์๋ฅผ ์ ๊ฑฐํ๊ณ , amountFor
ํจ์์ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ๋ก ๋์
ํ์.
์ ๋ฆฝ ํฌ์ธํธ ๊ณ์ฐ ์ฝ๋ ์ถ์ถํ๊ธฐ
- ์ผ๋จ ์ง๊ธ๊น์ง ๊ฒฐ๊ณผ๋ฅผ ๋ณด์.
- ์ง์ญ ๋ณ์๋ฅผ ์์ค ํจ๊ณผ๊ฐ ๋ณด์ด๋๊ฐ?
- ์ง์ญ ๋ณ์๊ฐ ์๋ค๋ฉด, ํจ์๋ฅผ ์ถ์ถํ ๋ ์์ด ๊ณ ๋ คํด์ผํ๋ ๋์์ด ์ถ๊ฐ๋๋ ์
์ด๋ค.
- ๊ทธ๋ฐ๋ฐ, ์ด๋ ๊ฒ ํด๋๋, ํจ์์ ๊ฒฐ๊ณผ๋ก ๋์ฒด๋์ด, ์ ๋ฆฝํฌ์ธํธ๋ฅผ ์ถ์ถํ๊ธฐ ๋ ํธํด์ก๋ค. (
volumeCredits
๊ณ์ฐ)
- ์ผ๋จ ๊ฐ์ ๊ณ์ฐํ๋ ๋ก์ง์ ์ถ์ถํ๊ณ , ์ด ๊ฒฐ๊ณผ๋ฅผ ๋ํ๋๋ก ๋ณ๊ฒฝํด๋ณด์.
- ๋ค์ ๋ ์ปดํ์ผ - ํ
์คํธ - ์ปค๋ฐํ๋ค.
- ๋จ์ํ ์ฎ๊ธฐ๊ณ ๋์ํ๋,
volumeCreditsFor
ํจ์ ๋ด๋ถ ๋ณ์๋ฅผ result
๋ก ๊ณ ์น์.
- ํ ์ํฉ์ ํ๋ฒ ๋ณด์.
- ์์ ๋ณ์๋ ์์ ์ด ์ํ ํจ์ ์์์๋ง ์๋ฏธ๊ฐ ์๊ธฐ ๋๋ฌธ์, ๊ธธ๊ณ ๋ณต์กํด์ ธ ๋ฌธ์ ๋ฅผ ์ผ์ผํค๊ธฐ ์ฝ๋ค.
- ๋ค์์ผ๋ก ๋ง๋งํ ๊ฑด ์ด์
format
์ด๋ค.
- ์ด๊ฑธ ๋ถ๋ฆฌํ๊ณ ๋ชจ๋ ์ ์ฉํด๋ณด์.
- ๋ค์ ๋ ์ปดํ์ผ - ํ
์คํธ - ์ปค๋ฐํ๋ค.
- ๊ทธ๋ฐ๋ฐ ์ด๋ฆ์ด ๊ฑธ๋ฆฐ๋ค.
format
์ด๋ผ๋ ์ด๋ฆ์ ๋๋ฌด ์ผ๋ฐ์ ์ด๋ค.
- ์ ์ ํ ์ด๋ฆ์ธ
usd
๋ก ๋ณ๊ฒฝํ์. ๋ํ ๋ณํ ๋ก์ง(/100
)๋ usd
ํจ์ ์์ผ๋ก ์ฎ๊ธฐ์.
- ๋ค์ ๋ ์ปดํ์ผ - ํ
์คํธ - ์ปค๋ฐํ๋ค.
- ๊ธด ํจ์๋ฅผ ์๊ฒ ์ชผ๊ฐ๋ ๋ฆฌํฉํฐ๋ง์ ์ด๋ฆ์ ์ ์ง์ด์ผ๋ง ํจ๊ณผ๊ฐ ์๋ค.
- ๋จ๋ฒ์ ์ข์ ์ด๋ฆ์ ์ง๊ธฐ๋ ์ฝ์ง ์๋ค. ๋น์ฅ์ ์ต์ ์ ์ฌ์ฉํ๋ค ๋ฐ๊พธ๋๋ก ํ์.
Reference