Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //QUESTION 1
- Map obj = new HashMap();
- obj.put("Sally", "blue");
- //QUESTION 2
- // HashMap and TreeMap
- //QUESTION 3
- Iterator itr = mp.keySet().iterator();
- //QUESTION 4
- Map hoover = new HashMap();
- //QUESTION 5
- // Maps have two values associated with each other (a key and its value).
- //QUESTION 6
- // If the key exists, the value is overridden.
- //QUESTION 7
- // No because keys are not allowed to repeat.
- //QUESTION 8
- // You would do so using the .size() command.
- //QUESTION 9
- System.out.println(tiny.get(obj));
- /*
- * PART B
- */
- public boolean setToolLocation(String position, int drillSize)
- {
- Object obj = toolLocationMap.get(position);
- if (obj != null)
- {
- toolLocationMap.put(position, drillSize);
- return true;
- }
- else
- return false;
- }
- public void deleteToolLocation(String position)
- {
- toolLocationMap.remove(position);
- }
- public int getToolRpm(String position)
- {
- Integer size = (Integer) toolLocationMap.get(position);
- if (int != null)
- {
- DrillInfo info = (DrillInfo) drillInfoMap(size);
- if (info != null)
- return info.rpm;
- else
- return -1;
- }
- else
- return -1;
- }
- public String getPosition(int toolSize)
- {
- Iterator itr = toolLocationMap.keySet().iterator();
- while (itr.hasNext())
- {
- String key = (String) iter.next();
- Integer val = toolLocationMap.get(key);
- if (Integer.compare(val, toolSize) == 0)
- return key;
- }
- return "X";
- }
- public double getFeedRate(int drillSize)
- {
- DrillInfo info = (DrillInfo) drillInfoMap(new Integer(drillSize));
- if (info != null)
- return info.feedRate;
- else
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement