项目作者: xapn

项目描述 :
A coding kata named Diamond
高级语言: Java
项目地址: git://github.com/xapn/diamond.git
创建时间: 2018-08-14T13:48:19Z
项目社区:https://github.com/xapn/diamond

开源协议:GNU General Public License v3.0

下载


Diamond

A letter for a diamond!

LoC Files Total lines Comments Blank lines

TestAsYouThink badge

Kata instructions

Given a single letter, print a diamond starting with ‘A’ with the supplied letter at the widest point. This kata like many others is intended to be solved by applying Test-Driven Development (TDD).

Example for ‘A’:

  1. A
Example for 'B':
  1. A
  2. B B
  3. A
Example for 'C':
  1. A
  2. B B
  3. C C
  4. B B
  5. A

Get started

Use my Diamond program in command line as following.

  1. mvn clean package -Pstandalone # to build it once
  2. java -jar target/diamond-kata-0.1.0-SNAPSHOT-shaded.jar F # to run it as many times as you want

You will get this result.

  1. A
  2. B B
  3. C C
  4. D D
  5. E E
  6. F F
  7. E E
  8. D D
  9. C C
  10. B B
  11. A
My Diamond program works for uppercase letters as for lowercase letters. For example, the diamond printed for 'c':
  1. a
  2. b b
  3. c c
  4. b b
  5. a

Also use it as a Java library with Maven.

  1. <dependency>
  2. <groupId>com.github.xapn</groupId>
  3. <artifactId>diamond-kata</artifactId>
  4. <version>0.1.0-SNAPSHOT</version>
  5. </dependency>

And get any diamond you want like that.

  1. import diamond.Diamond;
  2. class Example {
  3. public static void main(String[] args) {
  4. String diamond = Diamond.of("X");
  5. }
  6. }

License

The Diamond program is distributed under the GNU GPLv3 license. The GPLv3 license is included in the LICENSE.txt file. More information about this license is available at GNU.org.