Results 1 to 2 of 2
- 03-24-2011, 12:23 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 44
- Rep Power
- 0
TestPrintable.java:14: cannot find symbol
I have total of four classes, which are person, shape, printable,testprint.
public class Person implements Printable{
String name;
double weight;
public Person(String n, double w){
name = n;
weight = w;
}
public double getWeight(){
return weight;
}
public double getValue(){
return weight;
}
public String toString(){
return name + "weight" + getWeight();
}
public void print(){
}
}
public class Shape implements Printable{
String color;
double density;
double volume;
public Shape(String c, double d, double v){
color=c;
density=d;
volume=v;
}
public double getWeight(){
return density * volume;
}
public double getValue(){
return getWeight();
}
public String toString(){
return color + "weight" + getWeight();
}
public void print(){
}
}
//has a print method with no params and void return.(DONE!!!)
//Shape and Person should implement Printable (DONE!!!)
// Make class TestPrintable, with method printAll,
//param is array of printable objects. Loop through
//array and call each object print method.
//In main method, make an array of one Shape and one Person,
//and pass to the printall methods.
public interface Printable{
public void print();
}
public class TestPrintable{
public void printALL(Printable[]param){
for (int i=0; i<param.length; i++){
param[i].print();
}
}
public static void main (String[]args){
Printable r =new Shape("joe", 41);
Printable s =new Person("james", 50);
Printable[]param={r,s};
printAll(param);
}
}
I need to know what I have to do to get the program to be error free.
With the following error:
TestPrintable.java:14: cannot find symbol
symbol : constructor Shape(java.lang.String,int)
location: class Shape
Printable r =new Shape("joe", 41);
^
TestPrintable.java:18: cannot find symbol
symbol : method printAll(Printable[])
location: class TestPrintable
printAll(param);
^
- 03-24-2011, 12:51 AM #2
Similar Threads
-
java:92: cannot find symbol error
By noviceNewbie in forum AWT / SwingReplies: 3Last Post: 12-18-2010, 02:46 AM -
Java cannot find symbol- variable img
By crutchfieldj in forum New To JavaReplies: 3Last Post: 04-13-2010, 10:47 PM -
java:34:cannot find symbol
By MissyMadi in forum New To JavaReplies: 5Last Post: 11-09-2008, 06:53 PM -
cannot find symbol symbol :constructor Error. Please help! =(
By KalEl in forum New To JavaReplies: 9Last Post: 10-18-2008, 08:26 PM -
cannot find symbol symbol : class Item location: package platypos.services.order
By officialhopsof in forum New To JavaReplies: 3Last Post: 05-01-2008, 08:30 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks