Design and implement a stringed musical instrument class using the following gui
ID: 3538391 • Letter: D
Question
Design and implement a stringed musical instrument class using the following guidelines:
a. Data fields for your instrument should include number of strings, an array of string names representing string names (e.g. E,A,D,G), and boolean fields to determine if the instrument is tuned, and if the instrument is currently playing. You are welcome to add additional data fields if you like.
b. A constructor method that set the tuned and currently playing fields to false.
c. Other methods 1) to tune the instrument, 2) to start the instrument playing, and 3) to stop the instrument from playing.
d. Other methods as you see fit (Add at least one unique method).
2. 2. Create a UML class diagram using a diagram tool (e.g. PPT, Visio) of your choice. Prepare the diagrams and place them in a word document along with a brief description of each of your classes.
3. 3. Create Java classes for your instruments. Be sure that your code matches your design specifications and some minimal functionality is included. For example, if you called the violin.play() method, you should at least print that the violin is playing. Similar functionality should be supplied when you stop playing, tune or call any of your methods. For example:
public void playviolin() {
System.out.println("The violin is now playing.");
}
4. 4. Write the output from your Instrument class methods to a text file that a user entered from the command line arguments (e.g. java Mynamep3tst myfilename.txt). This allows your program to accept filenames from the user via a command line argument.
5. 5. Finally, create a Java test class that simulates using your instrument class. In your test class be you should at a minimum: a) Construct 10 instances of your instrument, b) tune your instruments, c) Start playing your instrument, d) Call your unique method, and e) Stop playing your instruments. (Hint: Arrays and Loops will make your job easier and result in more efficient code!)
6. 6. Your programs should compile and run without errors.
7. 7. Provide a list of comprehensive test cases used to validate your application and include these test cases in your word document containing your UML diagrams and descriptions. Similar to Project 1, your test data can be shown in a table that includes input data, expected output, actual output and pass/fail results from the test.
I
I
Explanation / Answer
private int tunedValue; private String name; /* declear the note sound variables here */ public void GuitarString(){ this.isPlaying = false; this.tunedValue = 0; this.name = ""; /* initalize the note here */ } public void GuitarString(String name){ this.isPlaying = false; this.tunedValue = 0; this.name = name; /* initalize the note here */ } public void GuitarString(String name, int tunedValue){ this.isPlaying = false; this.tunedValue = tunedValue; this.name = name; /* initalize the note here */ } //Could make another for a custom note public boolean getisPlaying(){ return this.isPlaying; } public void setisPlaying(boo isPlaying){ this.isPlaying = isPlaying; } public int getTunedValue(){ return this.tunedValue; } public void setTunedValue(int tunedValue){ this.tunedValue = tunedValue; } public int getname(){ return this.name; } public void setName(String name){ this.name= name; } // Then add in methods to make the string functional. public void playNote(){ setIsPlaying(true); /* do playing sound stuff and set tuned value here */ setIsPlaying(true); } } private int tunedValue; private String name; /* declear the note sound variables here */ public void GuitarString(){ this.isPlaying = false; this.tunedValue = 0; this.name = ""; /* initalize the note here */ } public void GuitarString(String name){ this.isPlaying = false; this.tunedValue = 0; this.name = name; /* initalize the note here */ } public void GuitarString(String name, int tunedValue){ this.isPlaying = false; this.tunedValue = tunedValue; this.name = name; /* initalize the note here */ } //Could make another for a custom note public boolean getisPlaying(){ return this.isPlaying; } public void setisPlaying(boo isPlaying){ this.isPlaying = isPlaying; } public int getTunedValue(){ return this.tunedValue; } public void setTunedValue(int tunedValue){ this.tunedValue = tunedValue; } public int getname(){ return this.name; } public void setName(String name){ this.name= name; } // Then add in methods to make the string functional. public void playNote(){ setIsPlaying(true); /* do playing sound stuff and set tuned value here */ setIsPlaying(true); } } private int tunedValue; private String name; /* declear the note sound variables here */ public void GuitarString(){ this.isPlaying = false; this.tunedValue = 0; this.name = ""; /* initalize the note here */ } public void GuitarString(String name){ this.isPlaying = false; this.tunedValue = 0; this.name = name; /* initalize the note here */ } public void GuitarString(String name, int tunedValue){ this.isPlaying = false; this.tunedValue = tunedValue; this.name = name; /* initalize the note here */ } //Could make another for a custom note public boolean getisPlaying(){ return this.isPlaying; } public void setisPlaying(boo isPlaying){ this.isPlaying = isPlaying; } public int getTunedValue(){ return this.tunedValue; } public void setTunedValue(int tunedValue){ this.tunedValue = tunedValue; } public int getname(){ return this.name; } public void setName(String name){ this.name= name; } // Then add in methods to make the string functional. public void playNote(){ setIsPlaying(true); /* do playing sound stuff and set tuned value here */ setIsPlaying(true); } } Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.