Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
(Compilation Errors Main.java:69: error: cannot find symbol shipmentEntity[k].display(); ^ symbol: method display() location: class ShipmentEntity 1 error) for the below program..

What I have tried:

ShipmentEntity.java
  public class ShipmentEntity {
protected String shipmentEntityName;
protected String identificationNumber;
ShipmentEntity()
{
    
}

public ShipmentEntity(String shipmentEntityName, String identificationNumber) {
    super();
    this.shipmentEntityName = shipmentEntityName;
	this.identificationNumber = identificationNumber;
}
public String getShipmentEntityName() {
	return shipmentEntityName;
}
public void setShipmentEntityName(String shipmentEntityName) {
	this.shipmentEntityName = shipmentEntityName;
}
public String getIdentificationNumber() {
	return identificationNumber;
}
public void setIdentificationNumber(String identificationNumber) {
	this.identificationNumber = identificationNumber;
}





}


import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {

public static void main(String args[]) throws IOException, ParseException
{
BufferedReader buf= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the number of shipment entity");
int n = Integer.parseInt(buf.readLine());
int arrcusvalue=0;
int arrcomvalue=0;
int arragnvalue=0;
int arrcarvalue=0;
Customer[] customer=new Customer[n];
int cuslength=0;
int comlength=0;
int carrlength=0;
int agnlength=0;
Company[] company=new Company[n];
Carrier[] carrier=new Carrier[n];
Agent[] agent=new Agent[n];
for (int i = 0; i <n; i++)
{

System.out.println("Enter the shipment entity "+(i+1)+" details :");
System.out.println("Select the shipment entity type");
System.out.println("1)Customer");
System.out.println("2)Company");
System.out.println("3)Agent");
System.out.println("4)Carrier");
int enttype = Integer.parseInt(buf.readLine());

if (enttype==1)
{
String[] val = buf.readLine().split(",");
int invalue=Integer.parseInt(val[2]);
customer[cuslength++]=Customer.createRecord(val[0],val[1],invalue,val[3]);
arrcusvalue=arrcusvalue+1;
}
if (enttype==2)
{
String[] val = buf.readLine().split(",");
company[comlength++] = Company.createRecord(val[0],val[1],val[2],val[3],val[4]);
arrcomvalue=arrcomvalue+1;
}
if (enttype==3)
{
String[] val = buf.readLine().split(",");
agent[agnlength++]=Agent.createRecord(val[0],val[1],val[2],val[3],val[4]);
arragnvalue=arragnvalue+1;
}
if (enttype==4)
{
String[] val = buf.readLine().split(",");
carrier[carrlength++]=Carrier.createRecord(val[0],val[1],val[2],val[3]);
arrcarvalue=arrcarvalue+1;
}
}
System.out.println("Shipment details are");
System.out.println("Enter the shipment entity type to display");
String entitytype;

entitytype=buf.readLine();
if (entitytype.equals("Customer"))
{
System.out.format("%-15s %-25s %-15s %-15s\n","Name","Identification Number","Customer Id","Customer Name");
for(int i=0;i<arrcusvalue;i++)
{

customer[i].display();
}

}

if (entitytype.equals("Agent"))
{
System.out.format("%-15s %-25s %-15s %-15s %-15s\n","Name","Identification Number ","Agent Name","IATA","FMC");
for(int i=0;i<arragnvalue;i++)
{

agent[i].display();
}

}
if (entitytype.equals("Company"))
{
System.out.format("%-15s %-25s %-15s %-15s %-15s\n","Name","Identification Number","Company Name","IATA","FMC");
for(int i=0;i<arrcomvalue;i++)
{

company[i].display();
}

}

if (entitytype.equals("Carrier"))
{
System.out.format("%-15s %-25s %-15s %-15s\n","Name","Identification Number","Code Name","IATA");
for(int i=0;i<arrcarvalue;i++)
{

carrier[i].display();
}

}


}
}
Posted
Updated 22-Jul-18 21:20pm
v2
Comments
Jochen Arndt 23-Jul-18 2:53am    
You have posted the wrong code.

Your code does not contain any usage of the shipmentEntity class and the index variable k mentioned by the error.
Jochen Arndt 23-Jul-18 3:25am    
The posted code still does not contain the line where the error is thrown.

You have shown us the ShipmentEntity class meanwhile. But that does not contain a display() member function and is not derived from another class which might contain the function.

This is Ship Entity

ShipmentEntity.java
  public class ShipmentEntity {
protected String shipmentEntityName;
protected String identificationNumber;
ShipmentEntity()
{
    
}

public ShipmentEntity(String shipmentEntityName, String identificationNumber) {
    super();
    this.shipmentEntityName = shipmentEntityName;
	this.identificationNumber = identificationNumber;
}
public String getShipmentEntityName() {
	return shipmentEntityName;
}
public void setShipmentEntityName(String shipmentEntityName) {
	this.shipmentEntityName = shipmentEntityName;
}
public String getIdentificationNumber() {
	return identificationNumber;
}
public void setIdentificationNumber(String identificationNumber) {
	this.identificationNumber = identificationNumber;
}





}
 
Share this answer
 
Comments
Richard Deeming 23-Jul-18 11:55am    
If you want to update your question, click the green "Improve question" link and update your question.

DO NOT post the update as a "solution".
Quote:
(Compilation Errors Main.java:69: error: cannot find symbol shipmentEntity[k].display(); ^ symbol: method display() location: class ShipmentEntity 1 error) for the below program..

Your code does have a
Java
shipmentEntity[k].display();

at all.

We can't help you if you don't give correct information.
 
Share this answer
 
Comments
Member 13922169 23-Jul-18 3:11am    
ShipmentEntity.java
public class ShipmentEntity {
protected String shipmentEntityName;
protected String identificationNumber;
ShipmentEntity()
{

}

public ShipmentEntity(String shipmentEntityName, String identificationNumber) {
super();
this.shipmentEntityName = shipmentEntityName;
this.identificationNumber = identificationNumber;
}
public String getShipmentEntityName() {
return shipmentEntityName;
}
public void setShipmentEntityName(String shipmentEntityName) {
this.shipmentEntityName = shipmentEntityName;
}
public String getIdentificationNumber() {
return identificationNumber;
}
public void setIdentificationNumber(String identificationNumber) {
this.identificationNumber = identificationNumber;
}





}
Patrice T 23-Jul-18 3:14am    
Use Improve question to update your question.
So that everyone can pay attention to this information.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900