View Single Post
  #1 (permalink)  
Old 08-05-2007, 11:34 PM
Rgfirefly24 Rgfirefly24 is offline
Member
 
Join Date: Aug 2007
Posts: 20
Rgfirefly24 is on a distinguished road
error with super.xxxxx
i'm attempting to create a child class that passes data to the parent class's method or constructor. I get the following error when compiling:
G:\Chair.java:54: cannot find symbol
symbol : method Item(int,float,java.lang.String)
location: class Item
super.Item(passchair, passchair_cost, passname);
^
1 error

Tool completed with exit code 1

this is the chair.java file:

Code:
import javax.swing.*; public class Chair extends Item{ private int chair1; private float chair1_cost; private String name; public Chair(){ } public Chair(int chair1, float chair1_cost, String name){ this.chair1 = chair1; this.chair1_cost = chair1_cost; this.name = name; this.passdata(chair1, chair1_cost, name); this.setchair1(super.getItemNum()); this.setchair1_cost(super.getCost()); this.setname(super.getManufacturersName()); } public void setchair1(int newchair1){ chair1 = newchair1; } public int getchair1(){ return chair1; } public void setchair1_cost(float newchair1_cost){ chair1_cost = newchair1_cost; } public float getchair1_cost(){ return chair1_cost; } public void setname(String newname){ name = newname; } public String getname(){ return name; } public void passdata(int passchair, float passchair_cost, String passname){ super.Item(passchair, passchair_cost, passname); } } and this is the Item.java file: import javax.swing.*; public class Item{ protected int item_number; protected float item_cost; protected String manufacturers_name; public boolean TF; public boolean TF1; /* default constructor */ Item(){ } Item(int item_number, float item_cost, String manufacturers_name){ this.item_number = item_number; this.item_cost = item_cost; this.manufacturers_name = manufacturers_name; this.setItemNum(item_number); this.setItemCost(item_cost); this.setManufacturersName(manufacturers_name); } public boolean isItemnum1(){ return TF; } public boolean isCost1(){ return TF1; } public int getItemNum(){ return item_number; } public float getCost(){ return item_cost; } public String getManufacturersName(){ return manufacturers_name; } public void setItemNum(int newitem_number){ if (newitem_number < 0){ TF = false; item_number = 0; } else { TF = true; item_number = newitem_number; } } public void setItemCost(float newitem_cost){ if (newitem_cost < 0){ TF1 = false; item_cost = 0; } else { TF1 = true; item_cost = newitem_cost; } } public void setManufacturersName(String newmanufacturers_name){ manufacturers_name = newmanufacturers_name; } }

Last edited by levent : 08-05-2007 at 11:51 PM.
Reply With Quote
Sponsored Links