Professional Documents
Culture Documents
Headphone: Pluggedin Manufacturer Headphonecolor Headphonemodel
Headphone: Pluggedin Manufacturer Headphonecolor Headphonemodel
CMIS 141
July 29 2020
WON KIM
private int volume = MEDIUM; // A private int data field named volume that specifies the volume
of the headphone. The default volume is MEDIUM.
private boolean pluggedIn = false; // A private boolean data field named pluggedIn that specifies if
the headphone is plugged in. The default value is false.
private String manufacturer; // A private String data field named manufacturer that specifies the
name of the manufacturer of the headphones.
private String headPhoneColor; // A private Color data field named headPhoneColor that specifies
the color of the headphones.
private String headPhoneModel; // A private String data field named headPhoneModel that
specifies the Model of the headphones.
// A method named toString() that returns a string describing the current field values of the
headphones.
@Override
public String toString() {
return "HeadPhone [volume=" + volume + ", pluggedIn=" + pluggedIn
+ ", manufacturer=" + manufacturer + ", headPhoneColor="
+ headPhoneColor + ", headPhoneModel=" + headPhoneModel + "]";
}
// A method named changeVolume(value) that changes the volume of the headphone to the value
passed into the method
public int changeVolume(int value){
if(value == 1){
setVolume(getLow());
}else if(value == 2){
setVolume(getMedium());
}else if(value == 3){
setVolume(getHigh());
}
return getVolume();
}
//UMGC- CMIS141
//HOMEWORK 3
//File Name: TestHeadPhone
//Author: STUDENT: WONKIM
package HeadPhone;
}
Test Cases
Expected Output Actual Output Pass?
Headphone # 1 Headphone # 1 Yes
Manufacturer: Bose Manufacturer: Bose
Model: 123 Model: 123
Color: red Color: red
Plugged In: false Plugged In: false
Volume: 1 Volume: 1
Changed vol: 2 Changed vol: 2
Changed pluggedIn: true Changed pluggedIn: true
Changed manufacturer to: Samsung Changed manufacturer to: Samsung
Changed headphone color to: black Changed headphone color to: black
Changed headphone model to:Galaxy Changed headphone model to: Galaxy