Question: Core Java_OOPS Concept_Problem Statement 6 Vinay and his family is going to relocate to London and they were looking for a good Shipping Company that

Core Java_OOPS Concept_Problem Statement 6

Vinay and his family is going to relocate to London and they were looking for a good Shipping Company that would make their relocation hassle-free and reliable. Vinay's friend suggested him about the Gaati Group of Shipping in their locality as the Company is a reputed firm specialised especially in Ocean freight transport.

The Company had a variety of Water carriers namely Bulk Ships, Container Ships owned by Company ,Ferries(small ships) and other carriers are owned byAgents, for their shipments. Vinay placed his shipment order in the Company but was interested to know the details of different ships in each category of the Water Carriers and requested the Shipping Officer for the same. The Officer needs your help to write a block of code in fetching the details of the ships based on the category of Water carriers.

This program will help you familiarize the need of Abstract classes. Abstract class is a class that is declared abstractit may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed.

[Note : Strictly adhere to the object oriented specifications given as a part of the problem statement. Use the same class names and member variable names. Create separate classes in separate files.] Create an abstract class named WaterCarrier with the following protected attributes / member variables.

String carrierName

String carrierCode

String carrierType

String iataCode

String carrierAddress

Include appropriate getters and setters.

Include default constructor and 5-argument constructor,with the following order carrierName,carrierCode,iataCode,carrierAddress,carrierType.

Include a abstract method displayShipDetails().

Include the following methods :

Method Name Description
static WaterCarrier createShip(String carrierName, String carrierCode, String iataCode, String carrierAddress,String carrierType,Integer capacity) to create and return the water carrier objects.
static String returnOwner(WaterCarrier waterCarrier) to return the owner of the ship(either company or agent).

Create a class named ContainerShips. The class ContainerShips is a derived class of WaterCarrier. Include the following private attributes / member variables.

Integer noOfContainers

Include appropriate getters and setters.

Include default constructor and 6-argument constructor,with the following order carrierName,carrierCode,iataCode,carrierAddress,carrierType,noOfContainers.

Create a class named BulkShips. The class BulkShips is a derived class of WaterCarrier. Include the following private attributes / member variables.

Integer noOfCargoes

Include appropriat getters and setters.

Include default constructor and 6-argument constructor,with the following order carrierName,carrierCode,iataCode,carrierAddress,carrierType,noOfcargoes.

Create a class named Ferries. The class Ferries is a derived class of WaterCarrier. Include the following private attributes / member variables.

Integer maxLoad

Include appropriate getters and setters.

Include default constructor and 6-argument constructor, with the following order carrierName,carrierCode,iataCode,carrierAddress,carrierType,maxLoad.

Below methods are overrided in all child classes.

S.No Method Name Method description
1 displayShipDetails() to display details of the ship

Display details using System.out.format("%-20s%-15s%-15s%-15s%-15s%-25s%s ","Carrier type","Name","Code","IATAcode","Location","Capacity","OwnedBy") Create another class called Main. In the method, create instances of the above classes and test the above classes.

Input and Output Format: The ship details are entered as comma separated values with following order carrierName,carrierCode,iataCode,carrierAddress,carrierType,capacity Refer sample input andoutput for formatting specifications. All text in bold corresponds to input and the rest corresponds to output. Sample Input and Output : Enter the number of carriers : 3 Enter the carrier 1 details : Titanic,CR20,IATA001,California,BulkShip,10 Enter the carrier 2 details : Arcadia,CR21,IATA002,Mexico,ContainerShip,10 Enter the carrier 3 details : Lexcorp,CR22,IATA003,Bermuda,Ferries,25 Ship details are Carrier type Name Code IATAcode Location Capacity OwnedBy BulkShip Titanic CR20 IATA001 California 10 cargoes Company ContainerShip Arcadia CR21 IATA002 Mexico 10 containers Company Ferries Lexcorp CR22 IATA003 Bermuda 25 kilograms Agent

Here, I am providing piece of code. Please update them and send me back.

WaterCarrier.java

public class WaterCarrier {

protected String carrierName;

protected String carrierCode;

protected String carrierType;

protected String iataCode;

protected String carrierAddress;

public WaterCarrier(){

}

public WaterCarrier(String carrierName, String carrierCode, String iataCode, String carrierAddress,String carrierType) {

super();

this.carrierName = carrierName;

this.carrierCode = carrierCode;

this.iataCode = iataCode;

this.carrierAddress = carrierAddress;

this.carrierType = carrierType;

}

public String getCarrierType() {

return carrierType;

}

public void setCarrierType(String carrierType) {

this.carrierType = carrierType;

}

public String getCarrierAddress() {

return carrierAddress;

}

public void setCarrierAddress(String carrierAddress) {

this.carrierAddress = carrierAddress;

}

public String getCarrierName() {

return carrierName;

}

public void setCarrierName(String carrierName) {

this.carrierName = carrierName;

}

public String getCarrierCode() {

return carrierCode;

}

public void setCarrierCode(String carrierCode) {

this.carrierCode = carrierCode;

}

public String getIataCode() {

return iataCode;

}

public void setIataCode(String iataCode) {

this.iataCode = iataCode;

}

//fill the code

}

Ferry.java

public class Ferry extends WaterCarrier{

Integer maxLoad;

public Ferry(){

}

public Ferry(String carrierName, String carrierCode, String iataCode, String carrierAddress, String carrierType,

Integer maxLoad) {

super(carrierName, carrierCode, iataCode, carrierAddress, carrierType);

this.maxLoad = maxLoad;

}

public Integer getMaxLoad() {

return maxLoad;

}

public void setMaxLoad(Integer maxLoad) {

this.maxLoad = maxLoad;

}

//fill the code

}

ContainerShip.java

public class ContainerShip extends WaterCarrier{

Integer noOfContainers;

public ContainerShip(){

}

public ContainerShip(String carrierName, String carrierCode, String iataCode, String carrierAddress,

String carrierType, Integer noOfContainers) {

super(carrierName, carrierCode, iataCode, carrierAddress, carrierType);

this.noOfContainers = noOfContainers;

}

public Integer getNoOfContainers() {

return noOfContainers;

}

Main.java

import java.io.*;

public class Main {

public static void main(String args[])throws IOException{

//fill the code

System.out.println("Ship details are");

System.out.format("%-20s%-15s%-15s%-15s%-15s%-25s%s ","Carrier type","Name","Code","IATAcode","Location","Capacity","OwnedBy");

//fill the code

}

}

public void setNoOfContainers(Integer noOfContainers) {

this.noOfContainers = noOfContainers;

}

//fill the code

}

BulkShip.java

public class BulkShip extends WaterCarrier{

Integer noOfcargoes;

public BulkShip(){

}

public BulkShip(String carrierName, String carrierCode, String iataCode, String carrierAddress, String carrierType,

Integer noOfcargoes) {

super(carrierName, carrierCode, iataCode, carrierAddress, carrierType);

this.noOfcargoes = noOfcargoes;

}

public Integer getNoOfcargoes() {

return noOfcargoes;

}

public void setNoOfcargoes(Integer noOfcargoes) {

this.noOfcargoes = noOfcargoes;

}

//fill the code

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!