Duel Masters game in Java
Posted
by
Arun Ramasubramanian
on Stack Overflow
See other posts from Stack Overflow
or by Arun Ramasubramanian
Published on 2013-10-24T03:46:11Z
Indexed on
2013/10/24
3:54 UTC
Read the original article
Hit count: 157
java
I was trying to make a Duel Masters card game in Java using BlueJ, and came up with a lot of ideas. However, I could not exactly figure out how to sort a deck on basis of the card names in the game. I have an array of Card objects(each has, as its instance variables: String name, int cost, int civ), and I want to sort them based on name. ie: if I have the cards "Pyrofighter Magnus", "Bazagazeal Dragon" and another "Pyrofighter Magnus" in the array, the cards should be sorted on basis of their names.
I know that I could use compareTo()
, but is there an easier method? Anyone? Remember, the method that sorts the cards should be a modifier.
© Stack Overflow or respective owner