Guest User

Untitled

a guest
Jun 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. public class Movie {
  2.  
  3. int id, rentCount;
  4. String title;
  5.  
  6. // Constructor
  7. public Movie(int newId, String newTitle, int newRentCount) {
  8. id = newId;
  9. title = newTitle;
  10. rentCount = newRentCount;
  11. }
  12.  
  13. public void getInfo() {
  14. System.out.println(id + "\t" + rentCount + "\t" + title);
  15. }
  16.  
  17. public void rent() {
  18. System.out.println("Movie '" + title + "' has been rented out (Total: " + ++rentCount + " times)");
  19. }
  20.  
  21. public void updateRent(int newRentCount) {
  22. rentCount = newRentCount;
  23. System.out.println("Movie '" + title + "' has been rented out " + rentCount + " times");
  24. }
  25.  
  26. public double getEarnings() {
  27. double earnings = 0.0;
  28. if (rentCount > 10) {
  29. earnings = 3.15 * rentCount;
  30. } else {
  31. earnings = 2.10 * rentCount;
  32. }
  33. return earnings;
  34. }
  35.  
  36. }
Add Comment
Please, Sign In to add comment