You need to sign in to do that
Don't have an account?

I am write the below code but some errors came could you please rectify this one
public class TvremoteControll {
integer volume;
static final integer MAX_VOLUME=50;
public TvremoteControll(){
volume= v; // Error:Non-void method might not return a value or might have statement after a return statement.
}
public integer increaseVolume(integer amount){
volume t= amount;
for(volume > MAX_VOLUME){ //Error =expecting an equals sign, found '>'
volume = MAX_VOLUME;
}
return volume;
}
public integer decreaseVolume(integer amount){
volume t1=amount;
if(volume<0){
volume=0;
}
return volume;
}
public static String getMenuOptions(){
return 'audio settings _ vedio settings';
}
}
integer volume;
static final integer MAX_VOLUME=50;
public TvremoteControll(){
volume= v; // Error:Non-void method might not return a value or might have statement after a return statement.
}
public integer increaseVolume(integer amount){
volume t= amount;
for(volume > MAX_VOLUME){ //Error =expecting an equals sign, found '>'
volume = MAX_VOLUME;
}
return volume;
}
public integer decreaseVolume(integer amount){
volume t1=amount;
if(volume<0){
volume=0;
}
return volume;
}
public static String getMenuOptions(){
return 'audio settings _ vedio settings';
}
}
Please update your code as follows :
public class TvremoteControll {
Integer volume;
static final integer MAX_VOLUME=50;
public TvremoteControll(Integer v){
volume = v;
}
public Integer increaseVolume(Integer amount){
Integer increasedVolume = volume + amount;
if(increasedVolume > MAX_VOLUME){
return MAX_VOLUME;
}
else{
return increasedVolume;
}
}
public Integer decreaseVolume(Integer amount){
Integer decreasedVolume = volume - amount;
if(decreasedVolume < 0){
return volume;
}
else{
return decreasedVolume;
}
}
public static String getMenuOptions(){
return 'audio settings _ vedio settings';
}
}
If this code does not help you or does not meet your requiremnt than please share your requirement so that i can help you.
Thanks,
Abhishek
public TvremoteControll(){
volume= v; // Error:Non-void method might not return a value or might have statement after a return statement.
}
2) in this line volume t= amount;
change to volume = amount;
3) same in this line volume t1=amount;
volume =amount;
try to make the above changes........let me know if this works..
Regards,
Rahul
Please find the required test class;
private class TvremoteControllTest {
static testMethod void myUnitTest() {
TvremoteControll testRef = new TvremoteControllTest(10);
testRef.increaseVolume(15);
testRef.increaseVolume(100);
testRef.decreaseVolume(15);
testRef.decreaseVolume(1);
testRef.getMenuOptions();
}
}
Regards,
Abhishek.