Skip to content

Commit

Permalink
Fixed Code
Browse files Browse the repository at this point in the history
  • Loading branch information
Parry-Howells committed Nov 14, 2019
1 parent 36d7961 commit dfcd54b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.capgemini.tdd.demo.models.Greeting;

import com.capgemini.tdd.demo.models.TalkyNumber;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -19,4 +20,12 @@ public Greeting greeting(@RequestParam(value="name", defaultValue="World") Strin
return new Greeting(counter.incrementAndGet(),
String.format(template, name));
}


@RequestMapping("/talkynumbers")
public TalkyNumber talkynumbers(@RequestParam(value = "number", defaultValue = "1") String number) {
return new TalkyNumber(counter.incrementAndGet(),
Integer.parseInt(number));
}
}

24 changes: 24 additions & 0 deletions src/main/java/com/capgemini/tdd/demo/models/TalkyNumber.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.capgemini.tdd.demo.models;

import com.capgemini.tdd.demo.services.NumberService;

public class TalkyNumber {
private final long id;
private final int number;
private NumberService talkynumbers = new NumberService();

public TalkyNumber(long id, int number) {
this.id = id;
this.number= number;
}

public long getId() {
return id;
}

public String getNumber() {
return talkynumbers.convert(number);
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public String convert(int num){
if(num >= 100){
output += ", ";
}
else{
else if (num > 0) {
output += " and ";
}

Expand Down

0 comments on commit dfcd54b

Please sign in to comment.