Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Core Java_OOPS Concept_Problem Statement 4 TransGlobal Shipping Company is a big

ID: 3906171 • Letter: C

Question

Core Java_OOPS Concept_Problem Statement 4

TransGlobal Shipping Company is a big name in the Logistics marketplace, with their global presence in over 10 countries. Having a widespread influence, the Company has huge connects with many Agents and Carriers for a customer – centric delivery.


A Shipment Entity can be handled by Customer himself, Agents, Carriers or the Company. At TransGlobal, there is enourmous shipment data flowing across and therefore they need an efficient system to handle them. Write a program that will retrieve the details of the Shipment Entity based on 4 types of people who handle it namely, Customer, Agent, Carrier and Company. Get all the details related to the Shipment Entity as input from the user.

This problem uses the concept of Hierarchical Inheritance. ShipmentEntitty Class is the parent class and 4 classes Customer, Agent, Carrier and Company extends it.

[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.]   

1.Create a class named ShipmentEntity
Include the following protected data members / attributes:

     String shipmentEntityName

     String identificationNumber

   Include appropriate getters and setters and constructor
    Constructor : ShipmentEntity(String shipmentEntityName,String identificationNumber).
    Include the methods void display() which will be implemented by all its sub classes.    

2.Create a class named Customer that extends ShipmentEntity
      Include the following private data members / attributes:

      Integer id

      String name

      Include appropriate getters and setters and constructor.
      Constructor : Customer(String shipmentEntityName,String identificationNumber,Integer id,String name)
Include the following methods :


Use System.out.format("%-15s %-25s %-15s %-15s ","Name","Identification Number","Customer Id","Customer Name") in display method.

3.Create a class named Company that extends ShipmentEntity

      Include the following private data members / attributes:

      String identifier

      String iata

      String fmc

      Include appropriate getters and setters and constructor.
     Constructor : Company(String name,String identificationNumber,String identifier,String iata,String fmc).
      Include the following methods :
    

Use System.out.format("%-15s %-25s %-15s %-15s %-15s ","Name","Identification Number","Company Name","IATA","FMC") in display method.
  
4.Create a class named Agent that extends ShipmentEntity
    Include the following private data members / attributes:

    String name

    String iata

    String fmc;   

    Include appropriate getters and setters and constructor.
    Constructor as follows Agent(String shipmentEntityName,String identificationNumber,String name,String iata,String fmc)
   Include the following methods :

Use System.out.format("%-15s %-25s %-15s %-15s %-15s ","Name","Identification Number ","Agent Name","IATA","FMC");

5.Create a class named Carrier that extends ShipmentEntity
Include the following private data members / attributes:

String carrierCode

String iata

Include the following methods :
Include appropriate getters and setters and constructor.
Constuctor : Carrier(String name,String identificationNumber,String carrierCode,String iata).

Use System.out.format("%-15s %-25s %-15s %-15s ","Name","Identification Number","Code Name","IATA");   


Input and Output Format:
Refer sample input and output for formatting specifications.
Note : [All text in bold corresponds to input and the rest corresponds to output.]

Sample Input and Output:
Enter the number of shipment entity
3
Enter the shipment entity 1 details :
Select the shipment entity type
1)Customer
2)Company
3)Agent
4)Carrier
1
Laptop,800101,111,Rahul

Enter the shipment entity 2 details :
Select the shipment entity type
1)Customer
2)Company
3)Agent
4)Carrier
1
Micro phone,801102,211,Mitharan

Enter the shipment entity 3 details :
Select the shipment entity type
1)Customer
2)Company
3)Agent
4)Carrier
3
Electric Fan,912115,Rahul,USCTG1230,PMI/SJC/1361

Shipment details are
Enter the shipment entity type to display
Customer
Name            Identification Number     Customer Id     Customer Name
Laptop          800101                    111             Rahul        
Micro phone     801102                    211             Mitharan

I am providing the piece of code. Please update the code and send me back. I need to have it in the given format.

ShipmentEntity.Java


public class ShipmentEntity {
  
protected String shipmentEntityName;
protected String identificationNumber;
  
//fill your code
public void setShipmentEntityName(String shipmentEntityName){
this.shipmentEntityName = shipmentEntityName;
}
  
public String getShipmentEntityName(){
return shipmentEntityName;
}
  
public void setIdentificationNumber(String identificationNumber){
this.identificationNumber = identificationNumber;
}
  
public String getIdentificationNumber(){
return identificationNumber;
}
// fill your code here
}

