File: Rating.java

package info (click to toggle)
mac-widgets 0.9.5%2Bsvn369-dfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,920 kB
  • sloc: java: 8,318; makefile: 13; sh: 12
file content (17 lines) | stat: -rw-r--r-- 437 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package com.explodingpixels.data;

public enum Rating {

    NO_RATING, ONE_STAR, TWO_STARS, THREE_STARS, FOUR_STARS, FIVE_STARS;

    public static Rating getRating(int ratingInteger) {

        if (ratingInteger < 0 || 100 < ratingInteger) {
            throw new IllegalArgumentException("Rating must be between " +
                    "1 and 100");
        }

        return Rating.values()[Math.round(ratingInteger / 20)];
    }

}