adding to a cart error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • oll3i
    Contributor
    • Mar 2007
    • 679

    adding to a cart error

    Code:
    public class KwiaciarniaMVC {
    
        public static void main(String[] args) {
            
        	KwiaciarniaModel     model      = new KwiaciarniaModel();
            KwiaciarniaView       view       = new KwiaciarniaView(model);
            KwiaciarniaController controller = new KwiaciarniaController(model, view);
            
            view.setVisible(true);
            
            Kwiaciarnia kwiaciarnia = new Kwiaciarnia();
            Wozek wozek = new Wozek();
        }
    }

    then in other class

    Code:
    if("Roza Czerwona".equals(wybrany_kwiat)){
        	
        	wozek.dodajDoWozka(new RozaCzerwona(),a);
        	
        	}
    why eclipse says that wozek cannot be resolved
    wozek means shoppingcart
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by oll3i
    Code:
    public class KwiaciarniaMVC {
    
        public static void main(String[] args) {
            
        	KwiaciarniaModel     model      = new KwiaciarniaModel();
            KwiaciarniaView       view       = new KwiaciarniaView(model);
            KwiaciarniaController controller = new KwiaciarniaController(model, view);
            
            view.setVisible(true);
            
            Kwiaciarnia kwiaciarnia = new Kwiaciarnia();
            Wozek wozek = new Wozek();
        }
    }
    then in other class

    Code:
    if("Roza Czerwona".equals(wybrany_kwiat)){
        	
        	wozek.dodajDoWozka(new RozaCzerwona(),a);
        	
        	}
    why eclipse says that wozek cannot be resolved
    wozek means shoppingcart
    The only Wozek I can see from your code is a variable 'wozek' defined in your
    main method and so it is a local variable. It certainly isn't visible outside of that
    main method and most certainly not in an entirely different class.

    Shouldn't you pass that Wozek to the other class object so it can use it?

    kind regards,

    Jos

    Comment

    Working...