Commit 475c3845 authored by cailliaud's avatar cailliaud

[Init] Création dépôt code des live coding Ippon

parents
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.ippon.live-coding</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>
<groupId>fr.ippon.kata</groupId>
<artifactId>romanNumber</artifactId>
<name>Roman Numerals Kata</name>
<developers>
<developer>
<email>cdamon@ippon.tech</email>
<name>Colin DAMON</name>
</developer>
<developer>
<email></email>
<name>Julie </name>
</developer>
</developers>
<dependencies>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package fr.ippon.kata.roman;
import java.util.NavigableMap;
import java.util.TreeMap;
public class Numerals {
private static final NavigableMap<Integer, Roman> CONVERSIONS = buildConversions();
public static String toRoman(int arabic) {
// TODO : Use Stream.iterable to avoid stackoverflow on recursion
if (arabic <= 0) {
return "";
}
Integer highestKnownConversion = CONVERSIONS.floorKey(arabic);
String highestKnownRepresentation = CONVERSIONS
.get(highestKnownConversion)
.getRepresentation();
return highestKnownRepresentation + toRoman(arabic - highestKnownConversion);
}
private static NavigableMap<Integer, Roman> buildConversions() {
NavigableMap<Integer, Roman> conversions = new TreeMap<>();
conversions.put(1, Roman.ONE);
conversions.put(4, Roman.FOUR);
conversions.put(5, Roman.FIVE);
conversions.put(9, Roman.NINE);
conversions.put(10, Roman.TEN);
return conversions;
}
}
package fr.ippon.kata.roman;
import java.util.NavigableMap;
public enum Roman {
ONE("I"),
FOUR("IV"),
FIVE("V"),
NINE("IX"),
TEN("X");
private String representation;
private Roman(String representation) {
this.representation = representation;
}
public String getRepresentation() {
return this.representation;
}
}
package fr.ippon.kata.roman;
import org.junit.jupiter.api.Test;
import static fr.ippon.kata.roman.Numerals.toRoman;
import static org.assertj.core.api.Assertions.*;
class NumeralsTest {
@Test
void shouldConvertZeroToEmptyString() {
assertThat(toRoman(0)).isEmpty();
}
@Test
void shouldConvertOneToI() {
assertThat(toRoman(1)).isEqualTo("I");
}
@Test
void shouldConvertThreeToIII() {
assertThat(toRoman(3)).isEqualTo("III");
}
@Test
void shouldConvertFourToIV() {
assertThat(toRoman(4)).isEqualTo("IV");
}
@Test
void shouldConvertFiveToV() {
assertThat(toRoman(5)).isEqualTo("V");
}
@Test
void shouldConvertSixToVI() {
assertThat(toRoman(6)).isEqualTo("VI");
}
@Test
void shouldConvertNineToIX() {
assertThat(toRoman(9)).isEqualTo("IX");
}
@Test
void shouldConvertTenToTen() {
assertThat(toRoman(10)).isEqualTo("X");
}
@Test
void shouldConvertFourteenToXIV() {
assertThat(toRoman(14)).isEqualTo("XIV");
}
}
\ No newline at end of file
<p align="center">
<a href="https://fr.ippon.tech/" target="_blank">
<img alt="Ippon Technologies Logo" width="100" src="https://fr.ippon.tech/assets/images/common/Logo.svg">
</a>
</p>
Ippon Live Coding
=================
Description
-----------------
Ce dépôt Git a pour but de partagerr les différents ateliers pouvant être réalisés durant les sessions live conding d'Ippon Technologies sur sa chaîne Twitch.
La chaîne Twitch : https://www.twitch.tv/ippontech
Si vous souhaitez vous tenir au courant des différents lives à venir, n'hésitez pas à nous suivre sur les réseaux :
*
Kata
-----------------
* **Wrapper** : Proposé par Colin DAMON le 09/07/2020
* lien: [Lancement de la chaîne](https://www.twitch.tv/videos/674458223)
* **Romans Number**: Proposé par Colin DAMON et Julie le 15/07/2020
* lien: [Roman Numerals avec Julie et Colin](https://www.twitch.tv/videos/680494502)
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.ippon.live-coding</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>
<groupId>fr.ippon.kata</groupId>
<artifactId>wrapper</artifactId>
<name>Wrapper Kata</name>
<developers>
<developer>
<email>cdamon@ippon.tech</email>
<name>Colin DAMON</name>
</developer>
</developers>
<dependencies>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package fr.ippon.kata.wrapper;
public class Wrapper {
private static final String BREAK = "\n";
private int columns;
private Wrapper(int columns) {
this.columns = columns;
}
public static String wrap(String sentence, int columns) {
return new Wrapper(columns).wrap(sentence);
}
private String wrap(String sentence) {
if (isShortEnough(sentence)) {
return sentence;
}
String left = sentence.substring(0, columns);
String right = sentence.substring(columns);
if (right.startsWith(" ")) {
return join(left, right.substring(1, right.length()));
}
if (left.contains(" ")) {
int spaceIndex = left.lastIndexOf(" ");
return join(sentence.substring(0, spaceIndex),
sentence.substring(spaceIndex + 1));
}
return join(left, right);
}
private boolean isShortEnough(String sentence){
return sentence == null || sentence.length() <= columns;
}
private String join(String left, String right){
return left + BREAK + wrap(right,columns);
}
}
package wrapper;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.stream.Collectors;
import static fr.ippon.kata.wrapper.Wrapper.wrap;
import static org.assertj.core.api.Assertions.*;
class WrapperTest {
@Test
void shouldNotWrapWithoutSentence(){
assertThat(wrap(null,4)).isNull();
}
@Test
void shouldNotWrapShortEnoughSentence(){
assertThat(wrap("Once",4)).isEqualTo("Once");
}
@Test
void shouldWrapBySplittingWord(){
assertThat(wrap("Once",2)).isEqualTo("On\nce");
}
@Test
void shouldWrapBySplittingWordMultipleItems(){
assertThat(wrap("Once",1))
.isEqualTo(join("O","n","c","e"));
}
@Test
void shouldWrapAfterWord(){
assertThat(wrap("Once uppon a time",10))
.isEqualTo(join("Once uppon","a time"));
}
private static String join (String... parts){
return Arrays.stream(parts)
.collect(Collectors.joining("\n"));
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.ippon.live-coding</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Ippon Live Coding Parent</name>
<description>Ippon Technologies propose des sessions live sur twitch.</description>
<packaging>pom</packaging>
<url>https://www.twitch.tv/ippontech</url>
<organization>
<name>Ippon Technologies</name>
<url>http://www.ippon.fr</url>
</organization>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
<modules>
<module>kata/wrapper</module>
<module>kata/romanNumber</module>
</modules>
<properties>
<java.version>14</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.surefire.version>2.22.2</maven.surefire.version>
<maven.failsafe.version>2.22.2</maven.failsafe.version>
<junit.jupiter.version>5.6.2</junit.jupiter.version>
<mockito.version>3.4.0</mockito.version>
<assertj.version>3.11.1</assertj.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven.failsafe.version}</version>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment