cannot invoke setCennik(String,double)

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

    cannot invoke setCennik(String,double)

    Code:
    public class Cennik {
    	 private static Cennik instance = null;
    	 Map<String,Double> cennik = new HashMap<String,Double> ();
    
    	   private Cennik() {  // prywatny konstruktor
    	   }
    
    	   public static Cennik getInstance() {
    	      if(instance == null) {
    	         instance = new Cennik();
    	         
    	      }
    	      return instance;
    	   }
    	   
    public void setCennik(String nazwaKwiat,double cena){	   
    	cennik.put(nazwaKwiat,cena);   
    }
    
    public  Map<String,Double> getCennik(){ return cennik;}
    }
    
    
    
    
    public class Kwiaciarnia {
      Cennik c= Cennik.getInstance();
      
      public Kwiaciarnia(){
      c.setCennik("Roza Czerwona",5.0);
      c.setCennik("Roza Biala",5.0);
      c.setCennik("Roza Zolta",5.0);
      c.setCennik("Roza Czarna",10.0);
      c.setCennik("Tulipan Zolty",3.50);
      c.setCennik("Tulipan Czerwony",3.50);
      c.setCennik("Tulipan Bialy",3.50);
      c.setCennik("Lilia Biala",7.50);
      c.setCennik("Lilia Zolta",7.50);
      c.setCennik("Lilia Rozowa",7.50);
      }
     
    private static void dodajKwiat(String n,double c){
    	
    	c.setCennik(n,c);
    	
    	}  
    }

    eclipse says that i have an error in c.setCennik(n,c ); it says cannot invoke setCennik(Strin g,double) on the primitive type double
    why? and what shd i change in the code?
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Did you tell Eclipse to use the version 5 or version 6 compliant compiler?

    You can find it at Project>Propert ies>Java Compiler

    kind regards,

    Jos

    Comment

    • oll3i
      Contributor
      • Mar 2007
      • 679

      #3
      i set it to 5

      Comment

      • oll3i
        Contributor
        • Mar 2007
        • 679

        #4
        they want us to use 5.0

        Comment

        • oll3i
          Contributor
          • Mar 2007
          • 679

          #5
          but switching between 6 and 5 doesnt change a thing

          Comment

          • sicarie
            Recognized Expert Specialist
            • Nov 2006
            • 4677

            #6
            Ok, I'm still on quite a bit of NyQuil, so I'm probably missing something here, but I'm just going to ask where are String nazwaKwiat, and double cena declared in the class?

            Also, you're declaring this as a Singleton. One instance. Yet you want to set it with six or seven different values? Might you want a CennikList() Singleton class more than a Cennik() Singleton class?

            Comment

            Working...