Saturday, September 10, 2016

JAVA 21 - Get coding!

So that's it!  We've gone through a lot of theory and examples together.

Next steps?  Well maybe Alan Richardson's book on Java For Testers is a good start  if you've not picked it up already.  But above all else, get coding, get practicing, get learning.

The following are a set of ideas for you to try out as revision for what we've covered so far.  Try not to go back to my code, but do use the internet to look up functions - most programmers do!

Revision exercises


  1. Create a HelloWorld program
  2. Create a HelloWorld program, where "Hello World"is declared as a string printMe, and passed to be printed.
  3. Create a HelloWorld program. Declare "Hello"as string Str1, and "World" as string Str2.  How do you put them together into string printMe to be published?
  4. Create a method printHelloWorld, which does just that.
  5. Use a loop to call printHelloWorld 10 times.
  6. Create a functon called printGutenTag, which prints "Guten Tag".  Create a loop which prints "Hello World" on odd numbers, and "Guten Tag" on even numbers, using if statements.
  7. Create a class called Card which has two attributes "suite" and "value".  Create a method for setting these values, and for getting the value of the card.
  8. Create a class called CardDeck, which contains 52 cards.  Create a method to draw a card at random.
  9. Look up Conways Game Of Life.  Create a class for a cell, and a series of JUnit tests for it.
  10. Look at our recent examples of Game Of Life, Character Creation or Account User.  Add some more JUnit tests which include assertions.


Building on character creation

The customer wants the following addition to our character creation code.


[REQ_1]  Add a combat system onto our Character Creation.  Characters must first hit with their weapon, then wound.
[REQ_2]  To hit - characters must roll equal or under their fighting attribute if doing hand-to-hand or shooting if done with a ranged attack.  This roll is done on a D20 (20 sided dice, with 20 always high).
[REQ_3]  If the character has the skill martial arts for hand-to-hand or archery for ranged attacks, they get to reroll a failed miss if it occurs (but the next result stands as is).
[REQ_4]  If they roll a 1 to hit, it's an automatic wound (skip the to wound roll)
[REQ_5]  To wound - if the character rolls equal or under their strength, they cause the loss of 1 health from their opponent.
[REQ_6]  If they roll a 1, then they cause the loss of D6 health in a critical hit.

Add code to support the above, including any JUnit tests needed.


Building on Account User

Revisit our account user code.

[REQ_7]  It's been decided, users will now user have their username created for them.  Use the method from unique username to create their username automatically on creation.
[REQ_8]  Sometimes there's just too many audits to read through.  Create a method to print out only audits which contain a certain action/phrase and test it.


Add code to support the above, including any JUnit tests needed.

No comments:

Post a Comment