I have this project due in my intro to programming (java) course. Its supposed to create a string instrument using methods, and play the instrument etc.. I've already done this project once in C#, but for what ever reason I can't seem to get it to work in java. I keep getting an error that "non static variable cannont be referenced from static content. I've searched on here, and so far non of the solutions work for me. Please help. Thanks!!
` /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */
package egreenhornfinal;
import java.util.Scanner;
/**
*
* @author Eddie
*/
public class EGreenhornFinal {
class Guitar
{
boolean isTuned; //Guitar starts off not tuned
boolean isPlaying; //Guitar is not playing at start
boolean isBroken; //Guitar has broken a string
boolean isFixed; //Broken String has been fixed
boolean isNotPlaying; //Guitar has stopped playing
boolean songOver; //The song is over now.
//array for Guitar strings
char[] GuitarStrings = { 'e', 'A', 'D', 'G', 'B', 'E' };
private int numberofStrings = 6;
//default Guitar object
public Guitar()
{
isTuned = false;
isPlaying = false;
isBroken = false;
isFixed = false;
isNotPlaying = false;
songOver = false;
System.out.println("The Guitar is not playing, and it is not tuned. All Strings are intact.\n");
}
public Guitar(boolean T, boolean P)
{
isTuned = T;
isPlaying = P;
}
public boolean playGuitar()
{
System.out.println("The Guitar is playing!\n");
return isPlaying = true;
}
public boolean stopPlaying()
{
System.out.println("The Guitar has stopped playing.\n");
return isNotPlaying = true;
}
public boolean tuneGuitar()
{
System.out.println("The Guitar is being tuned!\n");
return isTuned = true;
}
public boolean brokenString()
{
System.out.println("One of the strings was too tight, it has broken!\n");
return isBroken = true;
}
public boolean fixedString()
{
System.out.println("The broken string has been fixed, the guitar is now playing again.\n");
return isFixed = true;
}
public boolean EndOfSong()
{
System.out.println("The Guitar has stopped playing because the song is over.\n");
return songOver = true;
}
}
/**
*
* @param args
*/
public static void main(String[] args)
{
String WantToPlay = "Y";
do
{
Guitar MyGuitar = new Guitar();
//Error-- Non static variable being referenced from static content??
boolean varIsTuned = false;
varIsTuned = MyGuitar.tuneGuitar();
boolean varIsPlaying = false;
varIsPlaying = MyGuitar.playGuitar();
boolean varIsNotPlaying = true;
varIsNotPlaying = MyGuitar.stopPlaying();
boolean varIsBroken = false;
varIsBroken = MyGuitar.brokenString();
boolean varIsFixed = false;
varIsFixed = MyGuitar.fixedString();
boolean varsongOver = false;
varsongOver = MyGuitar.EndOfSong();
System.out.println("Would you like to play the Guitar again? (enter Y for yes, and N for no)");
Scanner inUsr = new Scanner(System.in);
WantToPlay = inUsr.nextLine();
}
while (WantToPlay == "Y");
}
}
`