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

I am having issues with my 2nd part of my code compiling and running without errors

I am having issues with my 2nd part of my code compiling and running without errors. Can you assist?

//

/*

*File: Guitar.java

*Author: Jessica Hager

*Date: 2/6/2019

*Purpose: This programs explains Guitar Class with constructors, private and public methods.

*/

// Class file for the Guitar.

import java.awt.*;

import java.lang.reflect.Field;

import java.util.*;

import java.util.Random;

public class Guitar1 {

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 Guitar1() {

numStrings = 6;

guitarLength = 28.2;

guitarManufacturer = “Gibson”;

guitarColor = “Red”;

}

public Guitar1(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 + ” }”;

}

}

//

/*

*File: TestGuitar.java

*Author: Jessica Hager

*Date: 2/6/2019

*Purpose: This programs explains Class Test Guitar with methods.

*/

// Class file for the Guitar object. Has four private variables and nine public methods

import java.util.Random;

public class TestGuitar1 {

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”);

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