Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. public abstract class SportsShopRental {
  2.  
  3. private boolean newModel = false;
  4. private double rentalCost = 25.0;
  5. private long rentalNumber = 1;
  6.  
  7. public boolean isNewModel() {
  8. return this.newModel;
  9. }
  10.  
  11. public void setNewModel(boolean newModel) {
  12. this.newModel = newModel;
  13. }
  14.  
  15. public double getRentalCost() {
  16. return this.rentalCost;
  17. }
  18.  
  19. public void setRentalCost(double rentalCost) {
  20.  
  21. try {
  22. if (rentalCost <= 0 || rentalCost > 999999999999) {
  23. throw new IllegalArgumentException();
  24. }
  25. }
  26. catch (IllegalArgumentException e){
  27. System.out.println("RentalNumber out of range");
  28. }
  29.  
  30. this.rentalCost = rentalCost;
  31. }
  32.  
  33. public long getRentalNumber() {
  34. return this.rentalNumber;
  35. }
  36.  
  37. public void setRentalNumber(long rentalNumber) {
  38. this.rentalNumber = rentalNumber;
  39. }
  40.  
  41. @Override
  42. public String toString(){
  43. return String.format("Rental #%d, Cost: $%7.2f, New: %b", this.rentalNumber, this.rentalCost, this.newModel);
  44. }
  45.  
  46. public abstract double lateCharge();
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement