if(!aDate.isBefore(plan.summerStart)&&!aDate.isAfter(plan.summerEnd))
charge = quantity*plan.summerRate;
else
charge = quantity*plan.regularRate+plan.regularserviceCharge;
// ์กฐ๊ฑด๋ฌธ ๋ถํดํ๊ธฐ ์ ์ฉ
if(summer())
charge = summercharge();
else
charge = regularCharge();
๋์ผํ ์๋ฏธ์ ๊ฐ์ ์กฐ๊ฑด์์ผ๋ก return ํ๋ค๋ฉด ํตํฉํ๋ค.
if(anEmployee.seniority<2) return 0;
if(anEmployee.monthsDisabled>12) return 0;
if(anEmployee.isPartTime)return 0;
// ์กฐ๊ฑด์ ํตํฉํ๊ธฐ
if (isNotEligibleForDisability())return 0;
function isNotEligibleForDisability(){
return ((anEmployee.seniority<2)||(anEmployee.monthsDisabled>12)||(anEmployee.isPartTime));
}
function getPayAmount(){
let result;
if (isDead)
result= deadAmount();
else {
if(isseparated)
result = separatedAmount();
else{
if(isRetired)
result = retiredAmount();
else
result = normalPayAmount();
}
}
return result;
}
// ์ค์ฒฉ์กฐ๊ฑด๋ฌธ์ ๋ณดํธ ๊ตฌ๋ฌธ์ผ๋ก ๋ฐ๊พธ๊ธฐ
function getPayAmount(){
if(isDead) return deadAmount();
if(isseparated) return separatedAmount();
if(isRetired) return retiredAmount();
return normalPayAmount();
}
switch(bird.type){
case '์ ๋ฝ ์ ๋น':
return '๋ณดํต์ด๋ค';
case '์ํ๋ฆฌ์นด ์ ๋น':
return (bird.numberOfCoconuts>2)?'์ง์ณค๋ค':'๋ณดํต์ด๋ค';
case '๋
ธ๋ฅด์จ์ด ํ๋ ์ต๋ฌด':
return (bird.voltage>100)?'๊ทธ์๋ ธ๋ค':'์์๋ค';
default:
return '์ ์ ์๋ค';
}
// ์กฐ๊ฑด๋ถ ๋ก์ง์ ๋คํ์ฑ์ผ๋ก ๋ฐ๊พธ๊ธฐ
class Bird{
constructor(birdObject){
Object.assign(this,birdObject);
}
get plumage(){
return '์ ์ ์๋ค';
}
get airSpeedVelocity(){
return null;
}
}
class EuropeanSwallow extends Bird{
get plumage(){
return '๋ณดํต์ด๋ค';
}
get airSpeedVelocity(){
return 35;
}
}
....
if (aCustomer==='๋ฏธํ์ธ ๊ณ ๊ฐ') customerName = '๊ฑฐ์ฃผ์';
// ํน์ด ์ผ์ด์ค ์ถ๊ฐํ๊ธฐ
class UnknownCustomer{
get name(){return '๊ฑฐ์ฃผ์';}
}
for(const p of people){
if(!found){
if(p==='์กฐ์ปค'){
sendAlert();
found=true;
}
}
}
//์ ์ด ํ๋๊ทธ๋ฅผ ํ์ถ๋ฌธ์ผ๋ก ๋ฐ๊พธ๊ธฐ
for(const p of people){
if(p==='์กฐ์ปค'){
sendAlert();
break;
}
}| "์ก๊ฐํ ๊ฐ๋ฐ์", "์์ฆ ์ฐ์ํ ๊ฐ๋ฐ"์ ์ฝ์ผ๋ฉฐ... (0) | 2024.06.19 |
|---|---|
| 11. API ๋ฆฌํฉํฐ๋ง (0) | 2021.11.04 |
| 9. ๋ฐ์ดํฐ ์กฐ์งํ (0) | 2021.11.04 |
| 8. ๊ธฐ๋ฅ ์ด๋ (0) | 2021.10.11 |
| 7.7. ์์ ์จ๊ธฐ๊ธฐ | 7.8. ์ค๊ฐ์ ์ ๊ฑฐํ๊ธฐ | 7.9. ์๊ณ ๋ฆฌ์ฆ ๊ต์ฒดํ๊ธฐ (0) | 2021.10.05 |