473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

cannot invoke setCennik(String,double)

oll3i
679 512MB
Expand|Select|Wrap|Line Numbers
  1. public class Cennik {
  2.      private static Cennik instance = null;
  3.      Map<String,Double> cennik = new HashMap<String,Double> ();
  4.  
  5.        private Cennik() {  // prywatny konstruktor
  6.        }
  7.  
  8.        public static Cennik getInstance() {
  9.           if(instance == null) {
  10.              instance = new Cennik();
  11.  
  12.           }
  13.           return instance;
  14.        }
  15.  
  16. public void setCennik(String nazwaKwiat,double cena){       
  17.     cennik.put(nazwaKwiat,cena);   
  18. }
  19.  
  20. public  Map<String,Double> getCennik(){ return cennik;}
  21. }
  22.  
  23.  
  24.  
  25.  
  26. public class Kwiaciarnia {
  27.   Cennik c= Cennik.getInstance();
  28.  
  29.   public Kwiaciarnia(){
  30.   c.setCennik("Roza Czerwona",5.0);
  31.   c.setCennik("Roza Biala",5.0);
  32.   c.setCennik("Roza Zolta",5.0);
  33.   c.setCennik("Roza Czarna",10.0);
  34.   c.setCennik("Tulipan Zolty",3.50);
  35.   c.setCennik("Tulipan Czerwony",3.50);
  36.   c.setCennik("Tulipan Bialy",3.50);
  37.   c.setCennik("Lilia Biala",7.50);
  38.   c.setCennik("Lilia Zolta",7.50);
  39.   c.setCennik("Lilia Rozowa",7.50);
  40.   }
  41.  
  42. private static void dodajKwiat(String n,double c){
  43.  
  44.     c.setCennik(n,c);
  45.  
  46.     }  
  47. }
  48.  

eclipse says that i have an error in c.setCennik(n,c); it says cannot invoke setCennik(String,double) on the primitive type double
why? and what shd i change in the code?
Mar 30 '07 #1
5 2296
JosAH
11,448 Expert 8TB
Did you tell Eclipse to use the version 5 or version 6 compliant compiler?

You can find it at Project>Properties>Java Compiler

kind regards,

Jos
Mar 30 '07 #2
oll3i
679 512MB
i set it to 5
Mar 30 '07 #3
oll3i
679 512MB
they want us to use 5.0
Mar 30 '07 #4
oll3i
679 512MB
but switching between 6 and 5 doesnt change a thing
Mar 30 '07 #5
sicarie
4,677 Expert Mod 4TB
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?
Mar 30 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Gregory Hassett | last post by:
Hi, I have a web service called GetComputerNameAndDescription which I can call from the main thread of my app. If I call it from a separate thread, however, it hangs on the call to Invoke() -- but...
0
by: Pawan Narula via DotNetMonster.com | last post by:
hi all, i'm using VB.NET and trying to code for contact management in a tree. all my contacts r saved in a text file and my C dll reads them one by one and sends to VB callback in a sync mode...
1
by: Marc | last post by:
Hi! I'm working with a C# client that calls a php web service. I've created a wrapper to call the service using .NET wsdl tool (adding a web reference). The call to the server works fine, it...
18
by: Paul Roberts | last post by:
Hiya I have a string with about 300+ characters, how can i insert a line break or another character every 50 characters for the whole string? Paul Roberts
0
by: Sreedhar | last post by:
Hi, I am working on the Application which will use wse2.0 to get the data from the server and when I hosted in sharepoint which has wse3.0, I am getting the following error after some period of...
2
by: John Smith | last post by:
I'm writing webervice client using .Net 2.0. I have this class: public class MyWebService : SoapHttpClientProtocol { public XmlDocument validate(string url, XmlDocument xmlDocument) {...
4
by: John Smith | last post by:
How can I allow someone to cast my C# class into System.String? Is it possible in C#? In C++ I used "operator" keyword to mark C++ member function.
0
by: Dan | last post by:
Hi I have a dotnet application that communicates with a web service running locally on my machine. It connects fine and works ok when I run the application from the c: drive. Am having...
3
by: =?Utf-8?B?Sm9l?= | last post by:
I know that I have posted this question before, but it is still unresolved and I don't know where to turn to next. I have code that is creating a user (works fine), then sets the account flags...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.