19.7k views
1 vote
Write a Java test program, named TestGuitar, to create 3different Guitars representing each representing a unique test case and call each all of the getter methods along with the toString and playGuitar() methods and document the output. Forexample for a Guitarwith 7strings,length of 30.2,manufactured by Fender with a color of Black, the output may look similar to this:

User MirekH
by
3.5k points

1 Answer

7 votes

Answer:

Step-by-step explanation:

//Guitar.java

import java.awt.Color;

import java.lang.reflect.Field;

import java.util.Random;

public class Guitar

/**

* these two fields are used to generate random note and duration

*/

static char[] validNotes = 'A', 'B', 'C', 'D', 'E', 'F', 'G' ;

static double[] validDuration = 0.25, 0.5, 1, 2, 4 ;

/**

* basic guitar attributes

*/

private int numStrings;

private double guitarLength;

private String guitarManufacturer;

private Color guitarColor;

public Guitar()

/**

* default constructor

*/

numStrings = 6;

guitarLength = 28.2;

guitarManufacturer = Gibson;

guitarColor = Color.RED;

public Guitar(int numStrings, double guitarLength,

String guitarManufacturer, Color guitarColor)

/**

* parameterized constructor

*/

this.numStrings = numStrings;

this.guitarLength = guitarLength;

this.guitarManufacturer = guitarManufacturer;

this.guitarColor = guitarColor;

/**

* required getters and setters

*/

public static char[] getValidNotes()

return validNotes;

public static void setValidNotes(char[] validNotes)

Guitar.validNotes = validNotes;

public static double[] getValidDuration()

return validDuration;

public

User Kaloyan Dimitrov
by
3.1k points