Guest User

Untitled

a guest
Jan 17th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. public void removeBid(String name) {
  2.  
  3. for(int a = 0;a < bidIndex; a++) {
  4. if(bids[a].getUser().getName().equals(name)) {
  5. bids[a]=null;
  6. bidIndex--;
  7. break;
  8. }
  9.  
  10. }
  11. sortBids();
  12.  
  13.  
  14.  
  15. public void sortBids() {
  16. if(bidIndex > 1) {
  17. for(int a = 0; a < bidIndex -1; a++) {
  18.  
  19. for(int b = a + 1; b < bidIndex; b++) {
  20.  
  21. if(bids[a] == null || bids[a].getBid() < bids[b].getBid()) {
  22. Bid temp = bids[a];
  23. bids[a] = bids[b];
  24. bids[b] = temp;
  25. }
  26. }
  27.  
  28. String[] items = new String[] {"String1", "String2", "String3"};
  29. items[1] = null;
  30.  
  31. Map<String, Bid> bids = new HashMap<String, Bid>();
  32.  
  33. Bid bid1 = new Bid(/*...*/);
  34. Bid bid2 = new Bid(/*...*/);
  35.  
  36. // Add bids to the map
  37.  
  38. bids.put("Wow", bid1);
  39. bids.put("Boy", bid2);
  40.  
  41. // Get any of these objects
  42.  
  43. Bid retrievedBid = bids.get("Wow");
  44.  
  45. // Or remove them
  46.  
  47. bids.remove("Wow");
  48.  
  49. Bid[] bidsArray = new Bid[0];
  50. bidsArray = bids.values().toArray(bidsArray);
Add Comment
Please, Sign In to add comment