Skip to content

Commit 7a11b03

Browse files
committed
Add print line feature
1 parent 7e57492 commit 7a11b03

File tree

7 files changed

+40
-58
lines changed

7 files changed

+40
-58
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>edu.training</groupId>
7+
<groupId>edu.thoughtworks.training</groupId>
88
<artifactId>triangleexercise</artifactId>
99
<version>1.0-SNAPSHOT</version>
1010

1111
<name>triangleexercise</name>
1212

1313
<properties>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15-
<maven.compiler.source>1.7</maven.compiler.source>
16-
<maven.compiler.target>1.7</maven.compiler.target>
15+
<maven.compiler.source>1.8</maven.compiler.source>
16+
<maven.compiler.target>1.8</maven.compiler.target>
1717
</properties>
1818

1919
<dependencies>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package edu.thoughtworks.training;
2+
3+
public class Asterisk {
4+
5+
private static final String ASTERISK = "*";
6+
7+
public String print() {
8+
return ASTERISK;
9+
}
10+
11+
public String print(int n) {
12+
StringBuilder builder = new StringBuilder();
13+
for (int i=0; i<n; ++i) builder.append(print());
14+
return builder.toString();
15+
}
16+
}

src/main/java/edu/training/App.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/main/java/edu/training/Asterisk.java

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package edu.thoughtworks.training;
2+
3+
import org.junit.Test;
4+
5+
import static org.junit.Assert.assertEquals;
6+
7+
public class AsteriskShould {
8+
@Test
9+
public void printAnAsterisk() {
10+
Asterisk asterisk = new Asterisk();
11+
assertEquals("Asterisk is not returning an asterisk", "*", asterisk.print());
12+
}
13+
14+
@Test
15+
public void printANumberOfAsterisk() {
16+
Asterisk asterisk = new Asterisk();
17+
int n = 6;
18+
assertEquals("Asterisk prints less than two asterisks", "******", asterisk.print(n));
19+
}
20+
21+
}

src/test/java/edu/training/AppTest.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/test/java/edu/training/AsteriskShould.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)