Design and implement a stringed musical instrument violin class using the follow
ID: 3566493 • Letter: D
Question
Design and implement a stringed musical instrument violin class using the following guidelines:
1) to tune the instrument
2) to start the instrument playing
3) to stop the instrument from playing.
4) return number of strings
5) return an array of string names representing string names (e.g. E,A,D,G)
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.
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.");
}
Write the output from your Instrument class methods to a text file that a user entered from the command line arguments (e.g. java violinOutput.txt). This allows your program to accept filenames from the user via a command line argument.
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 such as write string numbers and names, and e) Stop playing your instruments. (Hint: Arrays and Loops will make your job easier and result in more efficient code!)
Your programs should compile and run without errors.
Be sure to test your program carefully. 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.
........................................................
Output file example:
1 object:
The violin is now tunning . . .
The violin is now playing . . .
String numbers is 4 with String names are G D A E
The violin is now stopped.
2 object:
The violin is now tunning . . .
The violin is now playing . . .
String numbers is 4 with String names are G D A E
The violin is now stopped.
3 object:
The violin is now tunning . . .
The violin is now playing . . .
String numbers is 4 with String names are G D A E
The violin is now stopped.
4 object:
The violin is now tunning . . .
The violin is now playing . . .
String numbers is 4 with String names are G D A E
The violin is now stopped.
5 object:
The violin is now tunning . . .
The violin is now playing . . .
String numbers is 4 with String names are G D A E
The violin is now stopped.
6 object:
The violin is now tunning . . .
The violin is now playing . . .
String numbers is 4 with String names are G D A E
The violin is now stopped.
7 object:
The violin is now tunning . . .
The violin is now playing . . .
String numbers is 4 with String names are G D A E
The violin is now stopped.
8 object:
The violin is now tunning . . .
The violin is now playing . . .
String numbers is 4 with String names are G D A E
The violin is now stopped.
9 object:
The violin is now tunning . . .
The violin is now playing . . .
String numbers is 4 with String names are G D A E
The violin is now stopped.
10 object:
The violin is now tunning . . .
The violin is now playing . . .
String numbers is 4 with String names are G D A E
The violin is now stopped.
...........................................................
Your deliverables include a Java instrument file, Java test file and a Word document. The Java instrument file should be named ViolinYournameP3.java. The Java test file should be named ViolinDriverYournameP3.java. Your word document should include your test table, and UML diagrams and descriptions and be named ViolinYournameP3.doc.
---- refer to more detail on the top
ViolinYournameP3.java must include
ViolinYournameP3 class
at least 4 private members
at least 1 constructor
at least 3 set methods
at least 2 get(return) methods
ViolinDriverYournameP3.java must include
main()
Explanation / Answer
import java.util.Arrays;
public class ViolinYourNameP3 {
private int number;
private String[] stringNames={"A","B","C","D","E"};
private boolean tuned;
private boolean currentlyplaying;
public ViolinAlexP3() {
super();
this.tuned = false;
this.currentlyplaying = false;
this.number=stringNames.length;
}
public void tuneViolin() {
tuned=true;
System.out.println("The violin is now tuning......");
}
public void playViolin() {
currentlyplaying=true;
System.out.println("The violin is now playing......");
}
public void stopViolin() {
System.out.println("The violin is now stopped.");
currentlyplaying=false;
tuned=false;
}
public int getNumber() {
return number;
}
public String[] getStringNames() {
return stringNames;
}
public String toString() {
return "The String numbers is :"+getNumber()+" with String names are "+ Arrays.toString(getStringNames());
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.