SAYED
SAYED

Reputation: 1

Constructor of a class cannot be applied to the given type

I am trying to save my data by using Arraylist (I have a Software class which extends from products):

class Software extends Products{

    private float ram;
    private float processor;

    public Software (int productID,String productName,int productYear,String productPublishHouse)
    {
        super(productID,productName, productYear, productPublishHouse);

        this.ram = ram;
        this.processor = processor;

        // super(productID,productName, productYear, productPublishHouse);

    }

    public void setRam(){
        this.ram = ram;
    }

    public float getRam(){
        return ram;
    }

}

But in my other class which is SoftwareProducts I have declared the ram and processor attributes in actionperformed(ActionEvent e) method

float ram = Float.parseFloat(ramtf.getText());        
float processor = Float.parseFloat(processortf.getText());

I am getting error on this section:

Software.softwareList.add(new Software(ram,processor));

I think I have to add more attributes from parent class ?

Upvotes: 0

Views: 58

Answers (1)

jsh
jsh

Reputation: 338

The code you have so far does not list a constructor for doing what you are trying with "new Software(ram,processor)". In other words you don't seem to have the constructor defined for creating a "Software" object given only the two parameters you have listed.

Upvotes: 2

Related Questions