Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

import java.awt.*; import java.lang.reflect.Field; import java.util.*; public class Guitar {                  //Private data fields private int numStrings = 6; private double guitarLength = 28.2; private String guitarManufacturer = “Gibson”;

import java.awt.*; import java.lang.reflect.Field; import java.util.*;

public class Guitar {

 

 

 

//Private data fields

private int numStrings = 6;

private double guitarLength = 28.2;

private String guitarManufacturer = “Gibson”;

private Color guitarColor;

//No argument constructor that creates a Guitar using the default parameters

//Public method

 

public Guitar constructor() {

this.numStrings = 6;

this.guitarLength = 28.2;

this.guitarManufacturer = “Gibson”;

this.guitarColor = Color.red;

return this;

}

//A constructor that creates a Guitar using specified parameters

public Guitar constructor(int strings, double length, String manufacturer, Color color) {

this.numStrings = strings;

this.guitarLength = length;

this.guitarManufacturer = manufacturer;

this.guitarColor = color;

return this;

}

//Getter methods for data fields

public int getNumStrings() {

return this.numStrings;

}

public double getGuitarLength() {

return this.guitarLength;

}

public String getGuitarManufacturer() {

return this.guitarManufacturer;

}

public Color getGuitarColor() {

return this.guitarColor;

}

//playGuitar method to return a string of 16 randomly selected notes and duration

public String playGuitar() {

String play = “[“;

//arrays with possible notes and duration

char[] notes = {‘A’,’B’,’C’,’D’,’E’,’F’,’G’};

double[] duration = {0.25,0.5,1,2,4};

int a;

int b;

//initiate random number

Random rn = new Random();

//for loop for 16 random notes and duration

for (int k=0;k<16;k++) {

a = rn.nextInt(7);

b = rn.nextInt(5);

play = play + notes[a] + “(” + String.valueOf(duration[b]) + “)”;

if (k!=15) play = play + “, “;

}

play = play + ‘]’;

return play;

}

//toString which displays guitar parameters

public String toString() {

String infoString = “(numStrings=”+this.numStrings+”, Length=”+this.guitarLength+”, manufacturer=”+this.guitarManufacturer+”, color=”+colorName(this.guitarColor).orElse(“no name found”) +”)”;

return infoString;

}

//method to get color name

public Optional<String> colorName(Color c) {

for (Field f : Color.class.getDeclaredFields()) {

//test fields of type Color

if (f.getType().equals(Color.class)) try {

if (f.get(null).equals(c)) return Optional.of(f.getName().toLowerCase());

}

catch (IllegalArgumentException | IllegalAccessException e) {

e.printStackTrace();

}

}

return Optional.empty();

}

 

}

I keep getting compiler error for this saying:

Error: Main method not found in class Guitar, please define the main method as:

public static void main(String[] args)

or a JavaFX application class must extend javafx.application.Application

How do I fix this?

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"