Advertisement
Guest User

SubClass

a guest
Nov 25th, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import javax.swing.*;
  2.  
  3. public class LuxuryCarRental extends CarRental
  4. {
  5. private double dailyFee = 79.99;
  6. public String entry;
  7.  
  8. public LuxuryCarRental(String name, int zipCode, String size, int days)
  9. {
  10. super(name, zipCode, size, days);
  11. }
  12.  
  13. public void calculateTotal()
  14. {
  15. super.calculateTotal(days);
  16. }
  17.  
  18. public double chauffer()
  19. {
  20. double cfee;
  21. entry = JOptionPane.showInputDialog(null, "Would you like a chauffer for an additional $200 fee? Y/N");
  22. if (entry.toLowerCase() == "Y")
  23. {
  24. cfee = dailyFee + 200.00;
  25. return cfee;
  26. }
  27. else
  28. {
  29. return dailyFee;
  30. }
  31. }
  32.  
  33. public void display()
  34. {
  35. super.display();
  36. if(entry.toLowerCase() == "Y")
  37. {
  38. JOptionPane.showMessageDialog(null, "You selected to have a chauffer");
  39. }
  40. else
  41. {
  42. JOptionPane.showMessageDialog(null, "You selected not to have a chauffer");
  43. }
  44.  
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement