策略模式
let strategy = {
S:(salary) => {
return salary*5
},
A:(salary) => {
return salary*4
},
B:(salary) => {
return salary*3
},
C:(salary) => {
return salary*2
},
}
function settlement(grade,salary){
return strategy[grade](salary)
}
settlement('S',10000) // 50000
settlement('A',5000) // 20000