Agent.java

public class Agent{
  
String name;
String iata;
String fmc;
  
//fill your code
  
public void setName(String name){
this.name = name;
}
  
public String getName(){
return name;
}
  
public void setIata(String iata){
this.iata = iata;
}
public String getIata(){
return iata;
}

public void setFmc(String fmc){
this.fmc = fmc;
}
public String getFmc(){
return fmc;
}
// fill code here
}

Carrier.java

public class Carrier {
  
private String carrierCode;
private String iata;
  
//fill your code
  
public void setCarrierCode(String carrierCode){
this.carrierCode = carrierCode;
}
public String getCarrierCode(){
return carrierCode;
}

  
public void setIata(String iata){
this.iata = iata;
}
public String getIata(){
return iata;
}
// fill your code here
}

Company.java

public class Company {
  
private String identifier;
private String iata;
private String fmc;
  
//fill your code

public void setIdentifier(String identifier){
this.identifier = identifier;
}
public String getIdentifier(){
return identifier;
}
  
public void setIata(String iata){
this.iata = iata;
}
public String getIata(){
return iata;
}

public void setFmc(String fmc){
this.fmc = fmc;
}
public String getFmc(){
return fmc;
}
// fill your code here
      
}

Customer.java

public class Customer {
  
private Integer id;
private String name;
  
//fill your code

public void setId(Integer id){
this.id = id;
}
  
public Integer getId(){
return id;
}
  
public void setName(String name){
this.name = name;
}
  
public String getName(){
return name;
}
// fill your code here
}

Main.java

import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Main {
  
public static void main(String args[]) throws IOException, ParseException{
//fill your code
}
}

S.NO Method Name Method Description 1 void display() display the customer details

Explanation / Answer

//ShipmentEntity Class

package com.TransGlobal.shipments;

public class ShipmentEntity {

protected String shipmentEntityName;

protected String identificationNumber;

public ShipmentEntity(String shipmentEntityName, String identificationNumber) {

this.shipmentEntityName = shipmentEntityName;

this.identificationNumber = identificationNumber;

}

public void setShipmentEntityName(String shipmentEntityName) {

this.shipmentEntityName = shipmentEntityName;

}

public String getShipmentEntityName() {

return shipmentEntityName;

}

public void setIdentificationNumber(String identificationNumber) {

this.identificationNumber = identificationNumber;

}

public String getIdentificationNumber() {

return identificationNumber;

}

public void display() {

}

}

/*********end************************/

//Customer class

package com.TransGlobal.shipments;

import com.TransGlobal.shipments.ShipmentEntity;

public class Customer extends ShipmentEntity {

private Integer id;

private String name;

Customer(String shipmentEntityName, String identificationNumber, Integer id, String name) {

super(shipmentEntityName, identificationNumber);

this.id = id;

this.name = name;

}

public void setId(Integer id) {

this.id = id;

}

public Integer getId() {

return id;

}

public void setName(String name) {

this.name = name;

}

public String getName() {

return name;

}

@Override

public void display() {

System.out.format("%-15s %-25s %-15s %-15s ", shipmentEntityName, identificationNumber, id, name);

}

}

/*********end************************/

//Company class

package com.TransGlobal.shipments;

public class Company extends ShipmentEntity {

private String identifier;

private String iata;

private String fmc;

Company(String name, String identificationNumber, String identifier, String iata, String fmc) {

super(name, identificationNumber);

this.identifier = identifier;

this.iata = iata;

this.fmc = fmc;

}

public void setIdentifier(String identifier) {

this.identifier = identifier;

}

public String getIdentifier() {

return identifier;

}

public void setIata(String iata) {

this.iata = iata;

}

public String getIata() {

return iata;

}

public void setFmc(String fmc) {

this.fmc = fmc;

}

public String getFmc() {

return fmc;

}

public void display() {

System.out.format("%-15s %-25s %-15s %-15s %-15s ", shipmentEntityName, identificationNumber, identifier, iata,

fmc);

}

}

/*********end************************/

//Agent class

package com.TransGlobal.shipments;

