Advertisement
Guest User

Untitled

a guest
Apr 25th, 2014
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. public class PointCalculate {
  2.  
  3. public HashMap<String, Float> calPoint;
  4. private static PointCalculate instance;
  5.  
  6. private PointCalculate(){
  7. calPoint = new HashMap<String, Float>();
  8. }
  9.  
  10. public static PointCalculate getInstance(){
  11. if(instance==null){
  12. instance = new PointCalculate();
  13. }
  14. return instance;
  15. }
  16.  
  17. public void calculatePoint(String uid ,float point){
  18.  
  19. Float ps = instance.calPoint.get(uid);
  20. if(ps==null) {
  21. ps = point;
  22. instance.calPoint.put(uid, ps);
  23. }
  24. else {
  25. ps = point+ps.floatValue();
  26. instance.calPoint.put(uid, ps);
  27. }
  28. }
  29. }
  30.  
  31. public class Exp {
  32.  
  33. public void setpoint(){
  34. PointCalculate obj = PointCalculate.getInstance();
  35. obj.calculatePoint(rowkey, point);//rowkey and point come from file.....
  36. }
  37. }
  38.  
  39. public static void main(String args[]) throws Exception {
  40. PointCalculate obj = PointCalculate.getInstance();
  41. SqlInsertPoint.givePoint(obj.calPoint);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement