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));
}
}
解决方案 »
- JscrollPanel滚动条问题
- List l=new ArrayList()和Arraylist l=new ArrayList()有什么不同啊?
- 火箭赢啦!!放分!!
- 急, java 中如何实现 utf-8 到 ucs-2 ( ISO-10646-UCS-2 ?) 的转换.
- 小弟请教一个JDBC基础性的傻瓜问题,送分!
- JDBC问题,半路出错 晕
- 请问有使用过substance L&F么? 在其中使用JFileChooer出错
- sql server &&java(谢谢)
- 路过的大侠都来帮忙看看,java加密算法调用
- 头痛!关于apache1.3 + Tomcat4.1.12的配置问题
- DISPOSE_ON_CLOSE 与 HIDE_ON_CLOSE的区别
- 请大家帮忙看一下!
把你的编译出来的A类路径也加到classpath里去
然后到projsp3的上一层目录
javac projsp3\*.java