[Implementation] Elefant Hunt – Animals, Hunters

Image of the board game "Elefant Hunt"

Image of the board game "Elefant Hunt"

According to the description of Wikipedia (http://en.wikipedia.org/wiki/Tom_Wham), “Elefant Hunt” is a board game in which great White Hunters travel through deepest, darkest “Aferca” with the help of natives to capture as much live animals and ivory as they can to sell for profit.

It’s right: the main characters of this game are Animals and Hunters! Then, I decided to create two classes that represent Animal and Hunter.

But, wait a second… aren’t they similar? Both Animal and Hunter cards of the board game have level and name. So, why don’t I just make a class that represents the common part of both classes to do less work? It’s why I created Item class that has attributes of level and name. By inheriting the Item class, it was handy to create Animal and Hunter classes.

I will end this article with the UML diagrams. As stated, Hunter and Animal is sub-classes of Item. Check the source codes attached on the download section to see details.

Item UML

Attributes Behaviours
int level Item(int lvl, String newName)
String name int getLevel() // gets the level of hunter and animal
String getName() // gets the name of hunter and animal
String toString() // return String representation

Animal UML

Attributes Behaviours
boolean isPredator

//is a predator animal? or a friendly animal?

Animal (int lvl, String name, boolean predator)
boolean isPredator()
String toString() //return String representation

Hunter UML

Attributes Behaviours
boolean isMain

//is your main hunter? or other regular hunter?

Hunter(int lvl, String name, boolean isMain)
boolean isMain()
String toString() //  return String representation

Animal UML


Advertisements

About Wonjohn Choi
Hello, I am a software developer Wonjohn Choi. I live in Mississauga, Ontario, Canada and study at a school called St. Francis Xavier Secondary School. My core interests include Math, Computer Science, and Engineering. Thank you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: