Two-argument constructor that creates a headphone object


Create a Java class named HeadPhone to represent a headphone set. The class contains:
- Three integer constants named LOW, MEDIUM, and HIGH with values of 1, 2, and 3.
- A private int data field named volume that contains the volume setting of the headphone. The default value is HIGH.
- A private boolean data field named pluggedIn that specifies if the headphone is plugged in. The default value is false.
- A private String data field named manufacturer that specifies the name of the manufacturer of the headphones.
- A private Color data field named headPhoneColor that specifies the color of the headphones. This must be an object of the java.awt.Color class. (You will need to look up the features of this class.)
- A two-argument constructor that creates a HeadPhone object with specified manufacturer name and color, and default values for all other data fields.
- A method named toString() that returns a String object describing the current field values of the headphone.
- A method named changeVolume(int value) that changes the volume of the headphone to the value passed into the method. If the provided value is invalid, the volume shall not be changed.
- getter methods for all data fields, and setter methods for all data fields except manufacturer name and device color and volume. ()
(Note: It's not appropriate to provide "set" methods for the manufacturer and color because in the real world, manufacturer and color of a shipped product cannot be changed. Also, we don't want a "set" method for volume because that function is provided by the changeVolume method, which provides the needed input data validation.)
Create a TestHeadPhone main class to test the HeadPhone class. For each test, the necessary inputs shall be obtained from the tester (user). Each feature of the Headphone class shall be tested by comparing outputs from the getter methods to the required values. Test three different headphones. (Hint: put the test code in a loop.)
Use your IDE to accomplish this assignment.
Grading criteria are the same as for Assignments 1 and 2, and so are not restated here.
Submission requirements
Java Style:
- Header comments include filename, author, date, and brief description of the purpose of the program
- In-line comments as needed to explain any non-obvious code.
- Meaningful variable names and user prompts
- Class names in UpperCamelCase

Attachment:- Java code.rar

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Two-argument constructor that creates a headphone object
Reference No:- TGS02392271

Now Priced at $35 (50% Discount)

Recommended (99%)

Rated (4.3/5)