Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. public class Cruise {
  2.  
  3. // Class Variables
  4. private String cruiseName;
  5. private String cruiseShipName;
  6. private String departurePort;
  7. private String destination;
  8. private String returnPort;
  9. }
  10. // Constructor - default
  11. Cruise() {
  12. }
  13.  
  14. // Constructor - full
  15. Cruise(String tCruiseName, String tShipName, String tDeparture, String tDestination, String tReturn) {
  16. cruiseName = tCruiseName;
  17. cruiseShipName = tShipName;
  18. departurePort = tDeparture;
  19. destination = tDestination;
  20. returnPort = tReturn;
  21. }
  22.  
  23. // Accessors
  24. public String getCruiseName() {
  25. return cruiseName;
  26. }
  27.  
  28. public String getCruiseShipName() {
  29. return cruiseShipName;
  30. }
  31.  
  32. public String getDeparturePort() {
  33. return departurePort;
  34. }
  35.  
  36. public String getDestination() {
  37. return destination;
  38. }
  39.  
  40. public String getReturnPort() {
  41. return returnPort;
  42. }
  43.  
  44. // Mutators
  45. public void setCruiseName(String tVar) {
  46. cruiseName = tVar;
  47. }
  48.  
  49. public void setCruiseShipName(String tVar) {
  50. cruiseShipName = tVar;
  51. }
  52.  
  53. public void setDeparturePort(String tVar) {
  54. departurePort = tVar;
  55. }
  56.  
  57. public void setDestination(String tVar) {
  58. destination = tVar;
  59. }
  60.  
  61. public void setReturnPort(String tVar) {
  62. returnPort = tVar;
  63. }
  64.  
  65. // print cruise details
  66. public void printCruiseDetails() {
  67.  
  68. // complete this method
  69. // METHOD FOR PRINTING CRUISE DETAILS\\
  70.  
  71.  
  72. System.out.println(cruiseShipName + cruiseName + "\t" +
  73. departurePort + "\t" + destination + "\t" +
  74. returnPort);
  75. }
  76. }
  77.  
  78. // method added to print ship's name vice memory address
  79. @Override
  80. public String toString() {
  81. return cruiseName;
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement