package progusingjava;
//DO NOT MODIFY THE CODE PROVIDED TO YOU
public class MusicInstrumentCourse { private String instrumentCourseName; private int courseDuration; private double courseFee; private static String[] instrumentCourseAvailableArr = { "Piano", "Drum", "Guitar" }; private static double[] instrumentCourseCostArr = { 2000.0, 3000.0, 2500.0 };
public MusicInstrumentCourse(String instrumentCourseName, int courseDuration) { this.instrumentCourseName = instrumentCourseName; this.courseDuration = courseDuration; } public String getInstrumentCourseName() { return this.instrumentCourseName; } public double getCourseFee() { return this.courseFee; } public int getCourseDuration() { return this.courseDuration; } public boolean validateMusicInstrumentCourse() { return (this.instrumentCourseName.equals("Piano") || this.instrumentCourseName.equals("Drum") || this.instrumentCourseName.equals("Guitar")); } // To Trainees public void calculateCourseFee() { this.courseFee = -1.0; instrumentCourseName = instrumentCourseName.toLowerCase(); boolean courseFound = false; double basicCost = 0.0; for (int i = 0; i < instrumentCourseAvailableArr.length; i++) { if (instrumentCourseAvailableArr[i].equalsIgnoreCase(instrumentCourseName)) { courseFound = true; basicCost = instrumentCourseCostArr[i]; break; } } if (courseFound && basicCost != 0.0) { double basicFee = basicCost * courseDuration; double facilitiesFee = 0.1 * basicFee; basicFee += facilitiesFee; this.courseFee = basicFee; } } @Override public String toString() { return "MusicInstrumentCourse (instrumentCourseName=" + this.instrumentCourseName + ", courseDuration=" + this.courseDuration + ")"; }
}
Some comments have been hidden by the post's author - find out more
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
package progusingjava;
//DO NOT MODIFY THE CODE PROVIDED TO YOU
public class MusicInstrumentCourse {
private String instrumentCourseName;
private int courseDuration;
private double courseFee;
private static String[] instrumentCourseAvailableArr = { "Piano", "Drum", "Guitar" };
private static double[] instrumentCourseCostArr = { 2000.0, 3000.0, 2500.0 };
}