Advertisement
qwerty787788

Untitled

Nov 26th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1.        int predictRating(Film f, User u) {
  2.         int res = 4;
  3.         if (f == null && u != null) {
  4.             res = (int) Math.round(u.avarageRating);
  5.         } else {
  6.             if (f != null && u == null) {
  7.                 res = (int) Math.round(f.avarageRating);
  8.             } else {
  9.                 if (f != null && u != null) {
  10.                     res = (int) Math.round(Math.sqrt(f.avarageRating
  11.                             * u.avarageRating) - 0.1);
  12.                 }
  13.             }
  14.         }
  15.         if (res < 1)
  16.             res = 1;
  17.         if (res > 5)
  18.             res = 5;
  19.         return res;
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement