Hello I need help completing this java task
publicclassCruise {
// Class Variables
privateString cruiseName;
privateString cruiseShipName;
privateString departurePort;
privateString destination;
privateString 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
publicString getCruiseName() {
returncruiseName;
}
publicString getCruiseShipName() {
returncruiseShipName;
}
publicString getDeparturePort() {
returndeparturePort;
}
publicString getDestination() {
returndestination;
}
publicString getReturnPort() {
returnreturnPort;
}
// Mutators
publicvoidsetCruiseName(String tVar) {
cruiseName = tVar;
}
publicvoidsetCruiseShipName(String tVar) {
cruiseShipName = tVar;
}
publicvoidsetDeparturePort(String tVar) {
departurePort = tVar;
}
publicvoidsetDestination(String tVar) {
destination = tVar;
}
publicvoidsetReturnPort(String tVar) {
returnPort = tVar;
}
// print cruise details
publicvoidprintCruiseDetails() {
// complete this method
}
// method added to print ship's name vice memory address
@Override
publicString toString() {
returncruiseName;
}
}
The part that I need help coding in java is bolded and italicized in the text above.
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() {
//printing the details with
labels
System.out.println("CruiseName :
"+cruiseName);
System.out.println("CruiseShipName:
"+cruiseShipName);
System.out.println("DeparturePort:
"+departurePort);
System.out.println("Destination:
"+destination);
System.out.println("ReturnPort:
"+returnPort);
// complete this method
}
// method added to print ship's name vice memory address
@Override
public String toString() {
return cruiseName;
}
}
public class TestCruise{
public static void main(String[] args) {
Cruise c = new Cruise("Uday",
"AlexaShip", "USA", "India", "Yes");
c.printCruiseDetails();
}
}
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me
Hello I need help completing this java task publicclassCruise { // Class Variables privateString cruiseName; privateString...
[JAVA] Program: Design a Ship class that the following members: A field for the name of the ship (a string) o A field for the year the the ship was built (a string) o A constructor and appropriate accessors and mutators A toString method that displays the ship's name and the year it was built Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following members: A field for the maximum number of passengers...
Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the concept of a college course, assuming that a course has following attributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include a constructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test the behavior of the class and its methods. The outline of the class is given as follows: public class Course...
1. Employees and overriding a class method The Java program (check below) utilizes a superclass named EmployeePerson (check below) and two derived classes, EmployeeManager (check below) and EmployeeStaff (check below), each of which extends the EmployeePerson class. The main program creates objects of type EmployeeManager and EmployeeStaff and prints those objects. Run the program, which prints manager data only using the EmployeePerson class' printInfo method. Modify the EmployeeStaff class to override the EmployeePerson class' printInfo method and print all the...
Java Program (PLEASE PROVIDE SCREENSHOT OF THE CODE) Create a class Person which is a super class. The class includes four private String instance variables: first name, last name, social security number, and state. Write a constructor and get methods for each instance variable. Also, add a toString method to print the details of the person. After that create a class Teacher which extends the class, Person. Add a private instance variable to store number of courses. Write a constructor...
Hello, I need some help creating this class in Java. This is for a larger project. I am using Eclipse if that helps 1. Create a class named State that will store information about a state and provide methods to get, and set the data, and compare the states by several fields. a. Fields: Name, Capital City, Abbreviation, Population, Region, US House Seats b. Constructor c. Get and set methods for each field d. Compare method to compare State objects...
Program Challenge 10 Design a Ship class that the following members: · A field for the name of the ship (a string). · A field for the year that the ship was built (a string). · A constructor and appropriate accessors and mutators. · A toString method that displays the ship’s name and the year it was built. Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following members: · A field for the...
Write the following program in Java. Create an abstract Vehicle class - Vehicle should have a float Speed and string Name, an abstract method Drive, and include a constructor. Create a Tesla class - Tesla inherits from Vehicle. - Tesla has an int Capacity. - Include a constructor with the variables, and use super to set the parent class members. - Override Drive to increase the speed by 1 each time. - Add a toString to print the name, speed,...
J Inc. has a file with employee details. You are asked to write a C++ program to read the file and display the results with appropriate formatting. Read from the file a person's name, SSN, and hourly wage, the number of hours worked in a week, and his or her status and store it in appropriate vector of obiects. For the output, you must display the person's name, SSN, wage, hours worked, straight time pay, overtime pay, employee status and...
In java netbean8.1 or 8.2 please. The class name is Stock. It has 5 private attributes (name, symbol, numberOfShares, currentPrice and boughtPrice)and one static private attribute (numberOfStocks). All attributes must be initialized (name and symbol to “No name/ symbol yet” and numberOfShares, currentPrice and boughtPrice to 0. Create two constructors, one with no arguments and the other with all the attributes. (However, remember to increase the numberOfStocks in both constructors. Write the necessary mutators and accessors (getters and setters) for...
Java file Name Dog Classes and Methods Create a constructor that incorporates the type, breed, and name variables (do not include topTrick). Note: The type refers to what the breed typically does; for example, a corgi would be a “cattle herding dog.” A Shiba Inu would be a “hunting dog.” Create the setTopTrick() mutator method Dog is parent class Corgi and Driver are subclasses Complete the Corgi class: Using the UML Class diagram, declare the instance variables. Create the two...