Results 1 to 2 of 2
  1. #1
    hoangx87 is offline Member
    Join Date
    Mar 2011
    Posts
    44
    Rep Power
    0

    Default 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);
    ^

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    Read the error message.

    "constructor Shape(java.lang.String,int)"

    Does your Shape class have a constructor which takes a String and an int as its parameters?

Similar Threads

  1. java:92: cannot find symbol error
    By noviceNewbie in forum AWT / Swing
    Replies: 3
    Last Post: 12-18-2010, 03:46 AM
  2. Java cannot find symbol- variable img
    By crutchfieldj in forum New To Java
    Replies: 3
    Last Post: 04-13-2010, 11:47 PM
  3. java:34:cannot find symbol
    By MissyMadi in forum New To Java
    Replies: 5
    Last Post: 11-09-2008, 07:53 PM
  4. Replies: 9
    Last Post: 10-18-2008, 09:26 PM
  5. Replies: 3
    Last Post: 05-01-2008, 09:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •