Advertisement
absorr

Lesson 47

Feb 12th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | None | 0 0
  1. //QUESTION 1
  2. Map obj = new HashMap();
  3. obj.put("Sally", "blue");
  4.  
  5. //QUESTION 2
  6. // HashMap and TreeMap
  7.  
  8. //QUESTION 3
  9. Iterator itr = mp.keySet().iterator();
  10.  
  11. //QUESTION 4
  12. Map hoover = new HashMap();
  13.  
  14. //QUESTION 5
  15. // Maps have two values associated with each other (a key and its value).
  16.  
  17. //QUESTION 6
  18. // If the key exists, the value is overridden.
  19.  
  20. //QUESTION 7
  21. // No because keys are not allowed to repeat.
  22.  
  23. //QUESTION 8
  24. // You would do so using the .size() command.
  25.  
  26. //QUESTION 9
  27. System.out.println(tiny.get(obj));
  28.  
  29.  
  30. /*
  31.  *  PART B
  32. */
  33.  
  34. public boolean setToolLocation(String position, int drillSize)
  35. {
  36.     Object obj = toolLocationMap.get(position);
  37.     if (obj != null)
  38.     {
  39.         toolLocationMap.put(position, drillSize);
  40.         return true;
  41.     }
  42.     else
  43.         return false;
  44. }
  45.  
  46. public void deleteToolLocation(String position)
  47. {
  48.     toolLocationMap.remove(position);
  49. }
  50.  
  51. public int getToolRpm(String position)
  52. {
  53.     Integer size = (Integer) toolLocationMap.get(position);
  54.     if (int != null)
  55.     {
  56.         DrillInfo info = (DrillInfo) drillInfoMap(size);
  57.         if (info != null)
  58.             return info.rpm;
  59.         else
  60.             return -1;
  61.     }
  62.     else
  63.         return -1;
  64. }
  65.  
  66. public String getPosition(int toolSize)
  67. {
  68.     Iterator itr = toolLocationMap.keySet().iterator();
  69.     while (itr.hasNext())
  70.     {
  71.         String key = (String) iter.next();
  72.         Integer val = toolLocationMap.get(key);
  73.         if (Integer.compare(val, toolSize) == 0)
  74.             return key;
  75.     }
  76.     return "X";
  77. }
  78.  
  79. public double getFeedRate(int drillSize)
  80. {
  81.  
  82.     DrillInfo info = (DrillInfo) drillInfoMap(new Integer(drillSize));
  83.     if (info != null)
  84.         return info.feedRate;
  85.     else
  86.         return -1;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement