Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: Stephan Garland
- Date:03DEC2014
- Project: LuxuryCarRental - Modifies and adds options to CarRental
- */
- import java.util.Scanner;
- public class LuxuryCarRental extends CarRental
- {
- protected String chauffeur;
- public void setLuxury(double dailyFee)
- {
- this.dailyFee = dailyFee;
- }
- public void setName(String name)
- {
- this.name = name;
- }
- @Override
- public void setZip(String zip)
- {
- this.zip = zip;
- }
- @Override
- public void setRentalLength(int rentalLength)
- {
- this.rentalLength = rentalLength;
- }
- public void chauffeurSelect()
- {
- System.out.println("Would you like a chauffeur for $200/day extra? (Y\\N)");
- Scanner keyboard = new Scanner(System.in);
- chauffeur = keyboard.next().toUpperCase();
- char chauffeurSelection = chauffeur.charAt(0);
- switch(chauffeurSelection)
- {
- case 'Y' :
- System.out.println("Very good, I'll add that to your bill.");
- setLuxury(279.99);
- break;
- case 'N' :
- System.out.println("No chauffeur, then - very well.");
- setLuxury(79.99);
- break;
- default :
- System.out.println("Invalid selection");
- }
- }
- @Override
- void display()
- {
- chauffeurSelect();
- setCarSize("Luxury"); // Seems easier to do it directly here
- totalFee = dailyFee * getRentalLength();
- System.out.println("\nRental summary");
- System.out.println("\n" + getName());
- System.out.println("ZIP code " + getZip());
- System.out.println(getCarSize() +
- " at $" + getDailyFee() +
- " for " + getRentalLength() + " days" +
- " for a total of $" + getTotalFee());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement