java - Trouble passing an ArrayList of objects from one class to another -
i'm trying display 2 arraylists on jtextarea having troubles passing arraylist of objects 1 class another.
the part of code i'm having problems trying display info following code
private void jbuttondisplayactionperformed(java.awt.event.actionevent evt) { for(int i=0; i<bars.size(); i++) { jtextareadisplay.append(jtextareadisplay.gettext() + bars.get(i).tostring() + bars.get(i).getliquor.tostring() + "\n\n"); } }
it says can't find symbol: variable getliquor bar class.
bar class code i'm trying pass it:
arraylist<liquor> liquors; private liquor liquor = new liquor(liquors); public liquor getliquor() { return liquor; }
from other class liquor:
arraylist<liquor> liquors = new arraylist<>(); public liquor(arraylist<liquor> liquors) { this.liquors = liquors; this.vodka = getv(); this.whiskey = getw(); this.rum = getr(); this.gin = getg(); this.brandy = getb(); this.vcount = getvc(); this.wcount = getwc(); this.rcount = getrc(); this.gcount = getgc(); this.bcount = getbc(); }
the other contructor in liquor code (if relevant):
public liquor(string vodka, string whiskey, string rum, string gin, string brandy, int v, int w, int r, int g, int b) { this.vodka = vodka; this.whiskey = whiskey; this.rum = rum; this.gin = gin; this.brandy = brandy; this.vcount = v; this.wcount = w; this.rcount = r; this.gcount = g; this.bcount = b; }
update
from can see, changed little bit , @ least names of liquor show, stock number each isn't been read in, instead shows null. think problem lies here:
public liquor(arraylist<liquor> liquors) { this.vodka = "vodka"; this.whiskey = "whiskey"; this.rum = "rum"; this.gin = "gin"; this.brandy = "brandy"; this.vcount = getvc(); this.wcount = getwc(); this.rcount = getrc(); this.gcount = getgc(); this.bcount = getbc(); }
i don't think getters working correctly. or maybe arraylist?
output:
the kendall bar named: kink live music: true food service: false liquor in stock:
vodka: 0
whiskey: 0
rum: 0
gin: 0
brandy: 0
you're missing parentheses getliquor
method call:
bars.get(i).tostring() + bars.get(i).getliquor().tostring()
Comments
Post a Comment