#Error Expected 5 arguments but found 0

1 messages · Page 1 of 1 (latest)

copper hollow
#

Im getting an error saying Expected 5 arguments but found 0 in this code line 28 where it says Parcel parcel = new Parcel();.

public class Manager {

    private QueofCustomers customerQue;
    private ParcelMap parcelMap;
    private Log log;

    public Manager() {
    customerQue = new QueofCustomers();
    parcelMap = new ParcelMap();
    log = Log.getInstance();
    }

    public QueofCustomers getCustomerQue() {
        return customerQue;
    }

    public ParcelMap getParcelMap() {
        return parcelMap;
    }

    public Log getLog() {
        return log;
    }

    private static Parcel createParcel(String parcelID, int daysInDepot, double weight, double height, double length) {
        Parcel parcel = new Parcel();
        parcel.setParcelID(parcelID);
        parcel.setDaysInDepot(daysInDepot);
        parcel.setWeight(weight);
        parcel.setHeight(height);
        parcel.setLength(length);
        return parcel;
    }

    public static void parcelAdd() {

        Manager manager = new Manager();

        Parcel parcel1 = Manager.createParcel("X009", 9, 9, 9, 7);
        manager.getParcelMap().addParcel(parcel1);
        System.out.println(parcel1);

    }


        public static void main(String[] args) {
        parcelAdd();

    }
}```
pastel starBOT
#

<@&987246399047479336> please have a look, thanks.

copper hollow
#

It wont let me send my parcel class for some reason

glass steeple
#

just drag drop the file

copper hollow
#

Ok

#

One minute

#

I cant but My toString has 5 things

#
@Override
    public String toString() {
        return "Parcel ID: " + parcelID + ", Weight: " + weight + ", Height: " + height + ", Length: " + length + ", Days in Depot: " + daysInDepot;
    }```
pastel starBOT
copper hollow
#
 private static Parcel createParcel(String parcelID, int daysInDepot, double weight, double height, double length) {
        Parcel parcel = new Parcel();
        parcel.setParcelID(parcelID);
        parcel.setDaysInDepot(daysInDepot);
        parcel.setWeight(weight);
        parcel.setHeight(height);
        parcel.setLength(length);
        return parcel;
    }``` So this is the error where its Parcel parcel = new Parcel();
pastel starBOT
charred escarp
#

You need to share your Parcel constructor.

#

Is there actually a no arg constructor?

copper hollow
#
public class Parcel implements Serializable
{
    private static final long serialVersionUID = 1L;
    private String parcelID;
    private int daysInDepot;
    private double weight, length, width, height;

    public Parcel(String parcelID, int weight, int height, int length, int daysInDepot) {
        this.parcelID = parcelID;
        this.weight = weight;
        this.height = height;
        this.length = length;
        this.daysInDepot = daysInDepot;
    }```
pastel starBOT
copper hollow
#

This is the Parcel Constuctor

proper monolith
#

then how do you expect this to work:

Parcel parcel = new Parcel();
copper hollow
#

I was thinking that allows for a new parcel object

#

Then I can use it to print the Parcels

charred escarp
#

It does if you have a constructor that accepts 0 parameters...

copper hollow
#

Alright now I get no errors when removing the Parcel Constrctor

#

But will this cause me issues in the future?

charred escarp
#

As soon as you add a parametrized one the default one gets dropped.

#

You need to add constructors for what you want to use.

#

Like we recommended last time, please take the MOOC course.

copper hollow
#

Ok thank you