Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class SportsShopRental {
- private boolean newModel = false;
- private double rentalCost = 25.0;
- private long rentalNumber = 1;
- public boolean isNewModel() {
- return this.newModel;
- }
- public void setNewModel(boolean newModel) {
- this.newModel = newModel;
- }
- public double getRentalCost() {
- return this.rentalCost;
- }
- public void setRentalCost(double rentalCost) {
- try {
- if (rentalCost <= 0 || rentalCost > 999999999999) {
- throw new IllegalArgumentException();
- }
- }
- catch (IllegalArgumentException e){
- System.out.println("RentalNumber out of range");
- }
- this.rentalCost = rentalCost;
- }
- public long getRentalNumber() {
- return this.rentalNumber;
- }
- public void setRentalNumber(long rentalNumber) {
- this.rentalNumber = rentalNumber;
- }
- @Override
- public String toString(){
- return String.format("Rental #%d, Cost: $%7.2f, New: %b", this.rentalNumber, this.rentalCost, this.newModel);
- }
- public abstract double lateCharge();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement