Mehmet Ethem SULAN :: Test Güdümlü Yazılım(Test Driven Development) :: Çevik Süreç (Agile Process) İle Javada Test Güdümlü Proje Geliştirme(A Robot Battle Simulation Program Java Example)

ROBOWAR – A robot battle simulation program

Introduction

You have a one dimensional world of 20 meter long. You have 2 robots armed

with missiles fighting each other. Your mission if you accept it is to write a

program simulating the battle between these two robots until the death of one of the robot.

Robot

A robot is characterized by 5 parameters: attack, shield, speed, location and energy.

· Attack (A): represent the explosive power of the missile.

· Defense (D): represent the strength of the shield

· Speed (S): represents the maximum number of meter the robot can move at once.

· Energy(E): self-explanatory

· Location (L): position of the robot on the axis

Assumptions

· At the beginning of the battle one robot starts at L=0 the other at L=19.

· The battle is round-base: both robots make a move and then the outcome of their move is computed

· A missile always hit its target

· A move is either an attack or a movement within the world

· A robot cannot “jump” over each other and they cannot occupy the same space

· A robot dies when its Energy reaches 0 or less.

· Every robot has finite set amount of energy: 100 units.

· Ten units of ability points can be distributed between attack, defense and speed abilities.

For example: a robot defined by (A=8,D=1,S=1 is strong in attack, but is slow and has weak defense.

· Each move consumes an amount of energy calculated by: (DISTANCE/S)*5

· Each missile hit creates a damage which reduces the energy of a robot

· The damage is calculated by:

DAMAGE(R2) = ( RANDOM(BETWEEN 1 AND 10) * A(R1) / DISTANCE ) – (D(R2) * (DISTANCE / 10))

o Damage cannot be a negative value. Assume 0 if a negative value occurs.
test

//www.ethemsulan.com
package TestPaketi;
import junit.framework.Test;
import junit.framework.TestSuite;
public class AllTests {
public static Test suite() {
TestSuite suite = new TestSuite("Test for TestPaketi");
	//$JUnit-BEGIN$
	suite.addTestSuite(TestRobot2.class);
	suite.addTestSuite(TestRobot1.class);
	suite.addTestSuite(TestEngine.class);
	//$JUnit-END$
	return suite;
	}
}

Robot sınıf orj kod:http://www.ethemsulan.pastebin.com/HiG9cmxA

http://www.ethemsulan.pastebin.com/6z5aP6vz

http://www.ethemsulan.pastebin.com/JFU6tr9R

http://www.ethemsulan.pastebin.com/cUxDfUcR

Engine sınıflar:http://www.ethemsulan.pastebin.com/qeKvD8bJ

http://www.ethemsulan.pastebin.com/yyDhf2ew

Test sınıflar:http://www.ethemsulan.pastebin.com/Xm1wuGK3

http://www.ethemsulan.pastebin.com/dRGJ72BH

http://www.ethemsulan.pastebin.com/fzDdJ43t

http://www.ethemsulan.pastebin.com/hZXhbWHV

TDD ile yazılan robot uygulama kodlarını dropboxdan indirmek için tıklayın(boyut (Boyut 17.6 KB dir)