Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Cruise {
- // Class Variables
- private String cruiseName;
- private String cruiseShipName;
- private String departurePort;
- private String destination;
- private String returnPort;
- }
- // Constructor - default
- Cruise() {
- }
- // Constructor - full
- Cruise(String tCruiseName, String tShipName, String tDeparture, String tDestination, String tReturn) {
- cruiseName = tCruiseName;
- cruiseShipName = tShipName;
- departurePort = tDeparture;
- destination = tDestination;
- returnPort = tReturn;
- }
- // Accessors
- public String getCruiseName() {
- return cruiseName;
- }
- public String getCruiseShipName() {
- return cruiseShipName;
- }
- public String getDeparturePort() {
- return departurePort;
- }
- public String getDestination() {
- return destination;
- }
- public String getReturnPort() {
- return returnPort;
- }
- // Mutators
- public void setCruiseName(String tVar) {
- cruiseName = tVar;
- }
- public void setCruiseShipName(String tVar) {
- cruiseShipName = tVar;
- }
- public void setDeparturePort(String tVar) {
- departurePort = tVar;
- }
- public void setDestination(String tVar) {
- destination = tVar;
- }
- public void setReturnPort(String tVar) {
- returnPort = tVar;
- }
- // print cruise details
- public void printCruiseDetails() {
- // complete this method
- // METHOD FOR PRINTING CRUISE DETAILS\\
- System.out.println(cruiseShipName + cruiseName + "\t" +
- departurePort + "\t" + destination + "\t" +
- returnPort);
- }
- }
- // method added to print ship's name vice memory address
- @Override
- public String toString() {
- return cruiseName;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement