A类:
package projsp3;
public class Item {
private String itemId;
private float price;
private String description;
private boolean available;
private int quantity_in_stock;
public Item(String itemId,String description,float price,boolean available,int quantity_in_stock){
this.itemId=itemId;
this.description=description;
this.price=price;
this.available=available;
this.quantity_in_stock=quantity_in_stock;
}
public String getItemId(){
return itemId;
}
public void setItemId(String aItemId){
itemId=aItemId;
}
public float getPrice(){
return price;
}
public String getDescription(){
return description;
} public boolean getAvailable(){
return available;
} public void setAvailable(boolean aAvailable){
available=aAvailable;
} public int getQuantity_in_stock(){
return quantity_in_stock;
} public void setQuantity_in_stock(int aQuantity_in_stock){
quantity_in_stock=aQuantity_in_stock;
}
}
b类:
package projsp3;
import java.util.Vector;
public class Catalog{
private Vector items=new Vector();
synchronized public Vector getItems(){
return items;
}
synchronized public Item getItem(String itemId){
int index=Integer.parseInt(itemId);
return (Item)items.elementAt(index);
}
synchronized public void setItem(Item item,String itemId){
int index=Integer.parseInt(itemId);
items.set(index,item);
}
public Catalog(){
items.addElement(new Item("0","Toothbrush",(float)10,true,100));
items.addElement(new Item("1","Comb",(float)1,true,100));
items.addElement(new Item("2","Razor",(float)13,true,1000));
items.addElement(new Item("3","After shave",(float)10,true,900));
items.addElement(new Item("4","Cologne",(float)25,true,133));
items.addElement(new Item("5","shaving cream",(float)12,true,353));
items.addElement(new Item("6","Razor blades",(float)9,true,333));
items.addElement(new Item("7","Pen stand",(float)0.99,true,222));
items.addElement(new Item("8","Duke beanie",(float)19,true,343));
items.addElement(new Item("9","Elec Razor",(float)100,true,884));
}
}
package projsp3;
public class Item {
private String itemId;
private float price;
private String description;
private boolean available;
private int quantity_in_stock;
public Item(String itemId,String description,float price,boolean available,int quantity_in_stock){
this.itemId=itemId;
this.description=description;
this.price=price;
this.available=available;
this.quantity_in_stock=quantity_in_stock;
}
public String getItemId(){
return itemId;
}
public void setItemId(String aItemId){
itemId=aItemId;
}
public float getPrice(){
return price;
}
public String getDescription(){
return description;
} public boolean getAvailable(){
return available;
} public void setAvailable(boolean aAvailable){
available=aAvailable;
} public int getQuantity_in_stock(){
return quantity_in_stock;
} public void setQuantity_in_stock(int aQuantity_in_stock){
quantity_in_stock=aQuantity_in_stock;
}
}
b类:
package projsp3;
import java.util.Vector;
public class Catalog{
private Vector items=new Vector();
synchronized public Vector getItems(){
return items;
}
synchronized public Item getItem(String itemId){
int index=Integer.parseInt(itemId);
return (Item)items.elementAt(index);
}
synchronized public void setItem(Item item,String itemId){
int index=Integer.parseInt(itemId);
items.set(index,item);
}
public Catalog(){
items.addElement(new Item("0","Toothbrush",(float)10,true,100));
items.addElement(new Item("1","Comb",(float)1,true,100));
items.addElement(new Item("2","Razor",(float)13,true,1000));
items.addElement(new Item("3","After shave",(float)10,true,900));
items.addElement(new Item("4","Cologne",(float)25,true,133));
items.addElement(new Item("5","shaving cream",(float)12,true,353));
items.addElement(new Item("6","Razor blades",(float)9,true,333));
items.addElement(new Item("7","Pen stand",(float)0.99,true,222));
items.addElement(new Item("8","Duke beanie",(float)19,true,343));
items.addElement(new Item("9","Elec Razor",(float)100,true,884));
}
}
解决方案 »
- 请问如何使一个组件跟着鼠标箭头走啊?
- 求助问题,谢谢!!!。
- JAVA新手处女问~
- 字符串数组的问题???
- 新人请教高手~!HELP ME~~~~~~~~~~~~~~~~!
- 简单问题:由哪个方法可以确定一个字符串是否包含另一个字符串?
- 请教高手mtdropdown是作什么的,请讲地详细些
- 有好的实现广播的例子么?谢谢先!
- 我在程序中两次使用查询语句,出现SQL Exception,请高手指教
- 我正忙于有关于WebGIS的毕设,其中有想在Applet中放置几个TabPage,即标签页,敬请各位师长学兄不吝赐教,小弟在此先表谢意。如由简单实例,那最好不过,我的e-mail是[email protected]
- DISPOSE_ON_CLOSE 与 HIDE_ON_CLOSE的区别
- 请大家帮忙看一下!
把你的编译出来的A类路径也加到classpath里去
然后到projsp3的上一层目录
javac projsp3\*.java