I’m going to show two java programs please tell me what I’m missing import java.awt.*;
I’m going to show two java programs please tell me what I’m missing
import java.awt.*;
import java.lang.reflect.Field;
import java.util.*;
import java.util.Random;
public class Guitar {
private int numStrings;
private double guitarLength;
private String guitarManufacturer;
private String guitarColor;
static char arr[] = new char[]{‘A’,’B’,’C’,’D’,’E’,’F’,’G’};
static double val[] = new double[]{.25,.5,1,2,4};
public Guitar() {
numStrings = 6;
guitarLength = 28.2;
guitarManufacturer = “Gibson”;
guitarColor = “Red”;
}
public Guitar(int num, double length, String manufacturer, String color) {
numStrings = num;
guitarLength = length;
guitarManufacturer = manufacturer;
guitarColor = color;
}
public int getNumStrings() {
return numStrings;
}
public double getGuitarLength() {
return guitarLength;
}
public String getGuitarManufacturer() {
return guitarManufacturer;
}
public String getGuitarColor() {
return guitarColor;
}
public String playGuitar(){
Random r1 = new Random();
int v1, v2;
Random r2 = new Random();
String str = “”;
str = str + “[ “;
for(int i=0;i<16;++i){
v1 = r1.nextInt(4);
v2 = r2.nextInt(4);
if(i==15)
str = str +arr[v1]+ “(“+val[v2]+”)” + ” ]”;
else
str = str +arr[v1]+ “(“+val[v2]+”)” + “, “;
}
return str;
}
public String toString() {
return “{ numStrings = ” + numStrings + “, Length = ” + guitarLength + “, manufacturer = ”
+ guitarManufacturer + “, color = ” + guitarColor + ” }”;
}
}
and
import java.util.Random;
public class TestGuitar {
public static void main(String args[]) {
Guitar guitarOne = new Guitar();
Guitar guitarTwo = new Guitar(7, 30.2, “Fender”, “Black”);
Guitar guitarThree = new Guitar(8, 33, “Titan”, “Brown”);
printGuitar(guitarOne);
printGuitar(guitarTwo);
printGuitar(guitarThree);
}
public static void printGuitar(Guitar guitar) {
System.out.println(“\n\ntoString() : ” + guitar.toString());
System.out.println(“getNumStrings() : ” + guitar.getNumStrings());
System.out.println(“getGuitarLength() : ” +guitar.getGuitarLength());
System.out.println(“getGuitarColor() : ” +guitar.getGuitarColor());
System.out.print(“playGuitar() : ” + guitar.playGuitar() + “\n\n”);
}