- do not name variables with captial letter first. Those are limited to class names. Instead, place an "i" in front for int values:
iString
,
iBrass
.
- If you can (is this homework?) male the Object "section" into an
enum
.
Much safer to work with
Enum
than
Strings
.
Your Problem:
iStrings--;
iBrass--;
iConductor--;
iPercussion--;
iWoodWinds--;
if (section.toString().equals( "Strings" )){
iStrings+=2;
}
else if (section.toString().equals( "Brass" )){
iBrass+=2;
}
else if (section.toString().equals( "Conductor" )){
iConductor+=2;
}
else if (section.toString().equals( "Percussion" )){
iPercussion+=2;
}
else if (section.toString().equals( "WoodWinds" )){
iWoodWinds+=2;
}
but you need to split the code, you will not be able to make both, increase and decrease in the same method.
...Unless you have a value indicating wether it is increase or decrease:
enum DIR{
INCREASE,
DECREASE
}
public void setSection(SymphonySection section, DIR direction) {
if(dircetion.equals(DIR.INCREASE){
}
else{
}
}
if
enum
is not allowed you could also use a
boolean
or
int
value (-1 and 1) for that.