Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I keep getting a bracket error when compiling the java code. Any help would be helpful. Thank you. import java.util.Random; import java.lang.StringBuilder; public class Guitar{

I keep getting a bracket error when compiling the java code. Any help would be helpful. Thank you.

import java.util.Random; import java.lang.StringBuilder;

public class Guitar{ private int numStrings; private double guitarLength; private String guitarManufacturer; private String guitarColor;

// Guitar constructor public Guitar (int numS, double guitarL, String guitarM, String guitarC){ numStrings = numS; guitarLength = guitarL; guitarManufacturer = guitarM; guitarColor = guitarC; }

// Default Guitar constructor public Guitar (){ numStrings = 6; guitarLength = 28.2; guitarManufacturer = "Gibson"; guitarColor = "Red"; }

// Setter methods // setNumS public void setNumStrings(int numS){ numStrings = numS; }

// setGuitarLength public void setGuitarLength(double guitarL){ guitarLength = guitarL; }

// setGuitarManufacture public void setGuitarManufacturer(String guitarM){ guitarManufacturer = guitarM; }

// setGuitarColor public void setGuitarColor(String guitarC){ guitarColor = guitarC; }

// Getter methods // getNumStrings public int getNumStrings(){ return numStrings; }

// getGuitarLength public double getGuitarLength(){ return guitarLength; }

// getGuitarManufacturer public String getGuitarManufacturer(){ return guitarManufacturer; }

// getGuitarColor public String getGuitarColor(){ return guitarColor; }

// Random musical note generator public String playGuitar(){ Random randomGenerator = new Random(System.currentTimeMillis()); String[] validNotes = {"A", "B", "C", "D", "E", "F", "G"}; String[] durationValues = {"0.25", "0.5", "1", "2", "4"};

// String builder for musical notes StringBuilder musicalNote = new StringBuilder("["); for (int i=0; i<16; i++){ musicalNote.append(validNotes[randomGenerator.nextInt(7)] + "(" + durationValues[randomGenerator.nextInt(5)] + "),"); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

Students also viewed these Databases questions