diff --git a/Lab00App-build/Lab00App-code/src/main/java/ch/heigvd/res/lab00/Alphorn.java b/Lab00App-build/Lab00App-code/src/main/java/ch/heigvd/res/lab00/Alphorn.java new file mode 100644 index 0000000..f197f7f --- /dev/null +++ b/Lab00App-build/Lab00App-code/src/main/java/ch/heigvd/res/lab00/Alphorn.java @@ -0,0 +1,29 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ch.heigvd.res.lab00; + +/** + *this class represent the new instrument + * @author zacharie + */ +public class Alphorn implements IInstrument{ + +public Alphorn(){} + + @Override + public String play(){ + return "bum-bum"; + } + @Override + public int getSoundVolume(){ + return 9; + } + @Override + public String getColor(){ + return "green"; + } + +} diff --git a/Lab00App-build/Lab00App-code/src/main/java/ch/heigvd/res/lab00/Flute.java b/Lab00App-build/Lab00App-code/src/main/java/ch/heigvd/res/lab00/Flute.java index ea38934..5ec1cfd 100644 --- a/Lab00App-build/Lab00App-code/src/main/java/ch/heigvd/res/lab00/Flute.java +++ b/Lab00App-build/Lab00App-code/src/main/java/ch/heigvd/res/lab00/Flute.java @@ -18,4 +18,5 @@ public String getColor() { public int getSoundVolume() { return 3; } + } diff --git a/Lab00App-build/Lab00App-code/src/main/java/ch/heigvd/res/lab00/IInstrument.java b/Lab00App-build/Lab00App-code/src/main/java/ch/heigvd/res/lab00/IInstrument.java index ee13a1b..eafeb01 100644 --- a/Lab00App-build/Lab00App-code/src/main/java/ch/heigvd/res/lab00/IInstrument.java +++ b/Lab00App-build/Lab00App-code/src/main/java/ch/heigvd/res/lab00/IInstrument.java @@ -1,5 +1,7 @@ + package ch.heigvd.res.lab00; + /** * Created by Olivier Liechti on 28/02/18. */ @@ -7,4 +9,5 @@ public interface IInstrument { public String play(); public String getColor(); public int getSoundVolume(); + } diff --git a/Lab00App-build/Lab00App-code/src/main/java/ch/heigvd/res/lab00/Trumpet.java b/Lab00App-build/Lab00App-code/src/main/java/ch/heigvd/res/lab00/Trumpet.java index 25819dc..5ed92d0 100644 --- a/Lab00App-build/Lab00App-code/src/main/java/ch/heigvd/res/lab00/Trumpet.java +++ b/Lab00App-build/Lab00App-code/src/main/java/ch/heigvd/res/lab00/Trumpet.java @@ -1,5 +1,5 @@ -package ch.heigvd.res.lab00; +package ch.heigvd.res.lab00; /** * Created by Olivier Liechti on 28/02/18. @@ -17,6 +17,7 @@ public String getColor() { @Override public int getSoundVolume() { - return 8; + return 12 ; } + } diff --git a/Lab00App-build/Lab00App-tests/src/test/java/ch/heigvd/res/lab00/AlphornTest.java b/Lab00App-build/Lab00App-tests/src/test/java/ch/heigvd/res/lab00/AlphornTest.java new file mode 100644 index 0000000..0926b50 --- /dev/null +++ b/Lab00App-build/Lab00App-tests/src/test/java/ch/heigvd/res/lab00/AlphornTest.java @@ -0,0 +1,54 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ch.heigvd.res.lab00; + +import org.junit.Assert; +import static org.junit.Assert.assertNotNull; +import org.junit.Test; + +/** + *this class should test the Alphorn instrument + * @author zacharie + */ +public class AlphornTest { + @Test + public void thereShouldBeAnIInstrumentInterfaceAndAAlphornClass() { + IInstrument alphorn = new Alphorn(); + assertNotNull(alphorn); + } + + @Test + public void itShouldBePossibleToPlayAnInstrument() { + IInstrument alphorn = new Alphorn(); + String sound = alphorn.play(); + assertNotNull(sound); + } + + @Test + public void anAlphornShouldMakebumbum() { + IInstrument alphorn = new Alphorn(); + String sound = alphorn.play(); + Assert.assertEquals("bum-bum", sound); + } + + @Test + public void anAlphornShouldNotBeLouderThanATrumpet() { + IInstrument alphorn = new Alphorn(); + IInstrument trumpet = new Trumpet(); + int alphornVolume = alphorn.getSoundVolume(); + int trumpetVolume = trumpet.getSoundVolume(); + Assert.assertTrue(alphornVolume < trumpetVolume); + } + + @Test + public void anAlphornShouldBeGreen() { + IInstrument alphorn = new Alphorn(); + String color = alphorn.getColor(); + Assert.assertEquals("green", color); + } + + +} diff --git a/Lab00App-build/Lab00App-tests/src/test/java/ch/heigvd/res/lab00/TrumpetTest.java b/Lab00App-build/Lab00App-tests/src/test/java/ch/heigvd/res/lab00/TrumpetTest.java index 1e408a9..9e081a9 100644 --- a/Lab00App-build/Lab00App-tests/src/test/java/ch/heigvd/res/lab00/TrumpetTest.java +++ b/Lab00App-build/Lab00App-tests/src/test/java/ch/heigvd/res/lab00/TrumpetTest.java @@ -34,7 +34,7 @@ public void aTrumpetShouldMakePouet() { String sound = trumpet.play(); Assert.assertEquals("pouet", sound); } - + @Test public void aTrumpetShouldBeLouderThanAFlute() { IInstrument trumpet = new Trumpet(); @@ -50,5 +50,5 @@ public void aTrumpetShouldBeGolden() { String color = trumpet.getColor(); Assert.assertEquals("golden", color); } - + } diff --git a/Lab00App-build/Lab00App-tests/test-results.json b/Lab00App-build/Lab00App-tests/test-results.json new file mode 100644 index 0000000..2780dbb --- /dev/null +++ b/Lab00App-build/Lab00App-tests/test-results.json @@ -0,0 +1 @@ +{"ignoreCount":0,"failures":[],"runTime":109,"failureCount":0,"runCount":19} \ No newline at end of file