This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Developer Career Masterplan: Build your path to senior level and beyond with practical insights from industry experts and have Heather VanCura and Bruno Souza on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

Sorting objects by type, is that okay?

 
Ranch Hand
Posts: 103
Netbeans IDE Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I have android java game, where I have to deal with many different types of objects and their coordinates (player needs to place object in destination X/Y) But to make it less annoying for player I wanted to let him place object in any possible position (if there is more than one object of same type) I made this logic test code to sort objects by type, and than "send" all possible coordinates to each object:




My question is, I am not sure if its done right, and maybe there is anything I can do it better? Thank you.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mathew Mintalm wrote:My question is, I am not sure if its done right, and maybe there is anything I can do it better? Thank you.


Well, the main thing that leaps out at me is that you don't have a Coordinate class. If you did, you could make it Comparable, which would allow you to sort them - and so by extension any object that includes them - with Collections.sort().

Winston
 
reply
    Bookmark Topic Watch Topic
  • New Topic