can someone please help me fix my code for the following? What i am trying to do
ID: 3646856 • Letter: C
Question
can someone please help me fix my code for the following? What i am trying to do is at the top, and my code is at the bottom of it.2. Design and implement a stringed musical instrument class including the following elements:
a. Identifiers for your instrument should include:
1) An array for the string instrument with at least ten instances.
2) An array for the strings of the string instrument, for example, a guitar normally uses E, A, D, G, B, and E for determining a chord. [Other string instruments have different string configurations. This element can be researched for a different instrument.]
3) Boolean field to determine if the instrument is tuned.
4) Boolean field to determine if the instrument is currently playing.
5) The volume while the instrument is playing (1-10).
6) The register of the instrument (1-5).
7) The tone of the instrument (1-5).
8) The pickup choices (bridge, neck, or both).
9) A chord array based of the size determined by the array of strings mentioned above.
b. A constructor method that initializes the variables in the class.
c. Methods include:
1) An interactive element that requests from the user which of the instances of the string instrument array to change.
2) An interactive process that goes through a set of sequential questions (no menu), changes the values of some or all of the attributes for an instance of the string instrument, for example, from not playing to start playing an instance of guitarFour.
3) A method that selects a specific chord on the string instrument instance for playing.
4) Display in the Output window of NetBeans all processing as the program runs about an instance of the string instrument, e. g, all the questions and answers in the interactive section for the attributes of the string instrument instance.
5) Output to a text file the initial state of the string instrument instance and then the state after processing that instance. [If more than one instance is selected, then each instance appears in the text file.]. The text file should default to the Project folder under CMIS141.
3. The program structure (see Skeleton at end of this document) should have
a. The main function:
1) Declare an array of ten instances for the instrument.
2) Declare an array for the strings of the instrument.
3) Declare the necessary elements for a text file.
4) Declare additional variables as necessary.
5) A looping structure that
Explanation / Answer
please rate - thanks
to fix your current error you need to use 2 files.
if you need help for the rest of the program message me
import java.io.FileNotFoundException;
/**
*
* @author Owner
*/
public class Instrument {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws FileNotFoundException {
java.io.File file = new java.io.File("JamesKinneyp3tst.txt");
//check to see if file already exists
if (file.exists())
{
System.out.println("File already exists");
System.exit(0);
}
//create a file
java.io.PrintWriter output = new java.io.PrintWriter(file);
//declare violin object
Violin violin1 = new Violin();
//write test results to file
output.println(violin1.playViolin());
output.println(violin1.stopPlaying());
output.println(violin1.tuneViolin());
}
}
---------------------------------
class Violin
{
boolean isTuned; //Violin starts off not tuned
boolean isPlaying; //Violin is not playing at start
//array for Violin strings
char [] violinStrings = {'E','A','D','G'};
//default Violin object
public Violin()
{
isTuned = false;
isPlaying = false;
System.out.println("The violin is not playing, and it is not tuned.");
}
public Violin(boolean T, boolean P)
{
isTuned = T;
isPlaying = P;
}
public boolean playViolin()
{
System.out.println("The violin is playing!");
return isPlaying = true;
}
public boolean stopPlaying()
{
System.out.println("The violin has stopped playing.");
return isPlaying = false;
}
public boolean tuneViolin()
{
System.out.println("The violin is being tuned!");
return isTuned = true;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.