好的,所以我在下面有这段代码,并且我不断收到运行时错误,我认为这是代码逻辑中的一个缺陷。我正在尝试使用该setOneOtherPicture
方法来选择一张图片并将其设置为一个数组,以便稍后调用以在该showArtCollection
方法中显示。我得到了两个参数,which
并且pRef
. 有人可以帮我弄这个吗?谢谢。
public class House
{
String owner;
Picture pRef;
Picture favPic;
Picture [] picArray = new Picture [3];
public void showArtCollection ()
{
ArtWall aWall = new ArtWall(600,600);
aWall.copyPictureIntoWhere(favPic,250,100);
aWall.copyPictureIntoWhere(pRef,51,330);
aWall.copyPictureIntoWhere(pRef,151,330);
aWall.copyPictureIntoWhere(pRef,351,280);
aWall.show();
}
public void setOneOtherPicture (int which, Picture pRef)
{
this.picArray [which] = new Picture (FileChooser.pickAFile ());
}
public static void main (String [] args)
{
House PhDsHouse = new House ("Mad PH.D.");
Picture favPic = new Picture ();
Picture pRef = new Picture ();
PhDsHouse.setOneOtherPicture (0, pRef);
PhDsHouse.setOneOtherPicture (1, pRef);
PhDsHouse.setOneOtherPicture (2,pRef);
PhDsHouse.showArtCollection ();
}