public class Agent extends ShipmentEntity {

String name;

String iata;

String fmc;

Agent(String shipmentEntityName, String identificationNumber, String name, String iata, String fmc) {

super(shipmentEntityName, identificationNumber);

this.name = name;

this.fmc = fmc;

}

public void setName(String name) {

this.name = name;

}

public String getName() {

return name;

}

public void setIata(String iata) {

this.iata = iata;

}

public String getIata() {

return iata;

}

public void setFmc(String fmc) {

this.fmc = fmc;

}

public String getFmc() {

return fmc;

}

public void display() {

System.out.format("%-15s %-25s %-15s %-15s %-15s ", shipmentEntityName, identificationNumber, name, iata, fmc);

}

}

/*********end************************/

//Carrier class

package com.TransGlobal.shipments;

public class Carrier extends ShipmentEntity {

private String carrierCode;

private String iata;

Carrier(String name, String identificationNumber, String carrierCode, String iata) {

super(name, identificationNumber);

this.carrierCode = carrierCode;

this.iata = iata;

}

public void setCarrierCode(String carrierCode) {

this.carrierCode = carrierCode;

}

public String getCarrierCode() {

return carrierCode;

}

public void setIata(String iata) {

this.iata = iata;

}

public String getIata() {

return iata;

}

public void display() {

System.out.format("%-15s %-25s %-15s %-15s ", shipmentEntityName, identificationNumber, carrierCode, iata);

}

}

/********* end ************************/

//Main class

package com.TransGlobal.shipments;

import java.io.IOException;

import java.text.ParseException;

import java.util.ArrayList;

import java.util.List;

import java.util.Scanner;

public class Main {

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

Scanner input = new Scanner(System.in);

System.out.println("Enter the number of shipment entity");

int noOfShipment = Integer.parseInt(input.nextLine());

List<Customer> customerList = new ArrayList<Customer>();

Customer customer = null;

Agent agent = null;

Company company = null;

Carrier carrier = null;

List<Company> companyList = new ArrayList<Company>();

List<Agent> agentList = new ArrayList<Agent>();

List<Carrier> carrierList = new ArrayList<Carrier>();

for (int i = 1; i <= noOfShipment; i++) {

System.out.println("Enter the shipment entity " + i + " details :");

System.out.println("Select the shipment entity type");

System.out.println("1)Customer 2)Company 3)Agent 4)Carrier");

int typeOfShipment = Integer.parseInt(input.nextLine());

String all = null;

switch (typeOfShipment) {

case 1:

System.out.println("Enter the shipment entity " + i + " details :");

all = input.nextLine();

customer = new Customer(all.split(",")[0], all.split(",")[1], Integer.parseInt(all.split(",")[2]),

all.split(",")[3]);

customerList.add(customer);

break;

case 2:

System.out.println("Enter the shipment entity " + i + " details :");

all = input.nextLine();

company = new Company(all.split(",")[0], all.split(",")[1], all.split(",")[2], all.split(",")[3],

all.split(",")[4]);

companyList.add(company);

break;

case 3:

System.out.println("Enter the shipment entity " + i + " details :");

all = input.nextLine();

agent = new Agent(all.split(",")[0], all.split(",")[1], all.split(",")[2], all.split(",")[3],

all.split(",")[4]);

agentList.add(agent);

break;

case 4:

System.out.println("Enter the shipment entity " + i + " details :");

all = input.nextLine();

carrier = new Carrier(all.split(",")[0], all.split(",")[1], all.split(",")[2], all.split(",")[3]);

carrierList.add(carrier);

break;

default:

System.out.println("choose the proper option");

break;

}

}

System.out.println("Shipment details are " + "Enter the shipment entity type to display");

switch (input.next()) {

case "Customer":

for (int i = 0; i < customerList.size(); i++) {

customer = customerList.get(i);

customer.display();

}

case "Agent":

for (int i = 0; i < agentList.size(); i++) {

agent = agentList.get(i);

agent.display();

}

case "Company":

for (int i = 0; i < companyList.size(); i++) {

company = companyList.get(i);

company.display();

}

case "Carrier":

for (int i = 0; i < carrierList.size(); i++) {

carrier = carrierList.get(i);

carrier.display();

}

break;

default:

System.out.println("please give the correct choice...");

break;

}

}

}

/*********end************************/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote