Can somebody help me with this and possibly have it finished quickly. I have som
ID: 3551885 • Letter: C
Question
Can somebody help me with this and possibly have it finished quickly. I have some code started,
This project focuses on demonstrating your understanding of classes and objects. Before attempting this project, be sure you have completed all of the reading assignments listed in the syllabus to date, participated in the weekly conferences, and thoroughly understand the examples throughout the chapters. The project requirements include:
Design and implement a stringed musical instrument class using the following guidelines:
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 Mynamep3tst myfilename.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, 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.
Explanation / Answer
public class Hippopotamus{
//fields to determine if the instrument is isTuned,
private boolean isTuned;
//and if the instrument is currently isPlaying.
private boolean isPlaying;
private String name;
private int numberOfStrings = 4; // number of strings
private String nameofStringsInInstrument[] = {"E", "C", "D", "A"}; //an array of string names
//A constructor method that set the isTuned and currently isPlaying fields to false.
public AndrewRubinFinalProject() {
this.isTuned = false;
this.isPlaying = false;
}
public String getNameOfInstrument() {
return this.name;
}
public void setNameOfInstrument(String nameOfInstrument) {
this.name = nameOfInstrument;
}
// Other methods
public boolean isPlaying() {
return this.isPlaying;
}
public void setPlaying(boolean playing) {
this.isPlaying = playing;
}
public boolean isTuned() {
return this.isTuned;
}
public void setTuned(boolean isTuned) {
this.isTuned = isTuned;
}
public void startPlayInstrument() {
System.out.println("The Instrument is now Playing.");
this.isPlaying = true;
}
public void stopPlayInstrument() {
System.out.println("The Instrument is not Playing anymore.");
this.isPlaying = false;
}
public void startTuneInstrument() {
System.out.println("The Instrument is Tuned.");
this.isTuned = true;
}
public void stopTuneInstrument() {
System.out.println("The Instrument is not Tuned.");
this.isTuned = false;
}
public int getNumberOfStrings() {
return this.numberOfStrings ;
}
public String[] getStringNames() {
return this.nameofStringsInInstrument;
}
}
A new program to test and run
public class Main
{
public static void main(String[] args){
Hippopotamus andrewsObject= new Hippopotamus();
// you can call any method in your class with respect to andrewsObject
// e.g.
// andrewsObject.setNameOfInstrument("Violin");
// String x= andrewsObject.getNameOfInstrument()
}
}