请问怎么加入异常处理操作?interface Goods{ // 商品
public float getPrice() ;
public String getName() ;
}
class ShopCar{ // 购物车
private Goods goods[] ; // 保存商品
private int foot ;  
public ShopCar(int len){
if(len>0){
this.goods = new Goods[len] ;
}else{
this.goods = new Goods[1] ; // 至少保持一个大小
}
}
public void add(Goods goods){ // 向里面增加商品
if(this.foot<this.goods.length){
this.goods[this.foot++] = goods ; // 添加商品
}
}
public float check(){
float count = 0.0f ;
for(int x=0;x<this.goods.length;x++){
if(this.goods[x]!=null){
count += this.goods[x].getPrice() ;
}
}
return count ;
}
public Goods[] getGoods(){
return this.goods ;
}
}
class Book implements Goods{
private float price ;
private String name ;
public Book(float price,String name){
this.name = name ;
this.price = price ;
}
public void setName(String name){
this.name = name ;
}
public void setPrice(float price){
this.price = price ;
}
public String getName(){
return this.name ;
}
public float getPrice(){
return this.price ;
}
}
public class ExecDemo06{
public static void main(String args[]){
ShopCar sc = new ShopCar(5) ;
sc.add(new Book(79.8f,"Java开发")) ;
sc.add(new Book(89.8f,"Java WEB 开发")) ;
sc.add(new Book(99.8f,"Oracle 开发")) ;
sc.add(new Book(39.8f,"HTML和网页制作")) ;
for(int x=0;x<sc.getGoods().length;x++){
if(sc.getGoods()[x]!=null){
System.out.println(sc.getGoods()[x].getName() + " --> " + sc.getGoods()[x].getPrice()) ;
}
}
System.out.println("结帐:" + sc.check()) ;
}
}