문제

I have read many topics on reputation but none of them fits my needs. I am implementing a Q & A site. Each post (question/answer) can be voted. Each user has a reputation score. Depending on user's reputation, the vote for each post caries more weight. However, I dont want to do an endless if else, for example

if (0 < user_reputation < 10) then post_vote += 1
if (10 < user_reputation < 20) then post_vote += 2
if (20 < user_reputation < 30) then post_vote += 3
if (30 < user_reputation < 40) then post_vote += 4
..........

Please, suggest a better way (a formula or so) to calculate the post's vote without using the above endless if/else. I'm using Java.

도움이 되었습니까?

해결책

use post_vote += (int)(user_reputation/10);

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top