Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fb alphorn #73

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ public String getColor() {
public int getSoundVolume() {
return 3;
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@

package ch.heigvd.res.lab00;


/**
* Created by Olivier Liechti on 28/02/18.
*/
public interface IInstrument {
public String play();
public String getColor();
public int getSoundVolume();

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package ch.heigvd.res.lab00;

package ch.heigvd.res.lab00;

/**
* Created by Olivier Liechti on 28/02/18.
Expand All @@ -17,6 +17,7 @@ public String getColor() {

@Override
public int getSoundVolume() {
return 8;
return 12 ;
}

}
Original file line number Diff line number Diff line change
@@ -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);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void aTrumpetShouldMakePouet() {
String sound = trumpet.play();
Assert.assertEquals("pouet", sound);
}

@Test
public void aTrumpetShouldBeLouderThanAFlute() {
IInstrument trumpet = new Trumpet();
Expand All @@ -50,5 +50,5 @@ public void aTrumpetShouldBeGolden() {
String color = trumpet.getColor();
Assert.assertEquals("golden", color);
}

}
1 change: 1 addition & 0 deletions Lab00App-build/Lab00App-tests/test-results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"ignoreCount":0,"failures":[],"runTime":109,"failureCount":0,"runCount":19}