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.

1 comment:

  1. Gambling games suitable for gamblers of all ages.

    G club The casino will provide casino gaming investors with a full gamble. Played very well Gambling is live from the real casino. Bring it to everyone to play it realistically. There are many investments. Make huge profits. Where is the best place to play gambling? New bets. Have fun at any time like. Gamblers to help players find the casino game is number one. Bet on Wherever You Are It is ready to play bets that anyone can play well.

    In addition, the gambler to enter the casino gambling games online at our website. In addition, the gambler will invest your favorite gambler. The gambler will also receive a lot of promotions that we have been held for investors to get here. Investors who are interested in subscribing to our website, then the gambler is able to invest in our online gambling services here, the player will not be disappointed in this game. The player will be able to play easily with our online casino games. The gambler will not be disappointed by the luck we have to open it for you. Gclub มือถือ

    ReplyDelete