Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Movie {
- int id, rentCount;
- String title;
- // Constructor
- public Movie(int newId, String newTitle, int newRentCount) {
- id = newId;
- title = newTitle;
- rentCount = newRentCount;
- }
- public void getInfo() {
- System.out.println(id + "\t" + rentCount + "\t" + title);
- }
- public void rent() {
- System.out.println("Movie '" + title + "' has been rented out (Total: " + ++rentCount + " times)");
- }
- public void updateRent(int newRentCount) {
- rentCount = newRentCount;
- System.out.println("Movie '" + title + "' has been rented out " + rentCount + " times");
- }
- public double getEarnings() {
- double earnings = 0.0;
- if (rentCount > 10) {
- earnings = 3.15 * rentCount;
- } else {
- earnings = 2.10 * rentCount;
- }
- return earnings;
- }
- }
Add Comment
Please, Sign In to add comment