SlideShare a Scribd company logo
// HeadPhone.java
/* All the outputs were same because the variables declared and defined in HeadPhone class
were static,
they will be updated only once during the program execution.
removing the static keyword from the variables which will be updated during the program
execution will
give the desired results
*/
public class HeadPhone {
private static final int LOW = 1;
private static final int MEDIUM = 2;
private static final int HIGH = 3;
private int volume = 0;
private boolean pluggedIn = false;
private String none = null;
private String manufacturer = none;
private String headPhoneColor = none;
private String volPos = none;
private String switchPos= none;
private String onOrOff= none;
// Default Headphone Constructor
public HeadPhone() {
volume = MEDIUM;
pluggedIn = false;
manufacturer = "Sony";
headPhoneColor = "Gold";
}
// Headphone Constructor
public HeadPhone (int volume2, boolean pluggedIn2, String manufacturer2, String
headPhoneColor2) {
volume = volume2;
pluggedIn = pluggedIn2;
manufacturer = manufacturer2;
headPhoneColor = headPhoneColor2;
}
// Setter Methods
// setVolume
public void setVolume(int volume2) {
volume = volume2;
}
// setPluggedIn
public void setPluggedIn(boolean pluggedIn2) {
pluggedIn = pluggedIn2;
}
// setManufacturer
public void setManufacturer(String manufacturer2) {
manufacturer = manufacturer2;
}
// setColor
public void setColor(String headPhoneColor2) {
headPhoneColor = headPhoneColor2;
}
// Getter Methods
// getVolume
public int getVolume() {
if(volume == 3) {
volPos = "HIGH";
}
else if (volume == 2) {
volPos = "MEDIUM";
}
else if(volume == 1) {
volPos = "LOW";
}
else {
System.out.println("Your entry is invalid, please try again.");
}
return volume;
}
//getPluggedIn
public boolean getPluggedIn() {
if(pluggedIn == false) {
onOrOff = "Off";
}
else {
onOrOff = "On";
}
return pluggedIn;
}
//getManufacturer
public String getManufacturer() {
return manufacturer;
}
//getColor
public String getColor() {
return headPhoneColor;
}
// changeVolume method
public void changeVolume(int volume2) {
setVolume(volume2);
}
// toString method
public String toString() {
String str = "toString() results: (volume=" + volume + ", pluggedIn=" + pluggedIn + ",
Manufacturer=" + manufacturer + ", HeadPhone Color=" + headPhoneColor +")";
return str;
}
}
// TestHeadPhone.java
import java.util.Scanner;
public class TestHeadPhone {
public static void main(String[] args) {
int row = 4;
HeadPhone [] hfArray = new HeadPhone[row];
HeadPhone hpObj1 = new HeadPhone();
hfArray[0] = hpObj1;
Scanner input = new Scanner(System.in);
for(int i=1; i<4; i++) {
HeadPhone hpObj2 = new HeadPhone();
System.out.println("Please enter the data for new headphones:");
System.out.println("Would you like to turn the headphones on? (Type 'true' for on, Type
'false' for off: ");
hpObj2.setPluggedIn(input.nextBoolean());
System.out.println("Please the the volume (Options are by integer (1 = Low, 2 = Medium, 3 =
High): ");
hpObj2.setVolume(input.nextInt());
System.out.println("Who manufactured the headphones? (Any string/word(s)");
hpObj2.setManufacturer(input.next());
System.out.println("What are the color of the headphones? (Any string/word(s)");
hpObj2.setColor(input.next());
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
hfArray[i] = hpObj2;
}
for(int i=0; i<4; i++){
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println(hfArray[i].toString());
System.out.println("getPluggedIn() results: "+hfArray[i].getPluggedIn());
System.out.println("getVolume() results: "+hfArray[i].getVolume());
System.out.println("getManufacturer() results: "+hfArray[i].getManufacturer());
System.out.println("getColor() results: "+hfArray[i].getColor());
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}
}
}
/*
output:
Please enter the data for new headphones:
Would you like to turn the headphones on? (Type 'true' for on, Type 'false' for off:
true
Please the the volume (Options are by integer (1 = Low, 2 = Medium, 3 = High):
1
Who manufactured the headphones? (Any string/word(s)
apple
What are the color of the headphones? (Any string/word(s)
white
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~
Please enter the data for new headphones:
Would you like to turn the headphones on? (Type 'true' for on, Type 'false' for off:
true
Please the the volume (Options are by integer (1 = Low, 2 = Medium, 3 = High):
3
Who manufactured the headphones? (Any string/word(s)
sensiner
What are the color of the headphones? (Any string/word(s)
pink
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~
Please enter the data for new headphones:
Would you like to turn the headphones on? (Type 'true' for on, Type 'false' for off:
false
Please the the volume (Options are by integer (1 = Low, 2 = Medium, 3 = High):
2
Who manufactured the headphones? (Any string/word(s)
voda
What are the color of the headphones? (Any string/word(s)
green
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
toString() results: (volume=2, pluggedIn=false, Manufacturer=Sony, HeadPhone Color=Gold)
getPluggedIn() results: false
getVolume() results: 2
getManufacturer() results: Sony
getColor() results: Gold
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
toString() results: (volume=1, pluggedIn=true, Manufacturer=apple, HeadPhone Color=white)
getPluggedIn() results: true
getVolume() results: 1
getManufacturer() results: apple
getColor() results: white
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
toString() results: (volume=3, pluggedIn=true, Manufacturer=sensiner, HeadPhone Color=pink)
getPluggedIn() results: true
getVolume() results: 3
getManufacturer() results: sensiner
getColor() results: pink
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
toString() results: (volume=2, pluggedIn=false, Manufacturer=voda, HeadPhone Color=green)
getPluggedIn() results: false
getVolume() results: 2
getManufacturer() results: voda
getColor() results: green
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
*/
Solution
// HeadPhone.java
/* All the outputs were same because the variables declared and defined in HeadPhone class
were static,
they will be updated only once during the program execution.
removing the static keyword from the variables which will be updated during the program
execution will
give the desired results
*/
public class HeadPhone {
private static final int LOW = 1;
private static final int MEDIUM = 2;
private static final int HIGH = 3;
private int volume = 0;
private boolean pluggedIn = false;
private String none = null;
private String manufacturer = none;
private String headPhoneColor = none;
private String volPos = none;
private String switchPos= none;
private String onOrOff= none;
// Default Headphone Constructor
public HeadPhone() {
volume = MEDIUM;
pluggedIn = false;
manufacturer = "Sony";
headPhoneColor = "Gold";
}
// Headphone Constructor
public HeadPhone (int volume2, boolean pluggedIn2, String manufacturer2, String
headPhoneColor2) {
volume = volume2;
pluggedIn = pluggedIn2;
manufacturer = manufacturer2;
headPhoneColor = headPhoneColor2;
}
// Setter Methods
// setVolume
public void setVolume(int volume2) {
volume = volume2;
}
// setPluggedIn
public void setPluggedIn(boolean pluggedIn2) {
pluggedIn = pluggedIn2;
}
// setManufacturer
public void setManufacturer(String manufacturer2) {
manufacturer = manufacturer2;
}
// setColor
public void setColor(String headPhoneColor2) {
headPhoneColor = headPhoneColor2;
}
// Getter Methods
// getVolume
public int getVolume() {
if(volume == 3) {
volPos = "HIGH";
}
else if (volume == 2) {
volPos = "MEDIUM";
}
else if(volume == 1) {
volPos = "LOW";
}
else {
System.out.println("Your entry is invalid, please try again.");
}
return volume;
}
//getPluggedIn
public boolean getPluggedIn() {
if(pluggedIn == false) {
onOrOff = "Off";
}
else {
onOrOff = "On";
}
return pluggedIn;
}
//getManufacturer
public String getManufacturer() {
return manufacturer;
}
//getColor
public String getColor() {
return headPhoneColor;
}
// changeVolume method
public void changeVolume(int volume2) {
setVolume(volume2);
}
// toString method
public String toString() {
String str = "toString() results: (volume=" + volume + ", pluggedIn=" + pluggedIn + ",
Manufacturer=" + manufacturer + ", HeadPhone Color=" + headPhoneColor +")";
return str;
}
}
// TestHeadPhone.java
import java.util.Scanner;
public class TestHeadPhone {
public static void main(String[] args) {
int row = 4;
HeadPhone [] hfArray = new HeadPhone[row];
HeadPhone hpObj1 = new HeadPhone();
hfArray[0] = hpObj1;
Scanner input = new Scanner(System.in);
for(int i=1; i<4; i++) {
HeadPhone hpObj2 = new HeadPhone();
System.out.println("Please enter the data for new headphones:");
System.out.println("Would you like to turn the headphones on? (Type 'true' for on, Type
'false' for off: ");
hpObj2.setPluggedIn(input.nextBoolean());
System.out.println("Please the the volume (Options are by integer (1 = Low, 2 = Medium, 3 =
High): ");
hpObj2.setVolume(input.nextInt());
System.out.println("Who manufactured the headphones? (Any string/word(s)");
hpObj2.setManufacturer(input.next());
System.out.println("What are the color of the headphones? (Any string/word(s)");
hpObj2.setColor(input.next());
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
hfArray[i] = hpObj2;
}
for(int i=0; i<4; i++){
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println(hfArray[i].toString());
System.out.println("getPluggedIn() results: "+hfArray[i].getPluggedIn());
System.out.println("getVolume() results: "+hfArray[i].getVolume());
System.out.println("getManufacturer() results: "+hfArray[i].getManufacturer());
System.out.println("getColor() results: "+hfArray[i].getColor());
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}
}
}
/*
output:
Please enter the data for new headphones:
Would you like to turn the headphones on? (Type 'true' for on, Type 'false' for off:
true
Please the the volume (Options are by integer (1 = Low, 2 = Medium, 3 = High):
1
Who manufactured the headphones? (Any string/word(s)
apple
What are the color of the headphones? (Any string/word(s)
white
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~
Please enter the data for new headphones:
Would you like to turn the headphones on? (Type 'true' for on, Type 'false' for off:
true
Please the the volume (Options are by integer (1 = Low, 2 = Medium, 3 = High):
3
Who manufactured the headphones? (Any string/word(s)
sensiner
What are the color of the headphones? (Any string/word(s)
pink
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~
Please enter the data for new headphones:
Would you like to turn the headphones on? (Type 'true' for on, Type 'false' for off:
false
Please the the volume (Options are by integer (1 = Low, 2 = Medium, 3 = High):
2
Who manufactured the headphones? (Any string/word(s)
voda
What are the color of the headphones? (Any string/word(s)
green
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
toString() results: (volume=2, pluggedIn=false, Manufacturer=Sony, HeadPhone Color=Gold)
getPluggedIn() results: false
getVolume() results: 2
getManufacturer() results: Sony
getColor() results: Gold
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
toString() results: (volume=1, pluggedIn=true, Manufacturer=apple, HeadPhone Color=white)
getPluggedIn() results: true
getVolume() results: 1
getManufacturer() results: apple
getColor() results: white
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
toString() results: (volume=3, pluggedIn=true, Manufacturer=sensiner, HeadPhone Color=pink)
getPluggedIn() results: true
getVolume() results: 3
getManufacturer() results: sensiner
getColor() results: pink
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
toString() results: (volume=2, pluggedIn=false, Manufacturer=voda, HeadPhone Color=green)
getPluggedIn() results: false
getVolume() results: 2
getManufacturer() results: voda
getColor() results: green
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
*/

More Related Content

Similar to HeadPhone.java All the outputs were same because the variabl.pdf

Hi,Please fidn the Answer.Sorting,h is Header .pdf
Hi,Please fidn the Answer.Sorting,h is Header .pdfHi,Please fidn the Answer.Sorting,h is Header .pdf
Hi,Please fidn the Answer.Sorting,h is Header .pdf
anandf0099
 
C program that prompts user to enter two floating point t.pdf
  C program that prompts user to enter two floating point t.pdf  C program that prompts user to enter two floating point t.pdf
C program that prompts user to enter two floating point t.pdf
aoneonlinestore1
 

Similar to HeadPhone.java All the outputs were same because the variabl.pdf (10)

C++ TUTORIAL 3
C++ TUTORIAL 3C++ TUTORIAL 3
C++ TUTORIAL 3
 
Arduino based applications part 1
Arduino based applications part 1Arduino based applications part 1
Arduino based applications part 1
 
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersAnswers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
 
Hi,Please fidn the Answer.Sorting,h is Header .pdf
Hi,Please fidn the Answer.Sorting,h is Header .pdfHi,Please fidn the Answer.Sorting,h is Header .pdf
Hi,Please fidn the Answer.Sorting,h is Header .pdf
 
C program that prompts user to enter two floating point t.pdf
  C program that prompts user to enter two floating point t.pdf  C program that prompts user to enter two floating point t.pdf
C program that prompts user to enter two floating point t.pdf
 
Pure kotlin
Pure kotlinPure kotlin
Pure kotlin
 
Arduino for Beginners
Arduino for BeginnersArduino for Beginners
Arduino for Beginners
 
Hi,I have updated the code. It is workin fine as expected. Highlig.pdf
Hi,I have updated the code. It is workin fine as expected. Highlig.pdfHi,I have updated the code. It is workin fine as expected. Highlig.pdf
Hi,I have updated the code. It is workin fine as expected. Highlig.pdf
 
Arduino.pptx
Arduino.pptxArduino.pptx
Arduino.pptx
 
Arduino final ppt
Arduino final pptArduino final ppt
Arduino final ppt
 

More from info518726

Program to print all combination of size r in an array of size n.pdf
 Program to print all combination of size r in an array of size n.pdf Program to print all combination of size r in an array of size n.pdf
Program to print all combination of size r in an array of size n.pdf
info518726
 
Solubility in water happens when something is pol.pdf
                     Solubility in water happens when something is pol.pdf                     Solubility in water happens when something is pol.pdf
Solubility in water happens when something is pol.pdf
info518726
 
he coordination compounds , metal complexes or si.pdf
                     he coordination compounds , metal complexes or si.pdf                     he coordination compounds , metal complexes or si.pdf
he coordination compounds , metal complexes or si.pdf
info518726
 
  Polymers are made by joining small molecules into large ones.But m.pdf
  Polymers are made by joining small molecules into large ones.But m.pdf  Polymers are made by joining small molecules into large ones.But m.pdf
  Polymers are made by joining small molecules into large ones.But m.pdf
info518726
 
What is Operational ExcellenceAchieving Operational Excellence requ.pdf
What is Operational ExcellenceAchieving Operational Excellence requ.pdfWhat is Operational ExcellenceAchieving Operational Excellence requ.pdf
What is Operational ExcellenceAchieving Operational Excellence requ.pdf
info518726
 
because Electron Affinity is the amount of energy.pdf
                     because Electron Affinity is the amount of energy.pdf                     because Electron Affinity is the amount of energy.pdf
because Electron Affinity is the amount of energy.pdf
info518726
 
Ques-1Clostredium botulinum, bacteria that cause food poisoning &.pdf
Ques-1Clostredium botulinum, bacteria that cause food poisoning &.pdfQues-1Clostredium botulinum, bacteria that cause food poisoning &.pdf
Ques-1Clostredium botulinum, bacteria that cause food poisoning &.pdf
info518726
 

More from info518726 (20)

Program to print all combination of size r in an array of size n.pdf
 Program to print all combination of size r in an array of size n.pdf Program to print all combination of size r in an array of size n.pdf
Program to print all combination of size r in an array of size n.pdf
 
Methanol is soluble in water. methanol is a one carbon organic alco.pdf
  Methanol is soluble in water.  methanol is a one carbon organic alco.pdf  Methanol is soluble in water.  methanol is a one carbon organic alco.pdf
Methanol is soluble in water. methanol is a one carbon organic alco.pdf
 
Solubility in water happens when something is pol.pdf
                     Solubility in water happens when something is pol.pdf                     Solubility in water happens when something is pol.pdf
Solubility in water happens when something is pol.pdf
 
moles = 0.144 .pdf
                     moles = 0.144                                    .pdf                     moles = 0.144                                    .pdf
moles = 0.144 .pdf
 
It is used to remove water from the organic layer.pdf
                     It is used to remove water from the organic layer.pdf                     It is used to remove water from the organic layer.pdf
It is used to remove water from the organic layer.pdf
 
nitrogen is more electronegative than phosphorus .pdf
                     nitrogen is more electronegative than phosphorus .pdf                     nitrogen is more electronegative than phosphorus .pdf
nitrogen is more electronegative than phosphorus .pdf
 
ionic equation is 2 Cu+2(aq) + 4Cl-(aq) + 4 K+(aq.pdf
                     ionic equation is 2 Cu+2(aq) + 4Cl-(aq) + 4 K+(aq.pdf                     ionic equation is 2 Cu+2(aq) + 4Cl-(aq) + 4 K+(aq.pdf
ionic equation is 2 Cu+2(aq) + 4Cl-(aq) + 4 K+(aq.pdf
 
hydration of alkene. .pdf
                     hydration of alkene.                             .pdf                     hydration of alkene.                             .pdf
hydration of alkene. .pdf
 
H2O + NO + NO2 -- 2HNO2 Three molecules collide.pdf
                     H2O + NO + NO2 -- 2HNO2  Three molecules collide.pdf                     H2O + NO + NO2 -- 2HNO2  Three molecules collide.pdf
H2O + NO + NO2 -- 2HNO2 Three molecules collide.pdf
 
he coordination compounds , metal complexes or si.pdf
                     he coordination compounds , metal complexes or si.pdf                     he coordination compounds , metal complexes or si.pdf
he coordination compounds , metal complexes or si.pdf
 
PdCl2 + 2DMSO PdCl22DMSO It forms a complexe..pdf
                     PdCl2 + 2DMSO  PdCl22DMSO  It forms a complexe..pdf                     PdCl2 + 2DMSO  PdCl22DMSO  It forms a complexe..pdf
PdCl2 + 2DMSO PdCl22DMSO It forms a complexe..pdf
 
melting point of the mixture decreases when small.pdf
                     melting point of the mixture decreases when small.pdf                     melting point of the mixture decreases when small.pdf
melting point of the mixture decreases when small.pdf
 
  Polymers are made by joining small molecules into large ones.But m.pdf
  Polymers are made by joining small molecules into large ones.But m.pdf  Polymers are made by joining small molecules into large ones.But m.pdf
  Polymers are made by joining small molecules into large ones.But m.pdf
 
What is Operational ExcellenceAchieving Operational Excellence requ.pdf
What is Operational ExcellenceAchieving Operational Excellence requ.pdfWhat is Operational ExcellenceAchieving Operational Excellence requ.pdf
What is Operational ExcellenceAchieving Operational Excellence requ.pdf
 
the name arsenic acid, like phosphoric acid (H3PO4), does notconvey .pdf
the name arsenic acid, like phosphoric acid (H3PO4), does notconvey .pdfthe name arsenic acid, like phosphoric acid (H3PO4), does notconvey .pdf
the name arsenic acid, like phosphoric acid (H3PO4), does notconvey .pdf
 
Sucrose is a molecular compound and does not ionize in solution.KC.pdf
Sucrose is a molecular compound and does not ionize in solution.KC.pdfSucrose is a molecular compound and does not ionize in solution.KC.pdf
Sucrose is a molecular compound and does not ionize in solution.KC.pdf
 
C. Increasing the temperature of the system .pdf
                     C. Increasing the temperature of the system      .pdf                     C. Increasing the temperature of the system      .pdf
C. Increasing the temperature of the system .pdf
 
because Electron Affinity is the amount of energy.pdf
                     because Electron Affinity is the amount of energy.pdf                     because Electron Affinity is the amount of energy.pdf
because Electron Affinity is the amount of energy.pdf
 
Ques-1Clostredium botulinum, bacteria that cause food poisoning &.pdf
Ques-1Clostredium botulinum, bacteria that cause food poisoning &.pdfQues-1Clostredium botulinum, bacteria that cause food poisoning &.pdf
Ques-1Clostredium botulinum, bacteria that cause food poisoning &.pdf
 
Programprinting.c#include stdio.hint main() {    cha.pdf
Programprinting.c#include stdio.hint main() {    cha.pdfProgramprinting.c#include stdio.hint main() {    cha.pdf
Programprinting.c#include stdio.hint main() {    cha.pdf
 

Recently uploaded

plant breeding methods in asexually or clonally propagated crops
plant breeding methods in asexually or clonally propagated cropsplant breeding methods in asexually or clonally propagated crops
plant breeding methods in asexually or clonally propagated crops
parmarsneha2
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
YibeltalNibretu
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
Avinash Rai
 

Recently uploaded (20)

50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
plant breeding methods in asexually or clonally propagated crops
plant breeding methods in asexually or clonally propagated cropsplant breeding methods in asexually or clonally propagated crops
plant breeding methods in asexually or clonally propagated crops
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 

HeadPhone.java All the outputs were same because the variabl.pdf

  • 1. // HeadPhone.java /* All the outputs were same because the variables declared and defined in HeadPhone class were static, they will be updated only once during the program execution. removing the static keyword from the variables which will be updated during the program execution will give the desired results */ public class HeadPhone { private static final int LOW = 1; private static final int MEDIUM = 2; private static final int HIGH = 3; private int volume = 0; private boolean pluggedIn = false; private String none = null; private String manufacturer = none; private String headPhoneColor = none; private String volPos = none; private String switchPos= none; private String onOrOff= none; // Default Headphone Constructor public HeadPhone() { volume = MEDIUM; pluggedIn = false; manufacturer = "Sony"; headPhoneColor = "Gold"; } // Headphone Constructor public HeadPhone (int volume2, boolean pluggedIn2, String manufacturer2, String headPhoneColor2) { volume = volume2; pluggedIn = pluggedIn2; manufacturer = manufacturer2;
  • 2. headPhoneColor = headPhoneColor2; } // Setter Methods // setVolume public void setVolume(int volume2) { volume = volume2; } // setPluggedIn public void setPluggedIn(boolean pluggedIn2) { pluggedIn = pluggedIn2; } // setManufacturer public void setManufacturer(String manufacturer2) { manufacturer = manufacturer2; } // setColor public void setColor(String headPhoneColor2) { headPhoneColor = headPhoneColor2; } // Getter Methods // getVolume public int getVolume() { if(volume == 3) { volPos = "HIGH"; } else if (volume == 2) { volPos = "MEDIUM";
  • 3. } else if(volume == 1) { volPos = "LOW"; } else { System.out.println("Your entry is invalid, please try again."); } return volume; } //getPluggedIn public boolean getPluggedIn() { if(pluggedIn == false) { onOrOff = "Off"; } else { onOrOff = "On"; } return pluggedIn; } //getManufacturer public String getManufacturer() { return manufacturer; } //getColor public String getColor() { return headPhoneColor; } // changeVolume method public void changeVolume(int volume2) { setVolume(volume2); }
  • 4. // toString method public String toString() { String str = "toString() results: (volume=" + volume + ", pluggedIn=" + pluggedIn + ", Manufacturer=" + manufacturer + ", HeadPhone Color=" + headPhoneColor +")"; return str; } } // TestHeadPhone.java import java.util.Scanner; public class TestHeadPhone { public static void main(String[] args) { int row = 4; HeadPhone [] hfArray = new HeadPhone[row]; HeadPhone hpObj1 = new HeadPhone(); hfArray[0] = hpObj1; Scanner input = new Scanner(System.in); for(int i=1; i<4; i++) { HeadPhone hpObj2 = new HeadPhone(); System.out.println("Please enter the data for new headphones:"); System.out.println("Would you like to turn the headphones on? (Type 'true' for on, Type 'false' for off: "); hpObj2.setPluggedIn(input.nextBoolean()); System.out.println("Please the the volume (Options are by integer (1 = Low, 2 = Medium, 3 =
  • 5. High): "); hpObj2.setVolume(input.nextInt()); System.out.println("Who manufactured the headphones? (Any string/word(s)"); hpObj2.setManufacturer(input.next()); System.out.println("What are the color of the headphones? (Any string/word(s)"); hpObj2.setColor(input.next()); System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); hfArray[i] = hpObj2; } for(int i=0; i<4; i++){ System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println(hfArray[i].toString()); System.out.println("getPluggedIn() results: "+hfArray[i].getPluggedIn()); System.out.println("getVolume() results: "+hfArray[i].getVolume()); System.out.println("getManufacturer() results: "+hfArray[i].getManufacturer()); System.out.println("getColor() results: "+hfArray[i].getColor()); System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); } }
  • 6. } /* output: Please enter the data for new headphones: Would you like to turn the headphones on? (Type 'true' for on, Type 'false' for off: true Please the the volume (Options are by integer (1 = Low, 2 = Medium, 3 = High): 1 Who manufactured the headphones? (Any string/word(s) apple What are the color of the headphones? (Any string/word(s) white ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~ Please enter the data for new headphones: Would you like to turn the headphones on? (Type 'true' for on, Type 'false' for off: true Please the the volume (Options are by integer (1 = Low, 2 = Medium, 3 = High): 3 Who manufactured the headphones? (Any string/word(s) sensiner What are the color of the headphones? (Any string/word(s) pink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~ Please enter the data for new headphones: Would you like to turn the headphones on? (Type 'true' for on, Type 'false' for off: false Please the the volume (Options are by integer (1 = Low, 2 = Medium, 3 = High): 2 Who manufactured the headphones? (Any string/word(s) voda What are the color of the headphones? (Any string/word(s) green
  • 7. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ toString() results: (volume=2, pluggedIn=false, Manufacturer=Sony, HeadPhone Color=Gold) getPluggedIn() results: false getVolume() results: 2 getManufacturer() results: Sony getColor() results: Gold ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ toString() results: (volume=1, pluggedIn=true, Manufacturer=apple, HeadPhone Color=white) getPluggedIn() results: true getVolume() results: 1 getManufacturer() results: apple getColor() results: white ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ toString() results: (volume=3, pluggedIn=true, Manufacturer=sensiner, HeadPhone Color=pink) getPluggedIn() results: true getVolume() results: 3 getManufacturer() results: sensiner getColor() results: pink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ toString() results: (volume=2, pluggedIn=false, Manufacturer=voda, HeadPhone Color=green) getPluggedIn() results: false getVolume() results: 2 getManufacturer() results: voda getColor() results: green
  • 8. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ */ Solution // HeadPhone.java /* All the outputs were same because the variables declared and defined in HeadPhone class were static, they will be updated only once during the program execution. removing the static keyword from the variables which will be updated during the program execution will give the desired results */ public class HeadPhone { private static final int LOW = 1; private static final int MEDIUM = 2; private static final int HIGH = 3; private int volume = 0; private boolean pluggedIn = false; private String none = null; private String manufacturer = none; private String headPhoneColor = none; private String volPos = none; private String switchPos= none; private String onOrOff= none; // Default Headphone Constructor public HeadPhone() { volume = MEDIUM; pluggedIn = false; manufacturer = "Sony"; headPhoneColor = "Gold"; }
  • 9. // Headphone Constructor public HeadPhone (int volume2, boolean pluggedIn2, String manufacturer2, String headPhoneColor2) { volume = volume2; pluggedIn = pluggedIn2; manufacturer = manufacturer2; headPhoneColor = headPhoneColor2; } // Setter Methods // setVolume public void setVolume(int volume2) { volume = volume2; } // setPluggedIn public void setPluggedIn(boolean pluggedIn2) { pluggedIn = pluggedIn2; } // setManufacturer public void setManufacturer(String manufacturer2) { manufacturer = manufacturer2; } // setColor public void setColor(String headPhoneColor2) { headPhoneColor = headPhoneColor2; } // Getter Methods // getVolume
  • 10. public int getVolume() { if(volume == 3) { volPos = "HIGH"; } else if (volume == 2) { volPos = "MEDIUM"; } else if(volume == 1) { volPos = "LOW"; } else { System.out.println("Your entry is invalid, please try again."); } return volume; } //getPluggedIn public boolean getPluggedIn() { if(pluggedIn == false) { onOrOff = "Off"; } else { onOrOff = "On"; } return pluggedIn; } //getManufacturer public String getManufacturer() { return manufacturer; } //getColor public String getColor() { return headPhoneColor; }
  • 11. // changeVolume method public void changeVolume(int volume2) { setVolume(volume2); } // toString method public String toString() { String str = "toString() results: (volume=" + volume + ", pluggedIn=" + pluggedIn + ", Manufacturer=" + manufacturer + ", HeadPhone Color=" + headPhoneColor +")"; return str; } } // TestHeadPhone.java import java.util.Scanner; public class TestHeadPhone { public static void main(String[] args) { int row = 4; HeadPhone [] hfArray = new HeadPhone[row]; HeadPhone hpObj1 = new HeadPhone(); hfArray[0] = hpObj1; Scanner input = new Scanner(System.in); for(int i=1; i<4; i++) { HeadPhone hpObj2 = new HeadPhone(); System.out.println("Please enter the data for new headphones:");
  • 12. System.out.println("Would you like to turn the headphones on? (Type 'true' for on, Type 'false' for off: "); hpObj2.setPluggedIn(input.nextBoolean()); System.out.println("Please the the volume (Options are by integer (1 = Low, 2 = Medium, 3 = High): "); hpObj2.setVolume(input.nextInt()); System.out.println("Who manufactured the headphones? (Any string/word(s)"); hpObj2.setManufacturer(input.next()); System.out.println("What are the color of the headphones? (Any string/word(s)"); hpObj2.setColor(input.next()); System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); hfArray[i] = hpObj2; } for(int i=0; i<4; i++){ System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println(hfArray[i].toString()); System.out.println("getPluggedIn() results: "+hfArray[i].getPluggedIn()); System.out.println("getVolume() results: "+hfArray[i].getVolume()); System.out.println("getManufacturer() results: "+hfArray[i].getManufacturer()); System.out.println("getColor() results: "+hfArray[i].getColor());
  • 13. System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); } } } /* output: Please enter the data for new headphones: Would you like to turn the headphones on? (Type 'true' for on, Type 'false' for off: true Please the the volume (Options are by integer (1 = Low, 2 = Medium, 3 = High): 1 Who manufactured the headphones? (Any string/word(s) apple What are the color of the headphones? (Any string/word(s) white ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~ Please enter the data for new headphones: Would you like to turn the headphones on? (Type 'true' for on, Type 'false' for off: true Please the the volume (Options are by integer (1 = Low, 2 = Medium, 3 = High): 3 Who manufactured the headphones? (Any string/word(s) sensiner What are the color of the headphones? (Any string/word(s) pink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~ Please enter the data for new headphones: Would you like to turn the headphones on? (Type 'true' for on, Type 'false' for off: false
  • 14. Please the the volume (Options are by integer (1 = Low, 2 = Medium, 3 = High): 2 Who manufactured the headphones? (Any string/word(s) voda What are the color of the headphones? (Any string/word(s) green ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ toString() results: (volume=2, pluggedIn=false, Manufacturer=Sony, HeadPhone Color=Gold) getPluggedIn() results: false getVolume() results: 2 getManufacturer() results: Sony getColor() results: Gold ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ toString() results: (volume=1, pluggedIn=true, Manufacturer=apple, HeadPhone Color=white) getPluggedIn() results: true getVolume() results: 1 getManufacturer() results: apple getColor() results: white ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ toString() results: (volume=3, pluggedIn=true, Manufacturer=sensiner, HeadPhone Color=pink) getPluggedIn() results: true getVolume() results: 3 getManufacturer() results: sensiner getColor() results: pink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • 15. ~~~~~~~~~~~~~~~~~~~~~ toString() results: (volume=2, pluggedIn=false, Manufacturer=voda, HeadPhone Color=green) getPluggedIn() results: false getVolume() results: 2 getManufacturer() results: voda getColor() results: green ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ */