•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 402,054 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,400 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 290 | Replies: 15
![]() |
•
•
Join Date: May 2008
Posts: 34
Reputation:
Rep Power: 1
Solved Threads: 0
init:
deps-jar:
Compiling 1 source file to C:\NetBeansProjects\SCHOOL1\JavaApplication31\build\classes
C:\NetBeansProjects\SCHOOL1\JavaApplication31\src\javaapplication31\Inventory3a.java:185: cannot find symbol
symbol : constructor Product(java.lang.String,double,double,double)
location: class javaapplication31.Product
super( dvdTitle, dvdItemNumber, dvdStock, dvdPrice);
1 error
BUILD FAILED (total time: 0 seconds)
deps-jar:
Compiling 1 source file to C:\NetBeansProjects\SCHOOL1\JavaApplication31\build\classes
C:\NetBeansProjects\SCHOOL1\JavaApplication31\src\javaapplication31\Inventory3a.java:185: cannot find symbol
symbol : constructor Product(java.lang.String,double,double,double)
location: class javaapplication31.Product
super( dvdTitle, dvdItemNumber, dvdStock, dvdPrice);
1 error
BUILD FAILED (total time: 0 seconds)
package javaapplication31;
import java.util.Arrays;
public class Inventory3a{
Inventory3a() { // constructor
Product[] dvd = new Product[4];
dvd[0] = new Product(685.0,"How to Loose a Guy in 10 days",2003, 4, 19.99 );
dvd[1] = new Product(565.0,"Coyote Ugly Ugly",2000, 8, 19.98 );
dvd[2] = new Product(785.0,"Legally Blonde",2001, 13, 19.99);
dvd[3] = new Product(578.0,"Sweet Home Alabama",2002, 8,18.56);
double totalInStock = 0.0;
double totalValue = 0.0;
for(int i = 0; i < 4; i++)
{
System.out.println("Item number: " + dvd[i].getdvdItemNumber());
System.out.println("Title: " + dvd[i].getdvdTitle());
System.out.println("Made in: "+ dvd[i].getdvdYear());
System.out.println("In Stock: " + dvd[i].getdvdStock());
System.out.println("The price of each DVD is $" + dvd[i].getdvdPrice());
System.out.println("The value of the inventory is $" + dvd[i].Calvalue());
totalInStock += dvd[i].getdvdStock();
totalValue += dvd[i].Calvalue();
System.out.println("Total In Stock:" + totalInStock +
" Total Value: $" + totalValue);
System.out.println("Restock Fee: " + (dvd[i].getdvdStock() * dvd[i].getdvdPrice()) * 0.05);}
System.out.println();
}
public static void main(String args []) {
//Sorting strings
String[ ] titles = {"How to Loose a Guy in 10 days", "Coyote Ugly", "Legally Blonde", "Sweet Home Alabama"};
Arrays.sort(titles); //use the built-in sorting routine
for (int i = 0; i < 4; i++)
System.out.println(titles[ i ]);
double ReStockFee = 0.05;
new Inventory3a();
} //end method main
}
class Product
{
public double dvdItemNumber;
public String dvdTitle;
public double dvdYear;
public double dvdStock;
public double dvdPrice;
public double totalInStock;
public double totalValue;
public double ReStockFee;
// five-argument constructor
Product(double item,String title,double year, double stock, double price )
{
dvdItemNumber = item;
dvdTitle = title;
dvdYear = year;
dvdStock = stock;
dvdPrice = price;
} //end five-argument constructor
// set dvd item number
public void setdvdItemNumber (double item)
{
dvdPrice= item;
}// end method setdvdItemNumber
// return dvd item number
public double getdvdItemNumber()
{
return dvdItemNumber;
}// end method getdvdItemNumber
// set dvd title
public void setdvdTitle (String title)
{
dvdTitle= title;
}// end method setdvdTitle
// return dvd title
public String getdvdTitle()
{
return dvdTitle;
}// end method getdvdTitle
// set dvd year
// set dvd stock
public void setdvdYear(double year)
{
dvdYear= year;
}// return dvd year
public double getdvdYear()
{
return dvdYear;
}// end method getdvdYear
// set dvd stock
public void setdvdStock(double stock)
{
dvdStock= stock;
} // end method getdvdStock
// return dvd stock
public double getdvdStock()
{
return dvdStock;
}// end method getdvdStock
// set dvd price
public void setdvdPrice (double price)
{
dvdPrice= price;
}// end method setdvdPrice
// return dvd price
public double getdvdPrice()
{
return dvdPrice;
}// end method getdvdPrice
// set total in stock
public void settotalInStock (double total)
{
totalInStock= total;
}// end method settotalInStock
// return total in stock
public double gettotalInStock()
{
return totalInStock;
}// end method gettotalInStock
// caluclate Inventory
public double Calvalue() {
return dvdPrice * dvdStock;
} //end method value
// calculates Total Value
public double totalValue(){
return dvdPrice * totalInStock;
} // end method value
// returns smaller, bigger or equals according to dvdTitle
public int compareTo(Object o){
Product other = (Product) o;
return dvdTitle.compareTo(other.dvdTitle);
}
class Movie extends Product
{
private double reStockingFee;
public Movie(String dvdTitle, double dvdItemNumber, double dvdStock, double dvdPrice, double reStockingFee)
{
super( dvdTitle, dvdItemNumber, dvdStock, dvdPrice);
this.reStockingFee = reStockingFee;
}
@Override
public double getdvdPrice() //returns the value of the inventory, plus the restocking fee
{
return super.getdvdPrice() + reStockingFee;
}
@Override
public String toString()
{
return new StringBuffer().append("Price: " + super.getdvdPrice()).append(" With RestockingFee: " + getdvdPrice()).toString();
}
} // end class Movie
} //end class Product•
•
•
•
Read the message: You are calling the super() constructor with arguments that do not match any declared constructor in the parent class.
That pretty much sums it up.
For a more thorough explanation--
java Syntax (Toggle Plain Text)
// somewhere in product... // only Constructor for product defined // takes a double, String, double, double, and double Product(double item,String title,double year, double stock, double price )
java Syntax (Toggle Plain Text)
class Movie extends Product { private double reStockingFee; public Movie(String dvdTitle, double dvdItemNumber, double dvdStock, double dvdPrice, double reStockingFee) { // calling Product constructor String, double, double, double // you forgot to provide a double argument before the String! // compiler cannot locate this non-existant 4-arg constructor in Product! super( dvdTitle, dvdItemNumber, dvdStock, dvdPrice);
•
•
Join Date: Jan 2008
Posts: 1,490
Reputation:
Rep Power: 6
Solved Threads: 187
•
•
•
•
I am so very lost in where you are talking about, any other ways of explaining where to look to make the changes so it will work?
Alex did a good job of explaining it above. Product is the superclass. Movie is the subclass. Inside your Movie constructor, you have this line:
super( dvdTitle, dvdItemNumber, dvdStock, dvdPrice);
That means "Look in my superclass for a constructor that takes four arguments." Movie's superclass is Product. Product has one constructor. It's this one:
Product(double item,String title,double year, double stock, double price )
The above constructor takes five arguments. You've passed it four arguments. As Ezzaral mentioned, the number of arguments need to match, in addition to the argument types. What's year supposed to be? You haven't specified with this call:
super( dvdTitle, dvdItemNumber, dvdStock, dvdPrice);
•
•
Join Date: Jan 2008
Posts: 1,490
Reputation:
Rep Power: 6
Solved Threads: 187
Well, try it and find out. Don't be afraid to experiment. You at least won't get THAT error anymore if you make them the same, but you may have other errors. It is something you need to fix if you are going to keep that line in the program.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Another "cannot find symbol" compiling error (Java)
- compiling error, tried debugging but no luck (C)
- compiling error - help (C++)
- error 88:'(' expected when trying to display an array any help (Pascal and Delphi)
- compiling error wtf!?!? (C)
- Please help me out, need help (C)
Other Threads in the Java Forum
- Previous Thread: help please
- Next Thread: java.lang.NoClassDefFoundError: ???



Linear Mode