Complete the following tasks: a. Create a class named Trip that includes four st
ID: 3762097 • Letter: C
Question
Complete the following tasks:
a. Create a class named Trip that includes four string variables: destination (for example, “London”), means of transportation (for example, “air”), departure date (for example, “12/15/2015”), and trip's purpose (for example, “business”). Include two overloaded constructors. The default constructor sets each field to “XXX”. The nondefault constructor accepts four parameters—one for each field. Include two overloaded display() methods. The parameterless version displays all the Trip details. The second version accepts a string that represents a destination and displays the Trip details only if the Trip's destination matches the parameter.
b. Create an application that instantiates several Tripobjects and demonstrates all the methods.
In pseudocode
Explanation / Answer
Pseudocode for the class trip
class Trip
Declarations:
private string destination
private string meansOfTransport
private string departDate
private string purpose
public Trip()
destination=''xxx''
meansOfTransport=''xxx''
departDate=''xxx''
purpose=''xxx''
return
public Trip(string dest,string trans,strng date,string purp)
destination=dest
meansOfTransport=trans
departDate=date
purpose=purp
return
public void display()
output "destination: ",destination
output "means of transport: ", meansOfTransport
output "departure date: ",departDate
output "purpose" , purpose
return
public void display(string dest)
if(destination==dest) then
output "destination: ",destination
output "means of transport: ", meansOfTransport
output "departure date: ",departDate
output "purpose" , purpose
endif
return
endclass
pseducode for instantiating trip objects and calling functions with help of objects
start
Declarations
Trip trip1
Trip trip2("london","train","5/6/2015",tourism)
Trip trip3("manchester","air","7/8/2015","business")
trip1.display()
trip2.display()
trip3.display(london)
trip3.display(mancshester)
stop