I have this method which is supposed to check if a key is in a map and then increment a value.
papers.add(paper); //add a paper to the paper collection
papersOrdered.get(papers); //returns the papers
if(!(papersOrdered.containsKey(paper))) {
paperNo = 1;
String noPaper = Integer.toString(paperNo); //convert the paperNo integer to a String
papersOrdered.put(papers,noPaper); //put the rooNo and the paper collection into the HashMap
System.out.println("'" + paper + "'" + " has been added to the paper order. " + noPaper + " copy ordered" ); //a message to say a paper has been added
}
else{
paperNo = paperNo ++;
String noPaper = Integer.toString(paperNo); //convert the paperNo integer to a String
papersOrdered.put(papers,noPaper); //put the rooNo and the paper collection into the HashMap
System.out.println("'" + paper + "'" + " has been added to the paper order." + noPaper + " copies ordered" ); //a message to say a paper has been added
}
System.out.println("======================================================="); ; //a line to seperate text
System.out.println(" "); //a blank line
However it does not work and I do not know why?