Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**This function sets a musician's Orchestra Section.
- @param section is a SymphonySection indicating the musician's Orchestra Section.*/
- public void setSection(SymphonySection section) {
- this.section = section;
- if (getSection().toString().equals( "Strings" )){
- Strings--;
- }
- else if (getSection().toString().equals( "Brass" )){
- Brass--;
- }
- else if (getSection().toString().equals( "Conductor" )){
- Conductor--;
- }
- else if (getSection().toString().equals( "Percussion" )){
- Percussion--;
- }
- else if (getSection().toString().equals( "WoodWinds" )){
- WoodWinds--;
- }
- if (section.toString().equals( "Strings" )){
- Strings++;
- }
- else if (section.toString().equals( "Brass" )){
- Brass ++;
- }
- else if (section.toString().equals( "Conductor" )){
- Conductor ++;
- }
- else if (section.toString().equals( "Percussion" )){
- Percussion ++;
- }
- else if (section.toString().equals( "WoodWinds" )){
- WoodWinds ++;
- }
- }
- private final Map<SymphonySection, Integer> count = new HashMap<>();
- public void setSection(SymphonySection section) {
- if(section == this.section) return;
- count.put(this.section, count.get(this.section)-1);
- Integer prevCount = count.get(section)
- count.put(section, prevCount == null ? 1 : (prevCount+1));
- this.section = section;
- }
Add Comment
Please, Sign In to add comment