Simple: write a c'tor that takes no arguments and puts in default values to the instance variables.

Sorry I did not understand a word of that. I am very new to java well programming period. Thank you for being paitent

Write a constructor for Cars that doesn't take any arguments, and just put in some generic values as the default. Something like this:

public Cars() {
     this.item = 0;
     this.name = "Ford Probe";
     this.units = 1;
     this.price = 5000;
}

The default values are whatever values you consider to be a reasonable 'generic' or 'typical' car. In this case, there really isn't any really good choice for it, but any common one should do. Add this to Cars and it should allow you to call it in CarsImpl.

So I need to replace this with the one above

        prodNumber = (int) number;
        prodName = name;
        unitsTotal = (int) total; //validate and store total of cars
        unitPrice = price; // validate and store price per car

rob.sigmon: if you don't understand that part of the default/non-default constructors, you are (already) getting in way over your head.
it's better to ask your teacher for additional explanation now, while you still can catch up. if you don't, you risk to fall way to far behind to be able to make up.

You wouldn't replace it, no; you would have both. Java allows you to have two methods with the same name (called overloading a method), including a c'tor, so long as the parameter lists of the two methods are different.

Or you could just skip the default c'tor in CarsImpl, which would solve the whole issue entirely. Why did you want to have that there in the first place? It wasn't part of the assignment.

In my Cars.java file the error Iam getting now is with this part of the code

public int getProdNumber(){ 

And it says illegal start of expression

Also in the CarsImpl file

public float getTotalValue()

It says getTotalValue() cannot override getTotalValue() in Cars
return type float is not compatiable with int

Without looking into your code quickly I'd think that the first error is because you haven't closed something defined before the beggining of the method and the second one is you are returning an int value while expecting a float

I will post it now these are 3 seperate files

package cars;
// Robert Sigmon
// 10/12/2014 11:00 AM
public class Cars {

    private final int prodNumber; // product number
    private final String prodName;// product name
    private final int unitsTotal; // total units in stock
    private final double unitPrice; // price per unit
    private int item;
    private String name;
    private int units;
    private int price;

    //initialize four-arguement constructor

    public Cars (long number, String name, long total, double price)
    {
         prodNumber = (int) number;
        prodName = name;
        unitsTotal = (int) total; //validate and store total of cars
        unitPrice = price; // validate and store price per car

    } //end four-arguement constructor

    public Cars() {
     this.item = 0;
     this.name = "Ford Probe";
     this.units = 1;
     this.price = 5000;


    public int getProdNumber(){ 
        return prodNumber;
    }   


    public String getProdName() {
        return prodName;
    }


    public int getUnitsTotal() {
        return unitsTotal;
    }


    public double getUnitPrice() {
        return unitPrice;
    }


    public double getValue() {
        return unitsTotal * unitPrice;
    }

    int getTotalValue() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

} // end class cars


package cars;
// Robert Sigmon
// 10/12/2014 11:00 AM

public class CarsInventory {


public static void main( String[] args ) {  

//instantiate cars object
     Cars[] products = new Cars[3];

      products[0] = new Cars(2479, "BMW M6", 45, 65000);
   products[1] = new Cars(2480, "Nissan Leaf", 23, 35000);
   products[2] = new Cars(2481, "Ford Focus", 17, 20000);

// get car information 
System.out.println("RGS New and Used Car Inventory Program");

    for (Cars product : products) {
        System.out.printf("%s %d\n", "Product Number:", product.getProdNumber());

    int model = 0;
System.out.printf( "%s %s\n", "Product Name:", product.getProdName() );
System.out.printf( "%s %d\n", "Total Units in Stock:", product.getUnitsTotal() );
System.out.printf( "%s $%.2f\n", "Price Per Unit:", product.getUnitPrice() );
System.out.printf( "%s $%.2f\n", "Inventory Value:", product.getValue() ); // printing of inventory value

    }
} // end main method
} // end class CarsInventory


package cars;


public class CarsImpl extends Cars {

/**
 *
 * @author Robbie
 */

    private String supplier;
    private float restockfee;
    CarsImpl()
    {
        super();
        supplier = "Unknown";
        restockfee = 0;
    }
    CarsImpl(long productID, String productName, long unitsInStock, double unitPrice, String supplier)
    {
         super(productID, productName, unitsInStock, unitPrice);

        this.supplier = supplier;
    }

    public String getSupplier()
    {
        return supplier;
    }
    public void setProducer(String supplier)
    {
        this.supplier = supplier;
    }
    public float getRestockFee()
    {
        return restockfee;
    }

    public float getTotalValue()
    {
        restockfee = (5*super.getTotalValue())/100;
        //added 5% restocking fee
        return (super.getTotalValue() + restockfee); 
    }
}  //ends class Cars Inventory Restock   

Do you understand the default constructor that was implemented, why it was needed and what it does?

The error of totalvalue is because you are inheriting from Cars where it has already been implemented and now you are trying to return a different data type.

Get prod number returns an error because u haven't closed your constructor

No I do not understand. I closed it now and I get an error on the closing bracket. It says variable prodNumber might not have been initalized.

This was my fault; I copied the c'tor from CarList, rather than Cars. The c'tor should be:

public Cars() {
   this.prodNumber = 0;
   this.prodName = "Ford Probe";
   this.unitsTotal = 1;
   this.unitPrice = 5000;
}

However, the fact that you don't seem to understand the issues at hand is concerning to me. I am wondering if you really understand the idea of constructors in general. You seem to be doing a lot of copy and paste coding without understanding what you are doing.

That fixed all of the errors except this

public float getTotalValue()

It says it getTotal Value cannot override getTotalValue from Cars

That is because the getTotalValue() in Cars is a) not public, and b) type int, not float. An overriding method has to be of an access category as restrictive as or more restrictive than the method it is overriding, and cannot change the return type of the method.

BTW, where did you get throwing an UnsupportedOperationException as the body of this method? It looks like you're using an IDE that generated this body, and you never changed it. What should the getTotalValue() in Cars be, and what should type should it return?

For the restock fee. If you run the program it runs how it is but ineed to add a %5 restock fee

I'm not sure I'm following you. Are you saying that the reason it returns a float is because of the restocking fee?

No Im sorry I just do not understand enough about it. I just have to make it where if something comes back into stock it charges a 5% restocking fee

It looks like you should be setting the restocking fee when you instantiate the object, so change the c'tor for CarsImpl thusly:

CarsImpl(long productID, String productName, long unitsInStock, double unitPrice, String supplier)
{
     super(productID, productName, unitsInStock, unitPrice);

    this.supplier = supplier;
    this.restockfee = (5 * super.getTotalValue()) / 100.00;
}

Then change the return value of the Cars version of getTotalValue() to long. Now you can make the CarsImpl version of getTotalValue() just:

public long getTotalValue()
{
    //added 5% restocking fee
    return Math.round(super.getTotalValue() + restockfee); 
}

This will return the nearest integer value foe the return value of the total value.

this.restockfee = (5 * super.getTotalValue()) / 100.00; this line returns an error incompatible types: possible lossy conversion from double to float

Change restockfee to double.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.