Java logic in my code -
okay, have code below , keep getting run-time errors , i'm thinking flaw in codes logic. i'm trying use setoneotherpicture
method pick picture , set array later called on displayed in showartcollection
method. i've been given 2 parameters, which
, pref
. can me this? thanks.
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 (); }
this method:
public void setoneotherpicture (int which, picture pref) { this.picarray [which] = new picture (filechooser.pickafile ()); }
shouldn't calling filechooser, , shouldn't creating new picture object, instead should putting pref picture object have passed method array. otherwise you're throwing pref parameter away -- makes no sense.
Comments
Post a Comment